DestroyVeh after an amount of time after the vehicle has been spawned - 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: DestroyVeh after an amount of time after the vehicle has been spawned (
/showthread.php?tid=642433)
DestroyVeh after an amount of time after the vehicle has been spawned -
muka - 30.09.2017
Ok, so I have this :
- ok, so this is when the player will request the vehicle.
Код:
case 0:
{
GetPlayerFacingAngle(playerid, angle);
GetPlayerPos(playerid, x, y, z);
ticau_veh1 = CreateVehicle(481, x, y, z, angle, 144, 145, 125, 0);
PutPlayerInVehicle(playerid,ticau_veh1,0);
vehicleid = GetPlayerVehicleID(playerid);
i[playerid] = 1;
reset1(playerid);
delay(playerid, vehicleid);
return 1;
}
- these are the fuctions for destroying the vehicle after 5 seconds if the player is not inside
Код:
public delay(playerid, vehicleid)
{
SetTimerEx("destroy_veh", 5000, 1, "d");
}
public destroy_veh(playerid, vehicleid)
{
if(IsPlayerInVehicle(playerid, vehicleid)==1)
{
delay(playerid, vehicleid);
}
else
{
DestroyVehicle(vehicleid);
}
}
But it's not working. What did I do wrong ?
Re: DestroyVeh after an amount of time after the vehicle has been spawned -
J0sh... - 30.09.2017
You aren't specifying the playerid or vehicleid in SetTimerEx.
PHP код:
SetTimerEx("destroy_veh", 5000, 1, "dd", playerid, vehicleid);
Also you should remove the delay() inside destroy_veh because a new timer will check it.
Re: DestroyVeh after an amount of time after the vehicle has been spawned -
TakeiT - 30.09.2017
Why not just set the respawn time in CreateVehicle and not worry about any extra code?
Re: DestroyVeh after an amount of time after the vehicle has been spawned -
jlalt - 30.09.2017
^ because that's respawn time not destroy time.
Note: your timers auto reset / repeat value set to true but you never kill them, either disable the repeat or store their Id and kill them when finished.
Re: DestroyVeh after an amount of time after the vehicle has been spawned -
muka - 01.10.2017
Thanks, it's working !