SA-MP Forums Archive
!!Countdown textdraw issue!! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: !!Countdown textdraw issue!! (/showthread.php?tid=221755)



!!Countdown textdraw issue!! - BlackWolf120 - 06.02.2011

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;



Re: !!Countdown textdraw issue!! - On_Top_Non_Stop - 06.02.2011

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;
}



Re: !!Countdown textdraw issue!! - BlackWolf120 - 06.02.2011

ok, thx so much

didnt see that thx thx