SA-MP Forums Archive
How do I set a delay? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How do I set a delay? (/showthread.php?tid=90620)



How do I set a delay? - ThePS3Guy - 09.08.2009

I know how to set a timer, for example I have a 15 second timer for my nos to reset all the time, what I want to know is how to set a delay. A timer wouldn't work, because lets say I set a 1 second timer, the effect can take place anywhere from 0 to 1 seconds.

If you need me to be more specific, I want my Cars FS to set vehicles back to the spawn point , but only after say, 5 seconds after a player exits the vehicle. Here's what I have so far.

#include <a_samp>

public OnPlayerExitVehicle(playerid, vehicleid)
{
SetVehicleToRespawn(vehicleid);
return 1;
}


Re: How do I set a delay? - ruarai - 09.08.2009

Quote:

#include <a_samp>
forward cardestroy(vehicleid);

public OnPlayerExitVehicle(playerid, vehicleid)
{
SetTimerEx("cardestroy",5000,0,"i",vehicleid);
return 1;
}

public cardestroy(vehicleid)
{
SetVehicleToRespawn(vehicleid);
}

Untested


Re: How do I set a delay? - ThePS3Guy - 09.08.2009

ok thanks, my point is to learn rather than just get a code

so im guessing that SetTimerEx rather than SetTimer runs a timer just once and that's it?


Re: How do I set a delay? - ruarai - 09.08.2009

SetTimerEx can send variables over the timer as SetTimer cant.
Have a look at this: Wiki


Re: How do I set a delay? - James124 - 18.08.2010

so which is the code ?