DestroyVehicle - 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: DestroyVehicle (
/showthread.php?tid=649402)
DestroyVehicle -
PepsiCola23 - 08.02.2018
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(playerid, COLOR_WHITE, "{FFFFFF}Job: {FFFFFF}You canceled the job because you got out of your car.");
}
Re: DestroyVehicle -
JaKe Elite - 08.02.2018
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
}
Re: DestroyVehicle -
ISmokezU - 08.02.2018
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]);
Re: DestroyVehicle -
PepsiCola23 - 08.02.2018
SOLVED: Used
PHP код:
OnPlayerExitVehicle