#1

i am trying to do that if a player will enter an Area (i already defined the area) it will start a countdown to 0
and kill him...
how can i do that.. i tried to make something but it didn't helped... it just said You will die in 3...1...0...0...0...
i don't know why... it was suppose to be 3.2.1 and it was 3.1.0.0.0
do you have any idea how to fix it / how to do what i want?
Reply
#2

I am going to explain it a little bit

On top of your script, pretty basic - add
pawn Код:
forward countdown(playerid, seconds);
new countdowntime, tCountdown;
Now we gotta add the timer you need for the countdown. Add this in the area command
pawn Код:
countdowntime = 3;
tCountdown = SetTimerEx("countdown", 1000, true, "i", playerid);
It will set a Timer to run. We repeat it all the time till it gets killed. The "i" is defining the playerid (else only playerid 0 will be called)

Now we need to create the public function
pawn Код:
public countdown(playerid, seconds)
{
    if(countdowntime  >= 1)
    {
        countdowntime --;
        format(string, sizeof string, "%i", countdowntime);
        GameTextForPlayer(playerid, string, 1000, 4);
    }
    else
    {
        GameTextForPlayer(playerid, "0", 1000, 4);
        KillTimer(tCountdown);     
        countdowntime = 3;
    }
    return 1;
}
If you wonder why I set it to if(countdowntime >= 1). Well, we gotta end it at 0 right? At 0 it will kill the timer.

You can try and see if it works. If it doesn't or you get errors/warnings, please post them
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)