Countdown for all - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Countdown for all (
/showthread.php?tid=508896)
Countdown for all -
Affan - 24.04.2014
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;
}
Re: Countdown for all -
arakuta - 24.04.2014
Use loops.
https://sampforum.blast.hk/showthread.php?tid=305770
Re: Countdown for all -
Roel - 24.04.2014
NVM I misunderstood your question..
Re: Countdown for all -
Konstantinos - 24.04.2014
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--;
}
Re: Countdown for all -
Affan - 24.04.2014
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.