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)
+--- Thread: Timer (
/showthread.php?tid=563358)
Timer -
Jigsaw123 - 15.02.2015
How do I set a timer so that 10 seconds after the player connects to the server the chat gets cleared? :P
Thanks!
Re: Timer -
CalvinC - 15.02.2015
You can use a loop to clear the chat, here's an example that sends a blank message 100 times:
pawn Код:
for(new i = 0; i < 100; i++) SendClientMessage(playerid, -1, " ");
To create a timer for a certain player, use SetTimerEx.
Example, in OnPlayerConnect to initiate the timer:
pawn Код:
SetTimerEx("publicname", 10000, false, "i", playerid);
pawn Код:
forward publicname(playerid); // Forwards the public function
public publicname(playerid) return for(new i = 0; i < 100; i++) SendClientMessage(playerid, -1, " "); // Sends 100 messages when the timer ends
For more information, visit the wiki:
https://sampwiki.blast.hk/wiki/SetTimerEx
Re: Timer -
HY - 15.02.2015
Set a timer to 10 seconds.
pawn Код:
public OnPlayerConnect(playerid)
{
SetTimerEx("ClearChat", 10000, false, "i", playerid);
return 1;
}
10000 ms = 10 seconds.
false = timer doesn't repeat.
Create public.
pawn Код:
forward ClearChat(playerid);
public ClearChat(playerid)
{
for(new i = 0; i < 16; i++) SendClientMessage(playerid, -1, " ");
return 1;
}
Re: Timer -
Jigsaw123 - 15.02.2015
Thanks Guys!