!!Countdown textdraw issue!!
#1

hi,

as soon as a player enters a checkpoint there appears a textdraw counting from 20 down to 0.
The action (that i want to be executed ) takes place 20 after the player has enteres the cp.
But the problem is that if there is more than 1 player online the countdown is bugged!
It counts like 20, 16, 7, 3. Totaly wrong, i dont know whats wrong with this code.
Maybe you can help me.

pawn Код:
new HasEntered[MAX_PLAYERS];

//OnPlayerEnterCheckpoint

SetTimerEx("Bombspawnpolice",20000,false,"i",playerid);
CDONZone = SetTimerEx("counterzone",990,false,"i",playerid);
HasEntered[playerid] = 1;


//this is my countdown function
public counterzone(playerid)
{
for(new i; i < MAX_PLAYERS; i ++)
{
if(HasEntered[i] == 1 && countdownzone > 0)
{
CDONZone = SetTimer("counterzone",990,false);
new textformat[85];
format(textformat,sizeof textformat,"~g~%d",countdownzone);
TextDrawSetString(MiniCountdown,textformat);
TextDrawShowForPlayer(i,MiniCountdown);
countdownzone --;
}
}
return 1;
}

//BombSpawnPoliceTimer

countdownzone = 20;
KillTimer(CDONZone);
TextDrawHideForPlayer(playerid,MiniCountdown);
HasEntered[playerid] = 0;
Reply
#2

Your countdown variable is inside the loop so if there are 5 players connected the count down will jump down 5 numbers. Place countdownzone outside the loop.

pawn Код:
public counterzone(playerid)
{
    for(new i; i < MAX_PLAYERS; i ++)
    {
        if(HasEntered[i] == 1 && countdownzone > 0)
        {
            CDONZone = SetTimer("counterzone",990,false);
            new textformat[85];
            format(textformat,sizeof textformat,"~g~%d",countdownzone);
            TextDrawSetString(MiniCountdown,textformat);
            TextDrawShowForPlayer(i,MiniCountdown);
        }
    }
    countdownzone --;
    return 1;
}
Reply
#3

ok, thx so much

didnt see that thx thx
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)