DestroyVehicle
#1

So i`m making a job system when you type /work it spawn a car,and if you exit the car it destroys.

the car is spawning ,but it isnt destroying.

here`s what i got at onplayerkeystatechange when he leaves the car.

PHP код:
        if(PTruckerCP[playerid] >= 0)
        {
            
DisablePlayerCheckpoint(playerid);
            
RemoveDestination(playerid);
            
DestroyVehicle(VJob[playerid]);
            
PTruckerCP[playerid] = -1;
            
VJob[playerid] = -1;
            
SendClientMessage(playeridCOLOR_WHITE"{FFFFFF}Job: {FFFFFF}You canceled the job because you got out of your car.");
        } 
Reply
#2

Move your code from OnPlayerKeyStateChange to OnPlayerStateChange, Check if the player's state changes from PLAYER_STATE_DRIVER to PLAYER_STATE_ONFOOT

PHP код:
if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT)
{
// Your code here

Reply
#3

The array in which you stored the vehicle id in should be the same you destroy.

PHP код:
new VJob[MAX_VEHICLES];
CMD:work(....)
{
    
VJob[vehicleid] = CreateVehicle(....);
    return 
true;
}
   
// OnPlayerStateChange
DestroyVehicle(VJob[vehicleid]); 
Reply
#4

SOLVED: Used
PHP код:
OnPlayerExitVehicle 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)