VERY annoying Problem :(
#1

hi,

this bug already bugs me for such a long time now and i just CANT get this solved
This is also the last bug preventing me to get my server finally online!
There is a checkpoint on the map.
As soon as a player enters it, i want that a textdraw appears for only this player that has entered the cp.
This textdraw shall count from 20 down to 0.Thats how it should be

But its totally buged
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.
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.
So this is what i got, i tried so much and modified it about 20 times but its still not working
I hope someone can fix this for me

pawn Код:
//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);
This is all i got for this countdown and im begging you to help me

thanks in advance.

regards...
Reply
#2

Quote:
Originally Posted by BlackWolf120
Посмотреть сообщение
hi
Hello

Quote:
Originally Posted by BlackWolf120
Посмотреть сообщение
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.
Thats the cause of this
pawn Код:
new countdownzone[MAX_PLAYERS] = 20;
which set the first cell to 20 and leave the rest
pawn Код:
new countdownzone[MAX_PLAYERS] = {20, ...};
Quote:
Originally Posted by BlackWolf120
Посмотреть сообщение
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.
It doesnt count faster, there are only two different timers running which update the textdraw
And that is the problem because there is only one textdraw!

Quote:
Originally Posted by BlackWolf120
Посмотреть сообщение
Also i want the countdown to be killed for a player as soon as he leaves the cp.
Doesnt that already happen ?
Checkpoint sometimes look smaller than they really are
Reply
#3

Hi there again,
as you've called me in PM for help, here you go:

At TOP:
pawn Код:
forward counterzone(playerid);
new countdownzone[MAX_PLAYERS] = {20,...};
new CDONZone[MAX_PLAYERS];
new Text:MiniCountdown[MAX_PLAYERS];
At OnPlayerEnterCheckpoint:
pawn Код:
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);
The timer
pawn Код:
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;
}
At OnPlayerLeaveCheckpoint
pawn Код:
KillTimer(CDONZone[playerid]);
countdownzone[playerid] = 20;
TextDrawHideForPlayer(playerid, MiniCountdown[playerid]);
TextDrawDestroy(MiniCountdown[playerid]);
I think this should work. Give it a shot.


Jeffry
Reply
#4

hi,

thx so much for ur help, im gonna try it out

thx!!!

regards.
Reply


Forum Jump:


Users browsing this thread: