04.09.2011, 09:59
I would do :
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.
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;
}
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.