SA-MP Forums Archive
Countdown Textdraw issues :( - 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 issues :( (/showthread.php?tid=232497)



Countdown Textdraw issues :( - BlackWolf120 - 27.02.2011

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...


Re: Countdown Textdraw issues :( - BlackWolf120 - 28.02.2011

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


Re: Countdown Textdraw issues :( - BMUK - 28.02.2011

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


Re: Countdown Textdraw issues :( - BlackWolf120 - 04.03.2011

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

regards.