23.01.2011, 19:56
When i type "/countdown 20 Hi!" then the count down sart like this...
76
75
74
ect..
Why it dont count down from the number i entered?
76
75
74
ect..
Why it dont count down from the number i entered?
pawn Код:
#include <a_samp>
#include <sscanf>
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
forward Counter();
new CountdownTimer = -1;
new CountDownMessage[256];
new Counttime;
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(countdown, 9, cmdtext);
return 0;
}
dcmd_countdown(playerid, params[])
{
new time, cdmessage;
if(CountdownTimer != -1) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: Countdown already started!");
if(sscanf(params, "ds", time, cdmessage)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /countdown (text) (message)");
Counttime = time;
format(CountDownMessage, 128, "%s", cdmessage);
CountdownTimer = SetTimer("Counter", 1000, true);
return 1;
}
public Counter()
{
Counttime--;
if(Counttime <= 0)
{
GameTextForAll(CountDownMessage, 1500, 3);
KillTimer(CountdownTimer);
CountdownTimer = -1;
}
else
{
new string[256];
format(string, 10, "%d", Counttime);
GameTextForAll(string, 2000, 3);
}
return 1;
}