09.08.2011, 12:54
i made a /CD command but when i tried to make a /CCD command (CancelCountDown) i found a problem...
when i use /ccd it stop the gametext (3...2..1..) but still when the timer gets to 0 it says GO!!!... can you help me?
new and forward:
commands:
and CountDown(cd, number) public... :
when i use /ccd it stop the gametext (3...2..1..) but still when the timer gets to 0 it says GO!!!... can you help me?
new and forward:
pawn Код:
new CountDownTimer;
new CountDownOn;
forward CountDown(cd, number);
pawn Код:
if(strcmp(cmd, "/countdown", true) == 0 || strcmp(cmd, "/cd", true) == 0)
{
if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][AdminLevel] >= 1)
{
new tmp[256], tmp2[256];
tmp = strtok(cmdtext, idx);
tmp2 = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOUR_ORANGE, "/CountDown [Time] [0/1 - Freeze]");
return 1;
}
if(!strlen(tmp2))
{
SendClientMessage(playerid, COLOUR_ORANGE, "/CountDown [Time] [0/1 - Freeze]");
return 1;
}
new timer, number, string[128];
timer = strval(tmp);
number = strval(tmp2);
if(CountDownOn == 1) return SendClientMessage(playerid, COLOUR_RED, "лбш йщ сфйшд фетмъ");
if(ResServCdOn == 1) return SendClientMessage(playerid, COLOUR_RED, "дсфйшд майфес дщшъ лбш фетмъ");
if(number > 1 || number < 0) return SendClientMessage(playerid, COLOUR_RED, "оцб ддчфад йлем мдйеъ шч 0/1. 0 - бмй дчфад / 1 - тн дчфад");
if(timer < 1 || timer > 1000) return SendClientMessage(playerid, COLOUR_RED, "лоеъ дщрйеъ зййбъ мдйеъ бйп 1 - 1000");
CountDownOn = 1;
if(number == 0)
{
format(string, sizeof(string), "дордм дзм сфйшд щм %d щрйеъ бмй айфес дчфад", timer);
SendClientMessageToAll(COLOUR_YELLOW, string);
CountDownTimer = SetTimer("CountDown", timer*1000, 0);
CountDown(timer, 0);
}
else
{
format(string, sizeof(string), "дордм дзм сфйшд щм %d щрйеъ тн айфес дчфад");
SendClientMessageToAll(COLOUR_YELLOW, string);
CountDownTimer = SetTimer("CountDown", timer*1000, 0);
CountDown(timer, 1);
ToggleAllPlayersControllable(0);
}
}
else return SendClientMessage(playerid, COLOUR_RED, "аъд зййб мдйеъ мфзеъ агойп шод 1 бщбйм мдщъощ бфчегд же");
return 1;
}
//-------------------------------------------------------------------------------------
if(strcmp(cmd, "/cancelcountdown", true) == 0 || strcmp(cmd, "/ccd", true) == 0)
{
if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][AdminLevel] >= 1)
{
if(CountDownOn == 0) return SendClientMessage(playerid, COLOUR_RED, "айп сфйшд фтймд");
GameTextForAll("~r~Count Down Canceled", 3000, 3);
CountDownOn = 0;
KillTimer(CountDownTimer);
ToggleAllPlayersControllable(1);
}
else return SendClientMessage(playerid, COLOUR_RED, "аъд зййб мдйеъ мфзеъ агойп шод 1 бщбйм мдщъощ бфчегд же");
return 1;
}
pawn Код:
public CountDown(cd, number)
{
new string[128];
format(string, sizeof(string), "%d", cd);
GameTextForAll(string, 1000, 3);
if(cd > 0)
{
cd--;
CountDownTimer = SetTimerEx("CountDown", 1000, 0, "%d", cd);
}
else
{
if(number == 0)
{
GameTextForAll("~g~GO!!!", 3000, 3);
CountDownOn = 0;
}
else
{
GameTextForAll("~g~GO!!!", 3000, 3);
CountDownOn = 0;
KillTimer(CountDownTimer);
ToggleAllPlayersControllable(1);
}
}
}