//at the top of the script
forward counterzone(playerid);
new countdownzone[MAX_PLAYERS] = 20;
new CDONZone[MAX_PLAYERS];
new Text:MiniCountdown;
//OnGameModeInit
MiniCountdown = TextDrawCreate(3.000000, 412.000000, "20");
TextDrawBackgroundColor(MiniCountdown, 255);
TextDrawFont(MiniCountdown, 3);
TextDrawLetterSize(MiniCountdown, 0.939999, 3.900000);
TextDrawColor(MiniCountdown, -1);
TextDrawSetOutline(MiniCountdown, 1);
TextDrawSetProportional(MiniCountdown, 1);
TextDrawUseBox(MiniCountdown, 0);
TextDrawBoxColor(MiniCountdown, 1684300900);
TextDrawTextSize(MiniCountdown, 41.000000, 0.000000);
//OnPlayerEnterCheckpoint
CDONZone[playerid] = SetTimerEx("counterzone",990,false,"i",playerid);
//the timer
public counterzone(playerid)
{
if(countdownzone[playerid] > 0)
{
TextDrawShowForPlayer(playerid,MiniCountdown);
new textformat[85];
format(textformat,sizeof textformat,"~g~%d",countdownzone[playerid]);
TextDrawSetString(MiniCountdown,textformat);
CDONZone[playerid] = SetTimerEx("counterzone",990,false,"i",playerid);
countdownzone[playerid] --;
}
return 1;
}
//OnPlayerLeaveCheckpoint
KillTimer(CDONZone[playerid]);
countdownzone[playerid] = 20;
TextDrawHideForPlayer(playerid,MiniCountdown);
If there are more than 1 player on the server the textdraw doesnt appear at all or just for one single player if he enters the cp.
|
new countdownzone[MAX_PLAYERS] = 20;
new countdownzone[MAX_PLAYERS] = {20, ...};
Another issue is that it is counting down faster as soon as there are 2 or more players in the cp at the same time.
|
Also i want the countdown to be killed for a player as soon as he leaves the cp.
|
forward counterzone(playerid);
new countdownzone[MAX_PLAYERS] = {20,...};
new CDONZone[MAX_PLAYERS];
new Text:MiniCountdown[MAX_PLAYERS];
CDONZone[playerid] = SetTimerEx("counterzone",990,true,"i",playerid);
MiniCountdown[playerid] = TextDrawCreate(3.000000, 412.000000, "20");
TextDrawBackgroundColor(MiniCountdown[playerid], 255);
TextDrawFont(MiniCountdown[playerid], 3);
TextDrawLetterSize(MiniCountdown[playerid], 0.939999, 3.900000);
TextDrawColor(MiniCountdown[playerid], -1);
TextDrawSetOutline(MiniCountdown[playerid], 1);
TextDrawSetProportional(MiniCountdown[playerid], 1);
TextDrawUseBox(MiniCountdown[playerid], 0);
TextDrawBoxColor(MiniCountdown[playerid], 1684300900);
TextDrawTextSize(MiniCountdown[playerid], 41.000000, 0.000000);
public counterzone(playerid)
{
if(countdownzone[playerid] > 0)
{
TextDrawShowForPlayer(playerid,MiniCountdown[playerid]);
new textformat[10];
format(textformat,sizeof textformat,"~g~%d",countdownzone[playerid]);
TextDrawSetString(MiniCountdown[playerid],textformat);
countdownzone[playerid] --;
}
return 1;
}
KillTimer(CDONZone[playerid]);
countdownzone[playerid] = 20;
TextDrawHideForPlayer(playerid, MiniCountdown[playerid]);
TextDrawDestroy(MiniCountdown[playerid]);