new counter;
new countTimer;
forward timer();
if(!strcmp(cmdtext, "/count", true) || !strcmp(cmdtext, "/countdown", true))
{
if(counter != 0)
return SendClientMessage(playerid, COLOR_YELLOW, "Wait 5 seconds,then try again!");
countTimer = SetTimer("timer", 1000, true);
return true;
}
public timer()
{
counter++;
else if(counter == 1)
GameTextForAll("3", 500, 3);
else if(counter == 2)
GameTextForAll("2", 500, 3);
else if(counter == 3)
GameTextForAll("1", 500, 3);
else if(counter == 4)
{
GameTextForAll("GO!", 500, 3);
counter = 0;
KillTimer(countTimer);
}
return true;
}
forward CountDown(num);
new CountRunning =0;
dcmd_cd(playerid, params[])
{
if (!strlen(params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /cd [time]");
else if(CountRunning) return SendClientMessage(playerid, COLOR_RED, "There is already a countdown running.");
else if(!IsNumeric(params)) return SendClientMessage(playerid, COLOR_RED, "The [amount] param must be numerical");
else if (strval(params) < 1) return SendClientMessage(playerid, COLOR_RED, "The count has to be greater than zero");
else if (strval(params) > 10) return SendClientMessage(playerid, COLOR_RED, "The count can't be higher than 10!");
else
{
CountRunning = 1;
new ii = strval(params);
do
{
SetTimerEx("CountDown", (strval(params) - ii) * 1000, false, "i", ii);
ii --;
}
while (ii != -1);
SendClientMessage(playerid, COLOR_WHITE, "***CountDown Started***");
}
return 1;
}
public CountDown(num)
{
new str[2];
if (num)
{
format(str, sizeof(str), "%i", num);
GameTextForAll(str, 1001, 5);
}
else
{
GameTextForAll("~g~Go", 3000, 5);
CountRunning = 0;
}
}
Originally Posted by lrZ^ aka LarzI
pawn Код:
|
public timer()
{
counter++;
if(counter == 1)
GameTextForAll("3", 500, 3);
else if(counter == 2)
GameTextForAll("2", 500, 3);
else if(counter == 3)
GameTextForAll("1", 500, 3);
else if(counter == 4)
{
GameTextForAll("GO!", 500, 3);
counter = 0;
KillTimer(countTimer);
}
return true;
}
new Count=5;
new Countertimer;
-----
Command: /countdown:
SendClientMessage(playerid, COLOR, "You started the count down!");
Countertimer = SetTimer("Countdown", 1000, 1);
GameTextForAll("5 Seconds", 1000, 4);
-----
forward Countdown();
public Countdown()
{
Count--;
new string[128];
format(string, sizeof(string), "%d Seconds", Count);
GameTextForAll(string, 1000, 4);
if(Count == 0)
{
GameTextForAll("GO GO GO", 2000, 4);
KillTimer(CounterTimer);
Count=5;
}