02.07.2011, 10:55
How can I make a countdown system with gametextforall? :0
public OnPlayerSpawn(playerid) { SetTimer("Five", 1000, 0); SetTimer("Four", 2000, 0); SetTimer("Three", 3000, 0); SetTimer("Two", 4000, 0); SetTimer("One", 5000, 0); SetTimer("Gooooo", 6000, 0); } public Five() { GameTextForAll("~r~5", 2000, 4); } public Four() { GameTextForAll("~r~4", 2000, 4); } public Three() { GameTextForAll("~r~3", 2000, 4); } public Five() { GameTextForAll("~r~5", 2000, 4); } public Two() { GameTextForAll("~r~2", 2000, 4); } public One() { GameTextForAll("~r~1", 2000, 4); } public Gooooo() { GameTextForAll("~r~Gooooo", 2000, 4); } |
new CountDownVar = 4;
if(!strcmp(cmdtext, "/countdown", true))
{
CountDownTimer = SetTimer("CountDown", 1000, false);
return 1;
}
forward CountDown();
public CountDown()
{
CountDownVar--; //Thanks for the fix.
new str[128];
if(CountDownVar == 0)
{
KillTimer(CountDownTimer);
CountDownVar = 4; //Edit thanks to Hiddos...i was sleepy :S
}
else
{
format(str, sizeof(str), "Count Down: %d", CountDownTimer);
GameTextForAll(str, 1000, 1);
}
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[]) { if(strcmp(cmdtext, "/cdown", true) == 0) { SetTimer("Five", 1000, 0); SetTimer("Four", 2000, 0); SetTimer("Three", 3000, 0); SetTimer("Two", 4000, 0); SetTimer("One", 5000, 0); SetTimer("Gooooo", 6000, 0); } return 1; } public Five() { GameTextForAll("~r~5", 2000, 4); } public Four() { GameTextForAll("~r~4", 2000, 4); } public Three() { GameTextForAll("~r~3", 2000, 4); } public Five() { GameTextForAll("~r~5", 2000, 4); } public Two() { GameTextForAll("~r~2", 2000, 4); } public One() { GameTextForAll("~r~1", 2000, 4); } public Gooooo() { GameTextForAll("~r~Gooooo", 2000, 4); } |
public CountDown(seconds)
{
new msg[64];
if(seconds == 0)
{
//time's up - your code
}
else
{
//To display how much seconds left:
format(msg,64,"Time left: %i",seconds);
GameTextForAll(msg,1000,3);
seconds --;
SetTimerEx("CountDown",1000,0,"i",seconds); //countdown continues
}
}
new SCount = 11;
new SStart = 0;
new Timer;
CMD:start(playerid, cmdtext)
{
if(SStart == 0)
{
Timer = SetTimer("Counter", 1000, true); // Creates a timer that doesnt stop untill you say
SStart = 1;
} else return SendClientMessage(playerid, -1, " ** Theres already a countdown going on! ");
return 1;
}
forward Count();
public Count()
{
SCount --; // Removes 1 from SCount
switch(SCount)
{
case 11:{} // if SCount == 11, then do this
case 10:{ GameTestForAll("~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~r~10", 2000, 3); } // if SCount == 10, then do this
case 9: { GameTestForAll("~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~r~9", 2000, 3); }// if SCount == 9, then do this
case 8: { GameTestForAll("~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~r~8", 2000, 3); } // etc
case 7: { GameTestForAll("~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~r~7", 2000, 3); }
case 6: { GameTestForAll("~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~r~6", 2000, 3); }
case 5: { GameTestForAll("~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~r~5", 2000, 3); }
case 4: { GameTestForAll("~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~r~4", 2000, 3); }
case 3: { GameTestForAll("~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~r~3", 2000, 3); }
case 2: { GameTestForAll("~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~r~2", 2000, 3); }
case 1: { GameTestForAll("~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~y~1", 2000, 3); }
case 0: {
GameTestForAll("~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~g~ ] GO GO GO ]", 4000, 3);
KillTimer(Timer); // Kills the timer so it stops counting
SStart = 0; // You can use the command again
SCount = 11; // Resets the variable to 11
}
}
return 0;
}
/*---------------------------------
-- :) --
-- --
-- Made By V1ceC1ty --
-- anti countspam by Radi --
-- --
-- :) --
---------------------------------*/
#include <a_samp>
#define COLOR_BLUE 0x0259EAFF
forward One();
forward Two();
forward Three();
forward Four();
forward Five();
forward GoGoGo();
forward countspam2();
new countspam[MAX_PLAYERS];
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/count", cmdtext, true, 10) == 0)
{
if(countspam[playerid]==0)
{
SetTimer("Five", 1000, 0);
SetTimer("Four", 2000, 0);
SetTimer("Three", 3000, 0);
SetTimer("Two", 4000, 0);
SetTimer("One", 5000, 0);
SetTimer("GoGoGo", 6000, 0);
countspam[playerid]=1;
SetTimer("countspam2",120000,0);
}
else
{
SendClientMessage(playerid,COLOR_BLUE, "Please wait before using this Command again.");
}
return 1;
}
return 0;
}
public Five()
{
GameTextForAll("~h~~h~~h~5",2000,3);
return 1;
}
public Four()
{
GameTextForAll("~h~~h~~h~5~n~~b~4",2000,3);
return 1;
}
public Three()
{
GameTextForAll("~h~~h~~h~5~n~~b~4~n~~y~3",2000,3);
return 1;
}
public Two()
{
GameTextForAll("~h~~h~~h~5~n~~b~4~n~~y~3~n~~p~2",2000,3);
return 1;
}
public One()
{
GameTextForAll("~h~~h~~h~5~n~~b~4~n~~y~3~n~~p~2~n~~r~1",2000,3);
return 1;
}
public GoGoGo()
{
GameTextForAll("~h~~h~~h~5~n~~b~4~n~~y~3~n~~p~2~n~~r~1~n~~n~~>~~g~GO ~b~GO ~r~GO~y~!~<~",3000,3);
return 1;
}
Thank you...just one thing
E:\SAMP\gamemodes\FStudios.pwn(14987) : warning 203: symbol is never used: "countdown" |
I Get it From SA-MP Forum
pawn Код:
|