[HELP]Countdown
#9

Very simple

pawn Код:
// top
new Count, Timer[MAX_PLAYERS];

// goes under OnPlayerCommandText. It's a command for the count down
if (strcmp("/countdown", cmdtext, true) == 0)
{
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    Timer[playerid] = SetTimerEx("CountDown", 1000, true, "d", playerid); // Declaring a timer to call the public CountDown every 1 second
    for(new i; i < MAX_PLAYERS; i ++) // looping through all players
    {
        if(IsPlayerConnected(i)) // if connected
        {
            if(IsPlayerInRangeOfPoint(i, 20, X, Y, Z)) // if they are in your range
            {
                new str[4];
                Count = 5; // setting the countdown to 5 .. you can change that
                format(str, sizeof(str), "%d", Count); // formatting a string to use it in GameTextForPlayer
                GameTextForPlayer(i, str, 3000, 3); // showing the gametext for that player in your range
            }
        }
    }
    return 1;
}

forward CountDown(playerid);

public CountDown(playerid)
{
    Count --; // decreasing Count by one
    if(Count == 0) // if Count reaches 0
    {
        KillTimer(Timer[playerid]); // kill the cd timer
        // your codes when the cd ends go here
        GameTextForPlayer(i, "GO GO GO!!, 3000, 3);
        return 1; // to stop it
    }
    // so it's not = 0
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos(playerid, X, Y, Z); // getting the player position again (he probably has moved!)
    new str[4];
    format(str, sizeof(str), "
%d", Count); // formatting a string with the new decreased Count
    for(new i; i < MAX_PLAYERS; i ++)
    {
        if(IsPlayerConnected(i))
        {
            if(IsPlayerInRangeOfPoint(i, 20, X, Y, Z)) // if he is in your range
            {
                GameTextForPlayer(i, str, 3000, 3); // showing the gametext for that player in your range
            }
        }
    }
    return 1;
}
I simply copied his code and added it in as another GameText.
Reply


Messages In This Thread
[HELP]Countdown - by Devilxz97 - 24.06.2012, 04:08
Re: [HELP]Countdown - by [KHK]Khalid - 24.06.2012, 04:21
Re: [HELP]Countdown - by Devilxz97 - 24.06.2012, 04:23
Re: [HELP]Countdown - by [KHK]Khalid - 24.06.2012, 04:58
Re: [HELP]Countdown - by Devilxz97 - 24.06.2012, 05:12
Re: [HELP]Countdown - by Devilxz97 - 24.06.2012, 05:16
Re: [HELP]Countdown - by [KHK]Khalid - 24.06.2012, 05:25
Re: [HELP]Countdown - by Devilxz97 - 24.06.2012, 05:33
Re: [HELP]Countdown - by Kindred - 24.06.2012, 05:43
Re: [HELP]Countdown - by [KHK]Khalid - 24.06.2012, 05:45
Re: [HELP]Countdown - by Devilxz97 - 24.06.2012, 05:46
Re: [HELP]Countdown - by Kindred - 24.06.2012, 05:51
Re: [HELP]Countdown - by Devilxz97 - 24.06.2012, 05:57

Forum Jump:


Users browsing this thread: 2 Guest(s)