GameText and Timer..
#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


Messages In This Thread
GameText and Timer.. - by Joshb93 - 28.11.2011, 21:55
Re: GameText and Timer.. - by nmader - 28.11.2011, 22:18
Re: GameText and Timer.. - by grand.Theft.Otto - 28.11.2011, 22:56

Forum Jump:


Users browsing this thread: 2 Guest(s)