Condition car help
#1

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)