Countdown doesn't work correctly!
#3

I would do :

pawn Код:
new Count[ MAX_PLAYERS ] = 5, countTimer[ MAX_PLAYERS ], bool: hasc[ MAX_PLAYERS ];

// onplayerconnect
hasc[ playerid ] = false;

forward Countdown( playerid );
public Countdown( playerid )
{
    new
        Float: Pos[ 3 ]
    ;

    GetPlayerPos( playerid, Pos[ 0 ], Pos[ 1 ], Pos[ 2 ] );

    for ( new p = GetMaxPlayers( ), i; i < p; i ++ )
    {
        if ( !IsPlayerConnected( i ) )
            continue;

        if ( !IsPlayerInRangeOfPoint( i, 2.0, Pos[ 0 ], Pos[ 1 ], Pos[ 2 ] ) )
            continue;

        if ( Count[ playerid ] > 0 )
            Count[ playerid ] --;

        if ( Count[ playerid ] == 0 )
            KillTimer( countTimer[ playerid ] ), GameTextForPlayer( i, "~r~GO GO GO!", 2500, 3 ), hasc[ playerid ] = false;

        new gametextFormat[ 5 ];

        format( gametextFormat, 5, "~r~%d", Count );

        GameTextForPlayer( i, gametextFormat, 2500, 3 );
    }

    return 1;
}

// Command

COMMAND:count( playerid, params[ ] )
{
    foreach (Player, i)
        if ( hasc[ i ] )
            // error: somebodys already starting countdown

    if ( hasc[ playerid ] )
        // error : you are already starting a countdown

    // Messages thingy

    Count[ playerid ] = 5;

    countTimer[ playerid ] = SetTimerEx( "Countdown", 1000, true, "i", playerid );

    hasc[ playerid ] = true;
 
    return 1;
}
EDIT: Added an area check
EDIT2: Added an antispam for a player, so he will not repeat the command everytime.
EDIT3: IMPORTANT! Edited my post, so it will not mess another people's countdown.
EDIT4: Fixed.
Reply


Messages In This Thread
Countdown doesn't work correctly! - by [WSF]ThA_Devil - 04.09.2011, 09:46
AW: Countdown doesn't work correctly! - by Nero_3D - 04.09.2011, 09:55
Re: Countdown doesn't work correctly! - by Basicz - 04.09.2011, 09:59
Re: Countdown doesn't work correctly! - by [WSF]ThA_Devil - 04.09.2011, 10:01
Re: Countdown doesn't work correctly! - by Basicz - 04.09.2011, 10:05
Re: Countdown doesn't work correctly! - by [WSF]ThA_Devil - 04.09.2011, 10:07
Re: Countdown doesn't work correctly! - by iMonk3y - 04.09.2011, 10:07
Re: Countdown doesn't work correctly! - by [WSF]ThA_Devil - 04.09.2011, 10:16
Re: Countdown doesn't work correctly! - by Basicz - 04.09.2011, 10:16
Re: Countdown doesn't work correctly! - by [WSF]ThA_Devil - 04.09.2011, 10:50

Forum Jump:


Users browsing this thread: 1 Guest(s)