how to destroy last vehicle?
#1

hey how can i destroy las vehicle i had when i get a new vehicle from a checkpoint?

PHP код:
new LastPlayerInVec[MAX_VEHICLES] = (-1); 
PHP код:
public OnPlayerExitVehicle(playeridvehicleid)
{
     if(
GetPlayerState(playerid) == 2// Is he/she the driver?
       
LastPlayerInVec[vehicleid] = playerid;
    return 
1;

funtion
PHP код:
stock GetLastPlayerInVehicle(vehicleid)
{
    if(
LastPlayerInVec[vehicleid] != -1//Did someone entered it?
        
return LastPlayerInVec[vehicleid];
    return 
0;

checkpoint

PHP код:
if(dialogid == DIALOG_FCARS && response)
    {
        if(
listitem == 0)
        {
            new 
Float:xFloat:yFloat:zFloat:a;
            
GetPlayerPos(playeridx,y,z);
            
GetPlayerFacingAngle(playerida);
            new 
vehicleid CreateVehicle(457x+4,y,za, -1, -1, -1);
            
PutPlayerInVehicle(playeridvehicleid0);//Carid
        
}
        if(
listitem == 1)
         {
             new 
Float:xFloat:yFloat:zFloat:a;
            
GetPlayerPos(playeridx,y,z);
            
GetPlayerFacingAngle(playerida);
               new 
vehicleid CreateVehicle(545x+4,y,za, -1, -1, -1);
            
PutPlayerInVehicle(playeridvehicleid0);//carid
        
}
        if(
listitem == 2)
         {
             new 
Float:xFloat:yFloat:zFloat:a;
            
GetPlayerPos(playeridx,y,z);
            
GetPlayerFacingAngle(playerida);
               new 
vehicleid CreateVehicle(468x+4,y,za, -1, -1, -1);
            
PutPlayerInVehicle(playeridvehicleid0);//carid
        
}
        if(
listitem == 3)
        {
               
ShowPlayerDialog(playeridDIALOG_FCARSDIALOG_STYLE_LIST"Select Free Vehicle"string"Ok""");
        }
    } 
enter checkpoint

PHP код:
public OnPlayerEnterDynamicCP(playeridcheckpointid)
{
    if(
checkpointid == Checkpoint[0]) //This checks what checkpoint it is before it continues
    
{
            if(
gTeam[playerid] == Team_Civi)
            {
                  new 
string[200];
                
format(string200"Caddy\nHustler\nSanchez");
                
ShowPlayerDialog(playeridDIALOG_FCARSDIALOG_STYLE_LIST"Free Vehicles"string"Ok""");
            }
            if(
gTeam[playerid] == Team_Cop || gTeam[playerid] == Team_FBI || gTeam[playerid] == Team_Guard)
            {
                  if(
GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
                {
                    return 
SendClientMessage(playeridCOLOR_ERROR,"You must be on foot!");
                }
                new 
string[200];
                
format(string200"Police Car (LSPD)\nHPV1000\nFBI Rancher\nEnforcer\nSecuricar");
                
ShowPlayerDialog(playeridDIALOG_FCARSLDIALOG_STYLE_LIST"Free Vehicles"string"Ok""");
        }
            return 
1;
    }
    if(
checkpointid == Checkpoint[3])
    {
        if(
IsCop(playerid)) return SendClientMessage(playeridCOLOR_RED,"You are not A Criminal!");
        
ShowModelSelectionMenu(playeridskinlist"Select Skin");
    }
    if(
checkpointid == Checkpoint[4])
    {
        
ShowPlayerDialog(playeridWEAPONSDIALOG_STYLE_LIST"Weapon Shop""Health - $1000\nArmour - $2000\n9mm - $2500\nSilence Pistol - $3000\nDesert Eagle - $3500\nShotgun - $5000\nSawn-Off Shotgun - $8000\nCombat Shotgun - $6500\nMicro SMG - $5000\nMP5 - $5500\nTec-9 - $5000\nAK-47 - $10500\nM4 - $10000\nCountry Rifle - $12000\nSniper Rifle - $12000""Purchase""Cancel");
    }
    if(
checkpointid == Checkpoint[5])
    {
        
ShowPlayerDialog(playeridDIALOG_HOSPITALDIALOG_STYLE_LIST"Welcome to Los Santos Medical Center!""Heal\nCure\nBe a Medic""Okay""Cancel");
    }
    return 
1;
    } 
Reply
#2

1) set a variable for the last vehicle ID.
2) set the checkpoint in map-icon and set a variable for that checkpoint.
3) under OnPlayerEnterCheckpoint or whatever add a new variable that sets to one that he reached that point.
4) under OnPlayerEnterVehicle add a condition to check the variable that we set under OnPlayerEnterCheckpoint and if it's not zero the set it to zero and destroy the vehicle.
5) add a message so the player would know (optional)

I hope I helped any feedback would be appreciated!
Reply
#3

Quote:
Originally Posted by Stanford
Посмотреть сообщение
1) set a variable for the last vehicle ID.
2) set the checkpoint in map-icon and set a variable for that checkpoint.
3) under OnPlayerEnterCheckpoint or whatever add a new variable that sets to one that he reached that point.
4) under OnPlayerEnterVehicle add a condition to check the variable that we set under OnPlayerEnterCheckpoint and if it's not zero the set it to zero and destroy the vehicle.
5) add a message so the player would know (optional)

I hope I helped any feedback would be appreciated!
i dint understand
Reply
#4

Just follow these steps and you will get this ready, I have drew a conclusion that you don't know the concept of variables well, a variable is meant to be something like this:
pawn Код:
new IAmAVariable[MAX_PLAYERS];
If I was on computer I would explain this well, but I hope that you got the point, I hate typing on phones...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)