SA-MP Forums Archive
SetTimer *inside* a function? - 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: SetTimer *inside* a function? (/showthread.php?tid=130380)



SetTimer *inside* a function? - bajskorv123 - 26.02.2010

Hello, Is there any function that works like SetTimer but you can use it inside a function?
If you don't get what i mean, heres an example:
pawn Код:
if(strcmp("/loltele", cmdtext, true)==0)
{
  SetPlayerPos(playerid, 250, 250, 250);
  CountDown(5000)//The function, set at 5000 milliseconds
  {
    SetPlayerPos(playerid, 500, 500, 500);//This happens 5000 milliseconds after the CountDown callback got called
  }
  return 1;
}
First when you type /loltele you get teleported to the 250, 250, 250 coords.
Then 5 seconds after you got teleported to the 250, 250, 250 coords, teleport you to the 500, 500, 500 coords.


Re: SetTimer *inside* a function? - BlackFoX - 26.02.2010

Sleep does it but i think this Pawn Script dont Cotains this Function and it Freeze the Script.
SetTimerEx is the best way atm


Re: SetTimer *inside* a function? - bajskorv123 - 26.02.2010

Please explain SetTimerEx to me, wiki doesnt say much...


Re: SetTimer *inside* a function? - BlackFoX - 26.02.2010

Код:
public teleport(playerid,Float:x,Float:y,Float:z)return SetPlayerPos(playerid,x,y,z);
Код:
SetTimerEx("teleport",5000,0,"ifff",playerid,your_x,your_y,your_z);



Re: SetTimer *inside* a function? - [HiC]TheKiller - 26.02.2010

pawn Код:
if(strcmp("/loltele", cmdtext, true)==0)
{
  SetPlayerPos(playerid, 250, 250, 250);
  SetTimerEx("Timer", 5000, false, "d"/* D is the format (Number)*/, playerid); //Will save the playerid varaible in the timer.
  return 1;
}

forward Timer(playerid);
public Timer(playerid)
{
  SetPlayerPos(playerid, 500, 500, 500);
  return 1;
}