SA-MP Forums Archive
Timer - 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: Timer (/showthread.php?tid=212061)



Timer - nuriel8833 - 16.01.2011

*I am not so good with timers,so don't laugh at me O.o

I wanted to ask - how can I create a timer that after it will be finished something will happen?


Re: Timer - Anthonyx3' - 16.01.2011

pawn Код:
SetTimer("test",5000,false);
pawn Код:
public test()
{
    SendClientMessageToAll(COLOR_COLOR, "5 seconds passed");
}
Theres an example, if you dont understand ill explain


Re: Timer - Toreno - 16.01.2011

You can also do this;

Example;
pawn Код:
new TimerVar;

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp("/timer", cmdtext, true, 6) == 0)
    {
        SetPVarInt(playerid, "Timing", gettime());
        TimerVar = SetTimerEx("Timer", 1000, true, "i", playerid);
        return 1;
    }
    return 0;
}

forward Timer(playerid);
public Timer(playerid)
{
    if(gettime()-GetPVarInt(playerid, "Timing") < 5) // The time... in seconds. (five seconds)
    {
        /* Do here whatever you want after five seconds */
        KillTimer(TimerVar); // kills the timer when it's done
    }
}



Re: Timer - nuriel8833 - 16.01.2011

Quote:
Originally Posted by Anthonyx3'
Посмотреть сообщение
pawn Код:
SetTimer("test",5000,false);
pawn Код:
public test()
{
    SendClientMessageToAll(COLOR_COLOR, "5 seconds passed");
}
Theres an example, if you dont understand ill explain
Thats it?
Its easy.. thanks dude!