rendered paste bodyCommand:
if (strcmp(cmdtext, "/cd", true, 3) == 0 && cmdtext[3] == ' ')
{
if (!strlen(cmdtext[4])) {
SendClientMessage(playerid,COLOR_YELLOW,"Usage: /cd [time]");
} else if (strval(cmdtext[4]) > 10 || strval(cmdtext[4]) < 1 || strlen(cmdtext[4]) > 2) {
SendClientMessage(playerid,COLOR_YELLOW,"Max time: 10 seconds");
} else if (cdcount > 0) {
SendClientMessage(playerid,COLOR_YELLOW,"Another countdown is already running!");
} else if (!IsNumeric(cmdtext[4])) {
SendClientMessage(playerid,COLOR_YELLOW,"Numeric entries only!");
} else {
cdtimer = SetTimer("Countdown", 1000, 1);
cdcount = strval(cmdtext[4]);
}
return 1;
}
Timer:
public Countdown()
{
new string[256];
if (cdcount > 0) {
format(string,sizeof(string),"%d",cdcount);
GameTextForAll(string,1000,4);
PlaySoundForAll(1056,0,0,0);
cdcount --;
}
else if (cdcount == 0) {
GameTextForAll("GO!",1000,4);
PlaySoundForAll(1057,0,0,0);
KillTimer(cdtimer);
}
}
Requires:
Global variables cdtimer and cdcount