Vehicle help
#1

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.
Reply
#2

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".
Reply
#3

PHP код:
for(new ii<VEHICLE_LIMITi++)
{
if(
IsValidVehicle(pvehicle[playerid][i]))
{
// save vehicle
}

Reply
#4

mm can u tell me how this will be in my /resetcar command
PHP код:
CMD:resetcar(playeridparams[])
{
    new 
tmp[256], tmp1[256], name[MAX_PLAYER_NAME], string[256], string2[256], tvartvar1dia[256];
    if(
pvehicle[playerid][0]==&& pvehicle[playerid][1]==0) return SendClientMessage(playeridCOLOR_RED"ERROR:You Dont Own Any Vehicle");
    
GetPlayerName(playeridnamesizeof(name));
    if(
pvehicle[playerid][0]!=0)
    {
           
format(string50"V_%s"name);
        
tvar dini_Int(AddDirFile(dir_carfilesstring), "model");
        
format(tmpsizeof(tmp), "Reset Your: %s"tvar-400);
    }
     if(
pvehicle[playerid][1]!=0)
    {
           
format(string50"V1_%s"name);
         
tvar1 dini_Int(AddDirFile(dir_carfilesstring), "model");
        
format(tmp1sizeof(tmp1), "Reset Your: %s"tvar1-400);
    }
    
format(diasizeof(dia), "%s\n%s"tmptmp1);
    
ShowPlayerDialog2(playeridDIALOG_RES_CARDIALOG_STYLE_TABLIST_HEADERS"Select An Car To Reset"dia"Select""Cancel");
    return 
1;

this should show me the player cars
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)