Möglicherweise ist MaxVeh[playerid] auf 1?
Ich habe es so definiert:
new MaxVeh[MAX_PLAYERS];
Was muss ich machen, dass das Carkey funktioniert?
Möglicherweise ist MaxVeh[playerid] auf 1?
Ich habe es so definiert:
new MaxVeh[MAX_PLAYERS];
Was muss ich machen, dass das Carkey funktioniert?
new MaxVeh[MAX_PLAYERS] = {3, ...};
3 = Anzahl die man standardmäßig haben kann. Das ... einfach so lassen.
3 = Anzahl die man standardmäßig haben kann. Das ... einfach so lassen.
Ich bekomme jetzt die meldung das ich schon 1 Fahrzeug besitze.
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_AUTOKAUFEN)
{
if(response == 1)
{
new string[128];
for(new s=0; s<MAX_CARS_PER_PLAYER; s++)
{
if (Spectating[playerid][0]!=-1)
{
if (Carlist[playerid][s][Typ]==-1)
{
new preis = Kaufliste[Spectating[playerid][0]][Preis];
if(Spectating[playerid][0] == -1)
{
//Motorhaube zu
new vid = GetPlayerVehicleID(playerid);
new engine,lights1,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,engine,lights1,alarm,doors,VEHICLE_PARAMS_OFF,boot,objective);
//Kofferraum zu
GetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,VEHICLE_PARAMS_OFF,objective);
//Licht aus
GetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,engine,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot,objective);
SendClientMessage(playerid, COLOR_GRAD1, "Du besichtigst kein Fahrzeug!");
TogglePlayerControllable(playerid,1);
SetVehicleParamsForAll(Kaufliste[Spectating[playerid][0]][Carid],0,0);
Spectating[playerid][0]=-1;
RemovePlayerFromVehicle(playerid);
}
else if (preis <= GetPlayerMoney(playerid))
{
new autohaus=Kaufliste[Spectating[playerid][0]][Autohaus];
//Motorhaube zu
new vid = GetPlayerVehicleID(playerid);
new engine,lights1,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,engine,lights1,alarm,doors,VEHICLE_PARAMS_OFF,boot,objective);
//Kofferraum zu
GetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,VEHICLE_PARAMS_OFF,objective);
//Licht aus
GetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,engine,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot,objective);
GivePlayerMoney(playerid, - preis);
Carlist[playerid][s][Typ]=Spectating[playerid][0]; Carlist[playerid][s][X]=Autospawns[autohaus][X]; Carlist[playerid][s][Y]=Autospawns[autohaus][Y];
Carlist[playerid][s][Z]=Autospawns[autohaus][Z]; Carlist[playerid][s][Rotation]=Autospawns[autohaus][Rotation]; Carlist[playerid][s][Status]=1; Carlist[playerid][s][Lock]=0;
Carlist[playerid][s][Carid]=CreateVehicle(Kaufliste[Spectating[playerid][0]][Modelid],Carlist[playerid][s][X],Carlist[playerid][s][Y],Carlist[playerid][s][Z],Carlist[playerid][s][Rotation],-1,-1,-1);
SetVehicleParamsForAll(Kaufliste[Spectating[playerid][0]][Carid],0,0);
TogglePlayerControllable(playerid,1);
Spectating[playerid][0]=-1;
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_WHITE, " ");
format(string,128,"Du hast dir erfolgreich für $%i das Fahrzeug %s gekauft.",preis,Kaufliste[Carlist[playerid][s][Typ]][Name]);
SendClientMessage(playerid, COLOR_GREEN, string);
SendClientMessage(playerid, COLOR_YELLOW, "* Wenn dein Fahrzeug zerstört ist, gib /freparieren ein um es zu reparieren.");
SendClientMessage(playerid, COLOR_YELLOW, "* Du kannst dein Fahrzeug mit /flock, auf- und abschließen.");
SendClientMessage(playerid, COLOR_YELLOW, "* Mehr Befehle kannst du unter /fahrzeughelp sehen.");
SendClientMessage(playerid, COLOR_WHITE, " ");
SendClientMessage(playerid, COLOR_GREEN, "Dein Fahrzeug steht nun am Ausgabepunkt bereit! Viel Spaß mit dein neuen Fahrzeug");
SendClientMessage(playerid, COLOR_WHITE, " ");
SendClientMessage(playerid, COLOR_GREEN, "Fahr Vorsichtig!");
SendClientMessage(playerid, COLOR_WHITE, " ");
}
else
{
//Motorhaube zu
new vid = GetPlayerVehicleID(playerid);
new engine,lights1,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,engine,lights1,alarm,doors,VEHICLE_PARAMS_OFF,boot,objective);
//Kofferraum zu
GetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,VEHICLE_PARAMS_OFF,objective);
//Licht aus
GetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,engine,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot,objective);
format(string, 128, "Du hast nicht keine $%i um das Fahrzeug zu kaufen.", preis); SendClientMessage(playerid, COLOR_GRAD1, string);
TogglePlayerControllable(playerid,1);
SetVehicleParamsForAll(Kaufliste[Spectating[playerid][0]][Carid],0,0);
Spectating[playerid][0]=-1;
RemovePlayerFromVehicle(playerid);
}
return 1;
}
else
{
//Motorhaube zu
new vid = GetPlayerVehicleID(playerid);
new engine,lights1,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,engine,lights1,alarm,doors,VEHICLE_PARAMS_OFF,boot,objective);
//Kofferraum zu
GetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,VEHICLE_PARAMS_OFF,objective);
//Licht aus
GetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,engine,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot,objective);
SendClientMessage(playerid, COLOR_GRAD1, "Du besitzt bereits ein Auto!");
TogglePlayerControllable(playerid,1);
SetVehicleParamsForAll(Kaufliste[Spectating[playerid][0]][Carid],0,0);
Spectating[playerid][0]=-1;
RemovePlayerFromVehicle(playerid);
}
}
}
}
if(response == 0)
{
//Motorhaube zu
new vid = GetPlayerVehicleID(playerid);
new engine,lights1,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,engine,lights1,alarm,doors,VEHICLE_PARAMS_OFF,boot,objective);
//Kofferraum zu
GetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,VEHICLE_PARAMS_OFF,objective);
//Licht aus
GetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,engine,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot,objective);
SendClientMessage(playerid,COLOR_GRAD1,"Du hast den Fahrzeugkauf beendet.");
TogglePlayerControllable(playerid,1);
SetVehicleParamsForAll(Kaufliste[Spectating[playerid][0]][Carid],0,0);
Spectating[playerid][0]=-1;
RemovePlayerFromVehicle(playerid);
return 1;
}
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_AUTOKAUFEN)
{
if(response == 1)
{
new string[128];
for(new s=0; s<MAX_CARS_PER_PLAYER; s++)
{
if (Spectating[playerid][0]!=-1)
{
if (Carlist[playerid][s][Typ]==-1)
{
new preis = Kaufliste[Spectating[playerid][0]][Preis];
if(Spectating[playerid][0] == -1)
{
//Motorhaube zu
new vid = GetPlayerVehicleID(playerid);
new engine,lights1,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,engine,lights1,alarm,doors,VEHICLE_PARAMS_OFF,boot,objective);
//Kofferraum zu
GetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,VEHICLE_PARAMS_OFF,objective);
//Licht aus
GetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,engine,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot,objective);
SendClientMessage(playerid, COLOR_GRAD1, "Du besichtigst kein Fahrzeug!");
TogglePlayerControllable(playerid,1);
SetVehicleParamsForAll(Kaufliste[Spectating[playerid][0]][Carid],0,0);
Spectating[playerid][0]=-1;
RemovePlayerFromVehicle(playerid);
}
else if (preis <= GetPlayerMoney(playerid))
{
new autohaus=Kaufliste[Spectating[playerid][0]][Autohaus];
//Motorhaube zu
new vid = GetPlayerVehicleID(playerid);
new engine,lights1,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,engine,lights1,alarm,doors,VEHICLE_PARAMS_OFF,boot,objective);
//Kofferraum zu
GetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,VEHICLE_PARAMS_OFF,objective);
//Licht aus
GetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,engine,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot,objective);
GivePlayerMoney(playerid, - preis);
Carlist[playerid][s][Typ]=Spectating[playerid][0]; Carlist[playerid][s][X]=Autospawns[autohaus][X]; Carlist[playerid][s][Y]=Autospawns[autohaus][Y];
Carlist[playerid][s][Z]=Autospawns[autohaus][Z]; Carlist[playerid][s][Rotation]=Autospawns[autohaus][Rotation]; Carlist[playerid][s][Status]=1; Carlist[playerid][s][Lock]=0;
Carlist[playerid][s][Carid]=CreateVehicle(Kaufliste[Spectating[playerid][0]][Modelid],Carlist[playerid][s][X],Carlist[playerid][s][Y],Carlist[playerid][s][Z],Carlist[playerid][s][Rotation],-1,-1,-1);
SetVehicleParamsForAll(Kaufliste[Spectating[playerid][0]][Carid],0,0);
TogglePlayerControllable(playerid,1);
Spectating[playerid][0]=-1;
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_WHITE, " ");
format(string,128,"Du hast dir erfolgreich für $%i das Fahrzeug %s gekauft.",preis,Kaufliste[Carlist[playerid][s][Typ]][Name]);
SendClientMessage(playerid, COLOR_GREEN, string);
SendClientMessage(playerid, COLOR_YELLOW, "* Wenn dein Fahrzeug zerstört ist, gib /freparieren ein um es zu reparieren.");
SendClientMessage(playerid, COLOR_YELLOW, "* Du kannst dein Fahrzeug mit /flock, auf- und abschließen.");
SendClientMessage(playerid, COLOR_YELLOW, "* Mehr Befehle kannst du unter /fahrzeughelp sehen.");
SendClientMessage(playerid, COLOR_WHITE, " ");
SendClientMessage(playerid, COLOR_GREEN, "Dein Fahrzeug steht nun am Ausgabepunkt bereit! Viel Spaß mit dein neuen Fahrzeug");
SendClientMessage(playerid, COLOR_WHITE, " ");
SendClientMessage(playerid, COLOR_GREEN, "Fahr Vorsichtig!");
SendClientMessage(playerid, COLOR_WHITE, " ");
}
else
{
//Motorhaube zu
new vid = GetPlayerVehicleID(playerid);
new engine,lights1,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,engine,lights1,alarm,doors,VEHICLE_PARAMS_OFF,boot,objective);
//Kofferraum zu
GetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,VEHICLE_PARAMS_OFF,objective);
//Licht aus
GetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,engine,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot,objective);
format(string, 128, "Du hast nicht keine $%i um das Fahrzeug zu kaufen.", preis); SendClientMessage(playerid, COLOR_GRAD1, string);
TogglePlayerControllable(playerid,1);
SetVehicleParamsForAll(Kaufliste[Spectating[playerid][0]][Carid],0,0);
Spectating[playerid][0]=-1;
RemovePlayerFromVehicle(playerid);
}
return 1;
}
}
}
//Motorhaube zu
new vid = GetPlayerVehicleID(playerid);
new engine,lights1,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,engine,lights1,alarm,doors,VEHICLE_PARAMS_OFF,boot,objective);
//Kofferraum zu
GetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,VEHICLE_PARAMS_OFF,objective);
//Licht aus
GetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,engine,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot,objective);
SendClientMessage(playerid, COLOR_GRAD1, "Du besitzt bereits die maximale Anzahl an Fahrzeugen!");
TogglePlayerControllable(playerid,1);
SetVehicleParamsForAll(Kaufliste[Spectating[playerid][0]][Carid],0,0);
Spectating[playerid][0]=-1;
RemovePlayerFromVehicle(playerid);
}
if(response == 0)
{
//Motorhaube zu
new vid = GetPlayerVehicleID(playerid);
new engine,lights1,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,engine,lights1,alarm,doors,VEHICLE_PARAMS_OFF,boot,objective);
//Kofferraum zu
GetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,VEHICLE_PARAMS_OFF,objective);
//Licht aus
GetVehicleParamsEx(vid,engine,lights1,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,engine,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot,objective);
SendClientMessage(playerid,COLOR_GRAD1,"Du hast den Fahrzeugkauf beendet.");
TogglePlayerControllable(playerid,1);
SetVehicleParamsForAll(Kaufliste[Spectating[playerid][0]][Carid],0,0);
Spectating[playerid][0]=-1;
RemovePlayerFromVehicle(playerid);
return 1;
}
}
return 1;
}
Danke nochmal das du mir Hilfst
Ich kann jetzt jedoch die befehle nicht
Du musst die Schleife
for(new s=0; s<MAX_CARS_PER_PLAYER; s++)
in den Befehlen jeweils mit dem Key ersetzen, dafür hast du die Keys ja gemacht. Du willst doch nicht alle Fahrzeuge auf einmal verkaufen, sondern nur eins, also das von dem du den Schlüssel hast.
new s = CarKey[playerid];
Die Schleifen musst du an entsprechenden Befehlen weg machen. Wie bereits erwähnt, darfst du die Schleifen nur dort verwenden, wo du etwas für alle Fahrzeuge eines Spielers machen willst.
Wenn ich bei dem 2. Fahrzeug /parken machen will kommt eine Fehlermeldung. (Du sitzt nicht in deinem eigenen Fahrzeug!)
if(strcmp(cmd, "/parken", true) == 0)
{
new s = CarKey[playerid];
if (IsPlayerInVehicle(playerid,Carlist[playerid][s][Carid]))
{
GetVehiclePos(Carlist[playerid][s][Carid],Carlist[playerid][s][X],Carlist[playerid][s][Y],Carlist[playerid][s][Z]);
GetVehicleZAngle(Carlist[playerid][s][Carid],Carlist[playerid][s][Rotation]);
SendClientMessage(playerid, COLOR_WHITE, "{FFFFFF}» Dein Fahrzeug wurde nun an dieser Position {006600}erfolgreich{FFFFFF} geparkt.");
}
else { SendClientMessage(playerid, COLOR_GRAD1, "Du sitzt nicht in deinem eigenen Fahrzeug!"); }
return 1;
}
Dann wurde die Fahrzeug-ID nicht richtig gespeichert.
Wie lädst du die Fahrzeuge denn?
Oder du hast den falschen Schlüssel.
so wird das geladen.
public OnPlayerConnect(playerid)
{
new dateiname[MAX_PLAYER_NAME+25];
new playername[MAX_PLAYER_NAME+25];
for(new s=0; s<MAX_CARS_PER_PLAYER; s++)
{
Carlist[playerid][s][Typ]=-1; Carlist[playerid][s][X]=0.0; Carlist[playerid][s][Y]=0.0; Carlist[playerid][s][Z]=0.0;
Carlist[playerid][s][Rotation]=0.0; Carlist[playerid][s][Status]=0; Carlist[playerid][s][Lock]=0; Carlist[playerid][s][Carid]=-1;
Carlist[playerid][s][Farbe1]=-1; Carlist[playerid][s][Farbe2]=-1; Carlist[playerid][s][mod1]=-1; Carlist[playerid][s][mod2]=-1;
Carlist[playerid][s][mod3]=-1; Carlist[playerid][s][mod4]=-1; Carlist[playerid][s][mod5]=-1; Carlist[playerid][s][mod6]=-1;
Carlist[playerid][s][mod7]=-1; Carlist[playerid][s][mod8]=-1; Carlist[playerid][s][mod9]=-1; Carlist[playerid][s][mod10]=-1;
Carlist[playerid][s][mod11]=-1; Carlist[playerid][s][mod12]=-1; Carlist[playerid][s][mod13]=-1; Carlist[playerid][s][mod14]=-1;
Carlist[playerid][s][mod15]=-1; Carlist[playerid][s][mod16]=-1; Carlist[playerid][s][mod17]=-1; Carlist[playerid][s][Paintjob]=-1;
}
Spectating[playerid][0]=-1;
#if defined CARSELL
bietetAn[playerid]={-1,0};
#endif
GetPlayerName(playerid, playername, sizeof(playername));
for(new s=0; s<MAX_CARS_PER_PLAYER; s++)
{
format(dateiname, sizeof(dateiname), "/GekaufteFahrzeuge/%s%d.car", playername,s);
if (fexist(dateiname))
{
new File: CarFile = fopen(dateiname, io_read);
if ( CarFile )
{
new key[ 256 ];
new Data[ 256 ];
while ( fread( CarFile , Data , sizeof( Data ) ) )
{
key = ini_GetKey(Data);
if(strcmp(key,"AH_Typ",true)==0) { Carlist[playerid][s][Typ]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_X",true)==0) { Carlist[playerid][s][X]=floatstr(ini_GetValue(Data)); }
else if(strcmp(key,"AH_Y",true)==0) { Carlist[playerid][s][Y]=floatstr(ini_GetValue(Data)); }
else if(strcmp(key,"AH_Z",true)==0) { Carlist[playerid][s][Z]=floatstr(ini_GetValue(Data)); }
else if(strcmp(key,"AH_Rot",true)==0) { Carlist[playerid][s][Rotation]=floatstr(ini_GetValue(Data)); }
else if(strcmp(key,"AH_Status",true)==0) { Carlist[playerid][s][Status]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_Lock",true)==0) { Carlist[playerid][s][Lock]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_Paintjob",true)==0) { Carlist[playerid][s][Paintjob]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_Farbe1",true)==0) { Carlist[playerid][s][Farbe1]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_Farbe2",true)==0) { Carlist[playerid][s][Farbe2]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod1",true)==0) { Carlist[playerid][s][mod1]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod2",true)==0) { Carlist[playerid][s][mod2]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod3",true)==0) { Carlist[playerid][s][mod3]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod4",true)==0) { Carlist[playerid][s][mod4]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod5",true)==0) { Carlist[playerid][s][mod5]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod6",true)==0) { Carlist[playerid][s][mod6]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod7",true)==0) { Carlist[playerid][s][mod7]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod8",true)==0) { Carlist[playerid][s][mod8]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod9",true)==0) { Carlist[playerid][s][mod9]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod10",true)==0) { Carlist[playerid][s][mod10]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod11",true)==0) { Carlist[playerid][s][mod11]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod12",true)==0) { Carlist[playerid][s][mod12]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod13",true)==0) { Carlist[playerid][s][mod13]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod14",true)==0) { Carlist[playerid][s][mod14]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod15",true)==0) { Carlist[playerid][s][mod15]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod16",true)==0) { Carlist[playerid][s][mod16]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod17",true)==0) { Carlist[playerid][s][mod17]=strval(ini_GetValue(Data)); }
}
}
fclose(CarFile);
if(Carlist[playerid][s][Typ]!=-1 && Carlist[playerid][s][Status]==1)
{
Carlist[playerid][s][Carid]=CreateTunedCar(playerid);
}
}
}
SetTimerEx("DelaySetVehicleParams",10000,0,"i",playerid);
return 1;
}
Das sieht soweit gut aus.
Debugge den Befehl mal so, und poste dann was im Server Log steht, wenn du den Befehl eingibst:
if(strcmp(cmd, "/parken", true) == 0)
{
new s = CarKey[playerid];
printf("s: %d", s);
printf("carid: %d | inVeh: %d", Carlist[playerid][s][Carid], GetPlayerVehicleID(playerid));
if (IsPlayerInVehicle(playerid,Carlist[playerid][s][Carid]))
{
GetVehiclePos(Carlist[playerid][s][Carid],Carlist[playerid][s][X],Carlist[playerid][s][Y],Carlist[playerid][s][Z]);
GetVehicleZAngle(Carlist[playerid][s][Carid],Carlist[playerid][s][Rotation]);
SendClientMessage(playerid, COLOR_WHITE, "{FFFFFF}» Dein Fahrzeug wurde nun an dieser Position {006600}erfolgreich{FFFFFF} geparkt.");
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "Du sitzt nicht in deinem eigenen Fahrzeug!");
}
return 1;
}
So, ich habe vergessen, den Schlüssel zu wechseln.
Ich habe jetzt, jedoch das Problem wenn /parken mache dann werden auch die Fahrzeuge geparkt, jedoch, wenn ich wieder ingame gehe steht das Fahrzeug im Slot2 auf der Position von Slot1. Das Fahrzeug ist zudem das selbe wie in Slot1.
Log:
[16:29:41] s: 0
[16:29:41] carid: 933 | inVeh: 933
[16:30:27] s: 1
[16:30:27] carid: 934 | inVeh: 934
Poste bitte den Code vom Speichern der Fahrzeuge, wie er jetzt bei dir aussieht.
public OnPlayerDisconnect(playerid)
{
new dateiname[MAX_PLAYER_NAME+25];
new playername[MAX_PLAYER_NAME+25];
new var[256];
GetPlayerName(playerid, playername, sizeof(playername));
for(new s=0; s<MAX_CARS_PER_PLAYER; s++)
{
format(dateiname, sizeof(dateiname), "/GekaufteFahrzeuge/%s%d.car", playername,s);
new File: CarFile = fopen(dateiname, io_write);
format(var, 256, "AH_Typ=%i\n", Carlist[playerid][s][Typ]); fwrite(CarFile, var);
format(var, 256, "AH_X=%f\n", Carlist[playerid][s][X]); fwrite(CarFile, var);
format(var, 256, "AH_Y=%f\n", Carlist[playerid][s][Y]); fwrite(CarFile, var);
format(var, 256, "AH_Z=%f\n", Carlist[playerid][s][Z]); fwrite(CarFile, var);
format(var, 256, "AH_Rot=%f\n", Carlist[playerid][s][Rotation]); fwrite(CarFile, var);
format(var, 256, "AH_Status=%i\n", Carlist[playerid][s][Status]); fwrite(CarFile, var);
format(var, 256, "AH_Lock=%i\n", Carlist[playerid][s][Lock]); fwrite(CarFile, var);
format(var, 256, "AH_Paintjob=%i\n", Carlist[playerid][s][Paintjob]); fwrite(CarFile, var);
format(var, 256, "AH_Farbe1=%i\n", Carlist[playerid][s][Farbe1]); fwrite(CarFile, var);
format(var, 256, "AH_Farbe2=%i\n", Carlist[playerid][s][Farbe2]); fwrite(CarFile, var);
format(var, 256, "AH_mod1=%i\n", Carlist[playerid][s][mod1]); fwrite(CarFile, var);
format(var, 256, "AH_mod2=%i\n", Carlist[playerid][s][mod2]); fwrite(CarFile, var);
format(var, 256, "AH_mod3=%i\n", Carlist[playerid][s][mod3]); fwrite(CarFile, var);
format(var, 256, "AH_mod4=%i\n", Carlist[playerid][s][mod4]); fwrite(CarFile, var);
format(var, 256, "AH_mod5=%i\n", Carlist[playerid][s][mod5]); fwrite(CarFile, var);
format(var, 256, "AH_mod6=%i\n", Carlist[playerid][s][mod6]); fwrite(CarFile, var);
format(var, 256, "AH_mod7=%i\n", Carlist[playerid][s][mod7]); fwrite(CarFile, var);
format(var, 256, "AH_mod8=%i\n", Carlist[playerid][s][mod8]); fwrite(CarFile, var);
format(var, 256, "AH_mod9=%i\n", Carlist[playerid][s][mod9]); fwrite(CarFile, var);
format(var, 256, "AH_mod10=%i\n", Carlist[playerid][s][mod10]); fwrite(CarFile, var);
format(var, 256, "AH_mod11=%i\n", Carlist[playerid][s][mod11]); fwrite(CarFile, var);
format(var, 256, "AH_mod12=%i\n", Carlist[playerid][s][mod12]); fwrite(CarFile, var);
format(var, 256, "AH_mod13=%i\n", Carlist[playerid][s][mod13]); fwrite(CarFile, var);
format(var, 256, "AH_mod14=%i\n", Carlist[playerid][s][mod14]); fwrite(CarFile, var);
format(var, 256, "AH_mod15=%i\n", Carlist[playerid][s][mod15]); fwrite(CarFile, var);
format(var, 256, "AH_mod16=%i\n", Carlist[playerid][s][mod16]); fwrite(CarFile, var);
format(var, 256, "AH_mod17=%i\n", Carlist[playerid][s][mod17]); fwrite(CarFile, var);
fclose(CarFile);
if(Carlist[playerid][s][Carid]!=-1)
{
SetVehicleParamsForAll(Carlist[playerid][s][Carid],0,0);
DestroyVehicle(Carlist[playerid][s][Carid]);
Carlist[playerid][s][Carid]=-1;
}
if (Spectating[playerid][0]!=-1)
{
SetVehicleParamsForAll(Kaufliste[Spectating[playerid][0]][Carid],0,0);
Spectating[playerid][0]=-1;
}
}
return 1;
}
Das sieht soweit gut aus. Wie sieht der Code vom Laden aus? Kann ja dann nur noch daran liegen.
Es wird bei mir über OnPlayerConnect geladen...
public OnPlayerConnect(playerid)
{
new dateiname[MAX_PLAYER_NAME+25];
new playername[MAX_PLAYER_NAME+25];
for(new s=0; s<MAX_CARS_PER_PLAYER; s++)
{
Carlist[playerid][s][Typ]=-1; Carlist[playerid][s][X]=0.0; Carlist[playerid][s][Y]=0.0; Carlist[playerid][s][Z]=0.0;
Carlist[playerid][s][Rotation]=0.0; Carlist[playerid][s][Status]=0; Carlist[playerid][s][Lock]=0; Carlist[playerid][s][Carid]=-1;
Carlist[playerid][s][Farbe1]=-1; Carlist[playerid][s][Farbe2]=-1; Carlist[playerid][s][mod1]=-1; Carlist[playerid][s][mod2]=-1;
Carlist[playerid][s][mod3]=-1; Carlist[playerid][s][mod4]=-1; Carlist[playerid][s][mod5]=-1; Carlist[playerid][s][mod6]=-1;
Carlist[playerid][s][mod7]=-1; Carlist[playerid][s][mod8]=-1; Carlist[playerid][s][mod9]=-1; Carlist[playerid][s][mod10]=-1;
Carlist[playerid][s][mod11]=-1; Carlist[playerid][s][mod12]=-1; Carlist[playerid][s][mod13]=-1; Carlist[playerid][s][mod14]=-1;
Carlist[playerid][s][mod15]=-1; Carlist[playerid][s][mod16]=-1; Carlist[playerid][s][mod17]=-1; Carlist[playerid][s][Paintjob]=-1;
}
Spectating[playerid][0]=-1;
#if defined CARSELL
bietetAn[playerid]={-1,0};
#endif
GetPlayerName(playerid, playername, sizeof(playername));
for(new s=0; s<MAX_CARS_PER_PLAYER; s++)
{
format(dateiname, sizeof(dateiname), "/GekaufteFahrzeuge/%s%d.car", playername,s);
if (fexist(dateiname))
{
new File: CarFile = fopen(dateiname, io_read);
if ( CarFile )
{
new key[ 256 ];
new Data[ 256 ];
while ( fread( CarFile , Data , sizeof( Data ) ) )
{
key = ini_GetKey(Data);
if(strcmp(key,"AH_Typ",true)==0) { Carlist[playerid][s][Typ]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_X",true)==0) { Carlist[playerid][s][X]=floatstr(ini_GetValue(Data)); }
else if(strcmp(key,"AH_Y",true)==0) { Carlist[playerid][s][Y]=floatstr(ini_GetValue(Data)); }
else if(strcmp(key,"AH_Z",true)==0) { Carlist[playerid][s][Z]=floatstr(ini_GetValue(Data)); }
else if(strcmp(key,"AH_Rot",true)==0) { Carlist[playerid][s][Rotation]=floatstr(ini_GetValue(Data)); }
else if(strcmp(key,"AH_Status",true)==0) { Carlist[playerid][s][Status]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_Lock",true)==0) { Carlist[playerid][s][Lock]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_Paintjob",true)==0) { Carlist[playerid][s][Paintjob]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_Farbe1",true)==0) { Carlist[playerid][s][Farbe1]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_Farbe2",true)==0) { Carlist[playerid][s][Farbe2]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod1",true)==0) { Carlist[playerid][s][mod1]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod2",true)==0) { Carlist[playerid][s][mod2]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod3",true)==0) { Carlist[playerid][s][mod3]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod4",true)==0) { Carlist[playerid][s][mod4]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod5",true)==0) { Carlist[playerid][s][mod5]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod6",true)==0) { Carlist[playerid][s][mod6]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod7",true)==0) { Carlist[playerid][s][mod7]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod8",true)==0) { Carlist[playerid][s][mod8]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod9",true)==0) { Carlist[playerid][s][mod9]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod10",true)==0) { Carlist[playerid][s][mod10]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod11",true)==0) { Carlist[playerid][s][mod11]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod12",true)==0) { Carlist[playerid][s][mod12]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod13",true)==0) { Carlist[playerid][s][mod13]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod14",true)==0) { Carlist[playerid][s][mod14]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod15",true)==0) { Carlist[playerid][s][mod15]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod16",true)==0) { Carlist[playerid][s][mod16]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod17",true)==0) { Carlist[playerid][s][mod17]=strval(ini_GetValue(Data)); }
}
}
fclose(CarFile);
if(Carlist[playerid][s][Typ]!=-1 && Carlist[playerid][s][Status]==1)
{
Carlist[playerid][s][Carid]=CreateTunedCar(playerid);
}
}
}
SetTimerEx("DelaySetVehicleParams",10000,0,"i",playerid);
return 1;
}
Poste bitte die CreateTunedCar Funktion.
public CreateTunedCar(playerid)
{
for(new s=0; s<MAX_CARS_PER_PLAYER; s++)
{
if(IsPlayerConnected(playerid) && Carlist[playerid][s][Typ]!=-1)
{
new carid=CreateVehicle(Kaufliste[Carlist[playerid][s][Typ]][Modelid],Carlist[playerid][s][X],Carlist[playerid][s][Y],Carlist[playerid][s][Z],Carlist[playerid][s][Rotation],-1,-1,-1);
if(Carlist[playerid][s][Lock]==1)
{
SetVehicleParamsForAll(carid,0,1);
SetVehicleParamsForPlayer(carid,playerid,0,0);
}
if(Carlist[playerid][s][mod1]!=-1) { AddVehicleComponent(carid,Carlist[playerid][s][mod1]); }
if(Carlist[playerid][s][mod2]!=-1) { AddVehicleComponent(carid,Carlist[playerid][s][mod2]); }
if(Carlist[playerid][s][mod3]!=-1) { AddVehicleComponent(carid,Carlist[playerid][s][mod3]); }
if(Carlist[playerid][s][mod4]!=-1) { AddVehicleComponent(carid,Carlist[playerid][s][mod4]); }
if(Carlist[playerid][s][mod5]!=-1) { AddVehicleComponent(carid,Carlist[playerid][s][mod5]); }
if(Carlist[playerid][s][mod6]!=-1) { AddVehicleComponent(carid,Carlist[playerid][s][mod6]); }
if(Carlist[playerid][s][mod7]!=-1) { AddVehicleComponent(carid,Carlist[playerid][s][mod7]); }
if(Carlist[playerid][s][mod8]!=-1) { AddVehicleComponent(carid,Carlist[playerid][s][mod8]); }
if(Carlist[playerid][s][mod9]!=-1) { AddVehicleComponent(carid,Carlist[playerid][s][mod9]); }
if(Carlist[playerid][s][mod10]!=-1) { AddVehicleComponent(carid,Carlist[playerid][s][mod10]); }
if(Carlist[playerid][s][mod11]!=-1) { AddVehicleComponent(carid,Carlist[playerid][s][mod11]); }
if(Carlist[playerid][s][mod12]!=-1) { AddVehicleComponent(carid,Carlist[playerid][s][mod12]); }
if(Carlist[playerid][s][mod13]!=-1) { AddVehicleComponent(carid,Carlist[playerid][s][mod13]); }
if(Carlist[playerid][s][mod14]!=-1) { AddVehicleComponent(carid,Carlist[playerid][s][mod14]); }
if(Carlist[playerid][s][mod15]!=-1) { AddVehicleComponent(carid,Carlist[playerid][s][mod15]); }
if(Carlist[playerid][s][mod16]!=-1) { AddVehicleComponent(carid,Carlist[playerid][s][mod16]); }
if(Carlist[playerid][s][mod17]!=-1) { AddVehicleComponent(carid,Carlist[playerid][s][mod17]); }
if(Carlist[playerid][s][Paintjob]!=-1) { ChangeVehiclePaintjob(carid,Carlist[playerid][s][Paintjob]); }
if(Carlist[playerid][s][Farbe1]!=-1) { ChangeVehicleColor(carid,Carlist[playerid][s][Farbe1],Carlist[playerid][s][Farbe2]); }
return carid;
}
}
return 1;
}
public CreateTunedCar(playerid, s)
{
if(IsPlayerConnected(playerid) && Carlist[playerid][s][Typ]!=-1)
{
new carid=CreateVehicle(Kaufliste[Carlist[playerid][s][Typ]][Modelid],Carlist[playerid][s][X],Carlist[playerid][s][Y],Carlist[playerid][s][Z],Carlist[playerid][s][Rotation],-1,-1,-1);
if(Carlist[playerid][s][Lock]==1)
{
SetVehicleParamsForAll(carid,0,1);
SetVehicleParamsForPlayer(carid,playerid,0,0);
}
if(Carlist[playerid][s][mod1]!=-1) { AddVehicleComponent(carid,Carlist[playerid][s][mod1]); }
if(Carlist[playerid][s][mod2]!=-1) { AddVehicleComponent(carid,Carlist[playerid][s][mod2]); }
if(Carlist[playerid][s][mod3]!=-1) { AddVehicleComponent(carid,Carlist[playerid][s][mod3]); }
if(Carlist[playerid][s][mod4]!=-1) { AddVehicleComponent(carid,Carlist[playerid][s][mod4]); }
if(Carlist[playerid][s][mod5]!=-1) { AddVehicleComponent(carid,Carlist[playerid][s][mod5]); }
if(Carlist[playerid][s][mod6]!=-1) { AddVehicleComponent(carid,Carlist[playerid][s][mod6]); }
if(Carlist[playerid][s][mod7]!=-1) { AddVehicleComponent(carid,Carlist[playerid][s][mod7]); }
if(Carlist[playerid][s][mod8]!=-1) { AddVehicleComponent(carid,Carlist[playerid][s][mod8]); }
if(Carlist[playerid][s][mod9]!=-1) { AddVehicleComponent(carid,Carlist[playerid][s][mod9]); }
if(Carlist[playerid][s][mod10]!=-1) { AddVehicleComponent(carid,Carlist[playerid][s][mod10]); }
if(Carlist[playerid][s][mod11]!=-1) { AddVehicleComponent(carid,Carlist[playerid][s][mod11]); }
if(Carlist[playerid][s][mod12]!=-1) { AddVehicleComponent(carid,Carlist[playerid][s][mod12]); }
if(Carlist[playerid][s][mod13]!=-1) { AddVehicleComponent(carid,Carlist[playerid][s][mod13]); }
if(Carlist[playerid][s][mod14]!=-1) { AddVehicleComponent(carid,Carlist[playerid][s][mod14]); }
if(Carlist[playerid][s][mod15]!=-1) { AddVehicleComponent(carid,Carlist[playerid][s][mod15]); }
if(Carlist[playerid][s][mod16]!=-1) { AddVehicleComponent(carid,Carlist[playerid][s][mod16]); }
if(Carlist[playerid][s][mod17]!=-1) { AddVehicleComponent(carid,Carlist[playerid][s][mod17]); }
if(Carlist[playerid][s][Paintjob]!=-1) { ChangeVehiclePaintjob(carid,Carlist[playerid][s][Paintjob]); }
if(Carlist[playerid][s][Farbe1]!=-1) { ChangeVehicleColor(carid,Carlist[playerid][s][Farbe1],Carlist[playerid][s][Farbe2]); }
return carid;
}
return 1;
}
und
Carlist[playerid][s][Carid]=CreateTunedCar(playerid);
zu:
Carlist[playerid][s][Carid]=CreateTunedCar(playerid,s);