How can i create a countdown
#1

As the tittle says, how can i create a countdown on OnPlayerEnterCheckPoint?.. He enters there, and he starts capturing the zone, here the code...

pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{

    SendClientMessage(playerid, 0x00FF007A, "Wait 30 Seconds - To Caputre this Zone.");
    new namestr[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(namestr, sizeof(namestr), "[SERVER]: %s[%d] Is trying to capture the checkpoint, Face him!", name, playerid);
    SendClientMessageToAll(0xFF80FFFF, namestr);
    timer = SetTimerEx("SetZone", 30000, false, "i", playerid);
    Checkpoint[playerid] = 1; //
    return 1;
   
}


public OnPlayerLeaveCheckpoint(playerid)
{
    if(Checkpoint[playerid] == 1)
    {
        SendClientMessage(playerid, 0x00FF007A, " You have left the checkpoint , You have failed to capture");
        new namestr[128], name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
        format(namestr, sizeof(namestr), "[SERVER]: %s[%d] Failed to capture the checkpoint.", name, playerid);
        SendClientMessageToAll(red, namestr);
        KillTimer(timer);
        Checkpoint[playerid] = 0;
    }
    return 1;
}
Everything is working fine, i just want to add a countdown just so the player knows how many seconds are left, i'd give rep+ but i cant, but when i can, i surely will.. Help please.
Reply
#2

That's some nice slang in your messages there.
Reply
#3

Ok, fixed ...
Reply
#4

Bump, really need it

Edit:

I found a way.. (i guess) but it is not showing in the screen, when i enter the checkpoint i get fps drop like 4-5 and then they go up, wich means the gametext is trying to show up, Can somebody please help me?

pawn Код:
new CountDownTimer;

public OnPlayerEnterCheckpoint(playerid)
{

    SendClientMessage(playerid, 0x00FF007A, "Wait 30 Seconds - To Caputre this Zone.");
    new namestr[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(namestr, sizeof(namestr), "[INFO]: %s[%d] Is trying to capture the checkpoint, Face him!", name, playerid);
    SendClientMessageToAll(0xFF80FFFF, namestr);
    timer = SetTimerEx("SetZone", 30000, false, "i", playerid);
    CountDownTimer = SetTimerEx("CountDown", 30000, false, "i", playerid);
    Checkpoint[playerid] = 1; //
    return 1;

}

forward CountDown(playerid);
public CountDown(playerid)
{
    GameTextForPlayer(playerid, "~w~Capturing zone ~r~~h~30 ~w~seconds left", 1000, 4);
    GameTextForPlayer(playerid, "~w~Capturing zone ~r~~h~29 ~w~seconds left", 1000, 4);
    GameTextForPlayer(playerid, "~w~Capturing zone ~r~~h~28 ~w~seconds left", 1000, 4);
    GameTextForPlayer(playerid, "~w~Capturing zone ~r~~h~27 ~w~seconds left", 1000, 4);
    GameTextForPlayer(playerid, "~w~Capturing zone ~r~~h~26 ~w~seconds left", 1000, 4);
    GameTextForPlayer(playerid, "~w~Capturing zone ~r~~h~25 ~w~seconds left", 1000, 4);
    GameTextForPlayer(playerid, "~w~Capturing zone ~r~~h~24 ~w~seconds left", 1000, 4);
    GameTextForPlayer(playerid, "~w~Capturing zone ~r~~h~23 ~w~seconds left", 1000, 4);
    GameTextForPlayer(playerid, "~w~Capturing zone ~r~~h~22 ~w~seconds left", 1000, 4);
    GameTextForPlayer(playerid, "~w~Capturing zone ~r~~h~21 ~w~seconds left", 1000, 4);
    GameTextForPlayer(playerid, "~w~Capturing zone ~r~~h~20 ~w~seconds left", 1000, 4);
    GameTextForPlayer(playerid, "~w~Capturing zone ~r~~h~19 ~w~seconds left", 1000, 4);
    GameTextForPlayer(playerid, "~w~Capturing zone ~r~~h~18 ~w~seconds left", 1000, 4);
    GameTextForPlayer(playerid, "~w~Capturing zone ~r~~h~17 ~w~seconds left", 1000, 4);
    GameTextForPlayer(playerid, "~w~Capturing zone ~r~~h~16 ~w~seconds left", 1000, 4);
    GameTextForPlayer(playerid, "~w~Capturing zone ~r~~h~15 ~w~seconds left", 1000, 4);
    GameTextForPlayer(playerid, "~w~Capturing zone ~r~~h~14 ~w~seconds left", 1000, 4);
    GameTextForPlayer(playerid, "~w~Capturing zone ~r~~h~13 ~w~seconds left", 1000, 4);
    GameTextForPlayer(playerid, "~w~Capturing zone ~r~~h~12 ~w~seconds left", 1000, 4);
    GameTextForPlayer(playerid, "~w~Capturing zone ~r~~h~11 ~w~seconds left", 1000, 4);
    GameTextForPlayer(playerid, "~w~Capturing zone ~r~~h~10 ~w~seconds left", 1000, 4);
    GameTextForPlayer(playerid, "~w~Capturing zone ~r~~h~9 ~w~seconds left", 1000, 4);
    GameTextForPlayer(playerid, "~w~Capturing zone ~r~~h~8 ~w~seconds left", 1000, 4);
    GameTextForPlayer(playerid, "~w~Capturing zone ~r~~h~7 ~w~seconds left", 1000, 4);
    GameTextForPlayer(playerid, "~w~Capturing zone ~r~~h~6 ~w~seconds left", 1000, 4);
    GameTextForPlayer(playerid, "~w~Capturing zone ~r~~h~5 ~w~seconds left", 1000, 4);
    GameTextForPlayer(playerid, "~w~Capturing zone ~r~~h~4 ~w~seconds left", 1000, 4);
    GameTextForPlayer(playerid, "~w~Capturing zone ~r~~h~3 ~w~seconds left", 1000, 4);
    GameTextForPlayer(playerid, "~w~Capturing zone ~r~~h~2 ~w~seconds left", 1000, 4);
    GameTextForPlayer(playerid, "~w~Capturing zone ~r~~h~1 ~w~seconds left", 1000, 4);
    GameTextForPlayer(playerid, "~w~Capturing zone ~w~seconds left", 1000, 4);
    return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
    if(Checkpoint[playerid] == 1)
    {
        SendClientMessage(playerid, 0x00FF007A, " You have left the checkpoint , You have failed to capture");
        new namestr[128], name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
        format(namestr, sizeof(namestr), "[INFO]: %s[%d] Failed to capture the checkpoint.", name, playerid);
        SendClientMessageToAll(red, namestr);
        KillTimer(timer);
        KillTimer(CountDownTimer);
        Checkpoint[playerid] = 0;
    }
    return 1;
}
Reply
#5

!BUMP!
Reply
#6

Quote:
Originally Posted by dugi
No double posting. There is a modify button , please use it. However, bumping a topic in which you have or require further information is allowed after at least 24 hours.
Follow the rule
Reply
#7

Unirom, unless you don't know how to script, you could've helped the poor man out on Christmas (well in most of the West European countries we have a 1st and a 2nd Christmas day.)

Strier, I recently made such countdown script, I'll find you the code..
on top:
pawn Код:
new delay[MAX_PLAYERS]=30;// capture zone time = 30
new CountDownTimer[MAX_PLAYERS];
pawn Код:
forward CountDown(playerid);
public CountDown(playerid)
{
    new str[128];
    delay[playerid]--;
    format(str,128,"~w~Capturing zone ~r~~h~%d ~w~seconds left",delay[playerid]);
    GameTextForPlayer(playerid,str,1000,4);
    if(delay[playerid] <= 0)
    {
    KillTimer(CountDownTimer[playerid]);
    delay[playerid]=30;
    // do whatever u need to do once player captured the zone
    }
        return 1;
}
and onplayerenterCP
pawn Код:
GameTextForPlayer(playerid,"~w~Capturing zone ~r~~h~30 ~w~seconds left",1000,4);
CountdownTimer[playerid] = SetTimerEx("CountDown",1000,true,"i",playerid);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)