Countdown for all
#1

So what I'm trying to do, spawn all players at a random point, (the random points are in a circle in a mapped stadium) and then freeze and start the countdown, after the countdown ends, unfreeze. I'm trying to make it work for all. Like, it brings all players, and show the countdown to all, and unfreeze / freeze all.

pawn Код:
COMMAND:start(playerid, params[])
{
        new rand = random(sizeof(pRandomSpawns));
        SetPlayerPos(playerid, pRandomSpawns[rand][0], pRandomSpawns[rand][1], pRandomSpawns[rand][2]);
        TogglePlayerControllable(playerid, false);
        cd_sec = 5;
        cd_timer = SetTimer("countdown", 999, 1);
        return 1;
}
pawn Код:
forward countdown(playerid);
public countdown(playerid)
{
    if(cd_sec == 0)
    {
        GameTextForAll("~r~Go!",1000,3);
        TogglePlayerControllable(playerid, true);
        KillTimer(cd_timer);
    }
    else
    {
        new string[8];
        format(string,sizeof(string),"~g~%d",cd_sec);
        GameTextForAll(string,1000,3);
    }
    cd_sec = cd_sec-1;
    return 1;
}
Reply
#2

Use loops.

https://sampforum.blast.hk/showthread.php?tid=305770
Reply
#3

NVM I misunderstood your question..
Reply
#4

pawn Код:
COMMAND:start(playerid, params[])
{
    new rand;
    foreach(new i : Player)
    {
        TogglePlayerControllable(i, false);
        rand = random(sizeof(pRandomSpawns));
        SetPlayerPos(i, pRandomSpawns[rand][0], pRandomSpawns[rand][1], pRandomSpawns[rand][2]);
    }
    cd_sec = 5;
    cd_timer = SetTimer("countdown", 1000, 1);
    return 1;
}
   
forward countdown();
public countdown()
{
    if (!cd_sec)
    {
        GameTextForAll("~r~Go!",1000,3);
        foreach(new i : Player) TogglePlayerControllable(i, true);
        KillTimer(cd_timer);
    }
    else
    {
        new string[8];
        format(string,sizeof(string),"~g~%d",cd_sec);
        GameTextForAll(string,1000,3);
    }
    cd_sec--;
}
Reply
#5

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
pawn Код:
COMMAND:start(playerid, params[])
{
    new rand;
    foreach(new i : Player)
    {
        TogglePlayerControllable(i, false);
        rand = random(sizeof(pRandomSpawns));
        SetPlayerPos(i, pRandomSpawns[rand][0], pRandomSpawns[rand][1], pRandomSpawns[rand][2]);
    }
    cd_sec = 5;
    cd_timer = SetTimer("countdown", 1000, 1);
    return 1;
}
   
forward countdown();
public countdown()
{
    if (!cd_sec)
    {
        GameTextForAll("~r~Go!",1000,3);
        foreach(new i : Player) TogglePlayerControllable(i, true);
        KillTimer(cd_timer);
    }
    else
    {
        new string[8];
        format(string,sizeof(string),"~g~%d",cd_sec);
        GameTextForAll(string,1000,3);
    }
    cd_sec--;
}
Thank you, sadly I can rep after 24 hours , but I'll be sure to REP you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)