SetTimer - 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: SetTimer (
/showthread.php?tid=284467)
SetTimer -
zxc1 - 19.09.2011
Hi Everyone,
I know that people asked this question before, but I still can't make it work.
I want that for example when player uses the commmand /twominutes it's will show him with GameTextForPlayer:
119 seconds left, 118 seconds left, 117 seconds left..........
Can someone help me please?
Re: SetTimer -
Basicz - 19.09.2011
pawn Код:
new playerCounts[ MAX_PLAYERS ] = { 0, ... }, timer[ MAX_PLAYERS ];
public OnPlayerDisconnect( playerid, reason )
return KillTimer( timer[ playerid ] );
COMMAND:twominutes( playerid, params[ ] )
{
if ( playerCounts[ playerid ] > 0 ) return 0;
timer[ playerid ] = SetTimerEx( "TWO", 1000, true, "i", playerid );
return 1;
}
forward TWO( playerid );
public TWO( playerid )
{
playerCounts[ playerid ] ++;
if ( playerCounts[ playerid ] >= 200 )
{
playerCounts[ playerid ] = 0;
GameTextForPlayer( playerid, "~W~COUNT END", 1000, 3 );
KillTimer( timer[ playerid ] );
}
new txt[ 18 ];
format( txt, 30, "%d seconds left", 200 - playerCounts[ playerid ] );
// 200
GameTextForPlayer( playerid, txt, 1000, 3 );
return 1;
}
hope it works..
edit: fixed missing arguments
Re: SetTimer -
zxc1 - 19.09.2011
WOW Thank you so much Basicz.