Vehicle help - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Vehicle help (
/showthread.php?tid=632396)
Vehicle help -
silverms - 13.04.2017
so I'm working on car ownership system and I have made it so player can own one car and when he disconnect it saves his car like the following:
PHP код:
if (pvehicle[playerid][0] != 0)
{
pvehicle[playerid][0] = 0;
}
but this saves one car but what if he have more than one car how can I make it save anycar he own not one car like pvehicle[playerid][I]
i just need to know how to make it be pvehicle[playerid][i] which [i] is infinit and i can finish my self
PHP код:
new pvehicle[PLAYERS][3];
players is max_players.
Re: Vehicle help -
renatog - 13.04.2017
Use a loop.
Код:
//~ You are inside your player data save function ~
for(new i; i<3; i++)
{
if(pvehicle[playerid][i] != 0)
{
//Do things
}
}
I recommend you to define the maximum player vehicles, e.g.:
Код:
#define MAX_PLAYER_VEHICLES 3
And change "i<3" to "i<MAX_PLAYER_VEHICLES".
Re: Vehicle help -
XpDeviL - 13.04.2017
PHP код:
for(new i; i<VEHICLE_LIMIT; i++)
{
if(IsValidVehicle(pvehicle[playerid][i]))
{
// save vehicle
}
}
Re: Vehicle help -
silverms - 13.04.2017
mm can u tell me how this will be in my /resetcar command
PHP код:
CMD:resetcar(playerid, params[])
{
new tmp[256], tmp1[256], name[MAX_PLAYER_NAME], string[256], string2[256], tvar, tvar1, dia[256];
if(pvehicle[playerid][0]==0 && pvehicle[playerid][1]==0) return SendClientMessage(playerid, COLOR_RED, "ERROR:You Dont Own Any Vehicle");
GetPlayerName(playerid, name, sizeof(name));
if(pvehicle[playerid][0]!=0)
{
format(string, 50, "V_%s", name);
tvar = dini_Int(AddDirFile(dir_carfiles, string), "model");
format(tmp, sizeof(tmp), "Reset Your: %s", tvar-400);
}
if(pvehicle[playerid][1]!=0)
{
format(string, 50, "V1_%s", name);
tvar1 = dini_Int(AddDirFile(dir_carfiles, string), "model");
format(tmp1, sizeof(tmp1), "Reset Your: %s", tvar1-400);
}
format(dia, sizeof(dia), "%s\n%s", tmp, tmp1);
ShowPlayerDialog2(playerid, DIALOG_RES_CAR, DIALOG_STYLE_TABLIST_HEADERS, "Select An Car To Reset", dia, "Select", "Cancel");
return 1;
}
this should show me the player cars