15.12.2012, 10:26
This would be more logical
Always remember that you have to use sizeof() else you can crash your server, also players max name lenght can be only 24 chars, and use format() function as much as you can.
pawn Код:
#include <a_samp>
#define COLOR_LIGHTBLUE 0x33CCFFAA
forward timer();
new Time;
new timerid;
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Count Down By *Aldi*");
print("--------------------------------------\n");
return 1;
}
public timer()
{
if(Time > 0)
{
Time--;
new str[15];
if(Time == 0) { format(str,sizeof(str),"~y~Go Go Go!"); }
else { format(str,sizeof(str),"~g~%d",Time); }
GameTextForAll(str,2000,3);
}
else
{
KillTimer(timerid);
}
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[128],idx,tmp[64];
cmd = strtok(cmdtext, idx);
if(!strcmp(cmd, "/count", true))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, -1, "TIP: /count [Seconds]"); return 1;
}
Time = strval(tmp);
timerid = SetTimer("timer", 1000, 1);
new n[24],str[30];
GetPlayerName(playerid, n, sizeof(n));
format(str, sizeof(str), ">> %s started Count-Down.<<", n);
SendClientMessageToAll(COLOR_LIGHTBLUE, str);
return 1;
}
return 0;
}