GameText and Timer..
#1

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
Reply
#2

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]
Reply
#3

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 ...
            }
        }
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)