SA-MP Forums Archive
Condition car 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: Condition car help (/showthread.php?tid=451164)



Condition car help - Johnnny - 16.07.2013

Hello
I need to make a condition.If player have a car on slot 1(pcarkey),if player buy a car, this car go on slot2(pcarkey2),if player buy another car go on slot3(pcarkey3).
Код:
if(PlayerData[playerid][pPcarkey] == 999) 
if(PlayerData[targetid][pPcarkey2] == 999)
if(PlayerData[targetid][pPcarkey3] == 999)
Sorry for my bad english.


Re: Condition car help - iggy1 - 16.07.2013

Well you can initialize those vars to "INVALID_VEHICLE_ID", then check their value.

pawn Код:
//OnPlayerConnect
PlayerData[playerid][pPcarkey]  = INVALID_VEHICLE_ID;
PlayerData[playerid][pPcarkey2] = INVALID_VEHICLE_ID;
PlayerData[playerid][pPcarkey3] = INVALID_VEHICLE_ID;

//when your giving the player a vehicle
if( PlayerData[playerid][pPcarkey] == INVALID_VEHICLE_ID )
{
    //player doesn't have a vehice in this slot
    PlayerData[playerid][pPcarkey] = 420;//give a vehicle
   
}
else if( PlayerData[playerid][pPcarkey2] == INVALID_VEHICLE_ID )
{
    //player doesn't have a vehice in this slot
    PlayerData[playerid][pPcarkey2] = 425;
}
else if( PlayerData[playerid][pPcarkey3] == INVALID_VEHICLE_ID )
{
    //player doesn't have a vehice in this slot
    PlayerData[playerid][pPcarkey3] = 200;
}
else
{
    //player has a vehicle in all slots
}
There are other ways to do it, but this is the simplest i can think of. Not sure why you used "targetid" as well as "playerid".