Countdown Textdraw issues :(
#1

hi samp'ers,

i just got a problem i cant get rid of for a long time
There is a checkpoint on the map visible for all players.

As soon as someone enters the cp there appears a textdraws counting from 20 secods down to 0.
When this player exits the cp again, the textdraw shall disapear and start from 20 seconds again if he enters again.
But righ now its kinda fucked up
If there are more than 1 player on the server it starts to count faster if 2 player enter the cp at the same time.
Also it starts to count after a player leaves the cp.
I cant explain this problem very well but i give u the code and i hope that some scripters are able to see the error.

pawn Код:
//At the top of the script

forward counterzone(playerid);
new countdownzone = 20;
new CDONZone[MAX_PLAYERS];


//as soon as a player enters the cp

CDONZone[playerid] = SetTimerEx("counterzone",990,false,"i",playerid);


//the timer

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

return 1;
}


//OnPlayerLeaveCheckpoint

KillTimer(CDONZone[playerid]);
countdownzone = 20;
TextDrawHideForPlayer(playerid,MiniCountdown);


//when the countdown reaches zero

KillTimer(CDONZone[playerid]);
countdownzone = 20;
TextDrawHideForPlayer(playerid,MiniCountdown);
It works good as soon as there is only one player on the server but as soon as this circumstance changes its everything kinda buged

regards...
Reply
#2

please can a brave scripter take a look at this code?
It is very important!!
pls.
Reply
#3

I changed some bits. Totally untested but looks ok.

I don't know what hasentered is so left it there.

http://pastebin.com/FCHiKMkZ

Tell me if it works
Reply
#4

thx alot for ur code but i had to solve it with another method
thx anyway

regards.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)