27.06.2012, 09:55
Try to use this, i fixed it a little bit.
Your mistake was:
> Starting Timer more then one time, for everyone near you.
> Resetting the Timer if someone is near you (that bugs arround for you)
This is my fixed version ^-^.
Your mistake was:
> Starting Timer more then one time, for everyone near you.
> Resetting the Timer if someone is near you (that bugs arround for you)
pawn Код:
new Timer_Countdown;
new CountDown_Time;
command(countdown,playerid,params[])
{
CountDown(playerid, 3);
return 1;
}
forward CountDown(playerid, seconds);
public CountDown(playerid, seconds)
{
if(seconds > 0)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
CountDown_Time = seconds;
CountDownThink(X,Y,Z);
KillTimer(Timer_Countdown);
Timer_Countdown = SetTimerEx("CountDownThink", 1000,true, "fff", X,Y,Z);
return 1;
}
return 1;
}
forward CountDownThink(Float:X,Float:Y,Float:Z);
public CountDownThink(Float:X,Float:Y,Float:Z)
{
new string[50];
new seconds = CountDown_Time;
for(new i=0;i<MAX_PLAYERS;i++)
{
if(IsPlayerInRangeOfPoint(i, 40, X, Y, Z))
{
if(seconds == 0)
{
PlayerPlaySound(i, 1057, X, Y, Z);
GameTextForPlayer(i, "~G~Go!", 1000, 3);
}
else
{
PlayerPlaySound(i, 1056, X, Y, Z);
format(string, sizeof(string), "~b~%d", seconds);
GameTextForPlayer(i, string, 1000, 3);
CountDown_Time = seconds -1;
}
}
}
if (seconds == 0)
{
KillTimer(Timer_Countdown);
}
}