GameText and 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: GameText and Timer.. (
/showthread.php?tid=300132)
GameText and Timer.. -
Joshb93 - 28.11.2011
Ok, i have a question, can someone help me on making a timer, with GameTextForPlayer, therefore, updating the GameTextForPlayer with the timer. Like, the timer counts down on their screen in GameText..
Please, and +rep for anyone who helps
Re: GameText and Timer.. -
nmader - 28.11.2011
Well, as I am honestly too lazy to type it all out, I know of a ******* video that explains it (If I am knowing what you are talking about correctly)
Here: [ame]http://www.youtube.com/watch?v=E6o7u0yAjdE[/ame]
Re: GameText and Timer.. -
grand.Theft.Otto - 28.11.2011
Untested.
pawn Код:
// top of script
new SecondsLeft;
// ongamemodeinit
SecondsLeft = SetTimer("SecondsLeftTimer",1000,true); // every 1 second
// in your command for example :
if(strcmp(cmdtext, "/countdown", true, 10))
{
SetPVarInt(playerid,"CountDown",10); // 10 sec
return 1;
}
// bottom of script
public SecondsLeftTimer()
{
new Amount;
for(new i = 0; i < MAX_PLAYERS; i++)
{
Amount = GetPVarInt(i,"CountDown");
if(Amount > 0)
{
Amount--;
SetPVarInt(i,"CountDown",Amount);
new string[128];
format(string,sizeof(string),"~n~~n~~n~~n~~n~~p~time left: ~w~%d Seconds",Amount);
GameTextForPlayer(i,string,1000,3);
if(Amount == 0)
{
// if countdown is at 0 seconds, award them / give a prize / punish / etcetera ...
}
}
}
}