Countdown system
#2

This would be more logical

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;
}
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.
Reply


Messages In This Thread
Countdown system - by CrystalFire - 15.12.2012, 09:50
Re: Countdown system - by ikey07 - 15.12.2012, 10:26

Forum Jump:


Users browsing this thread: 1 Guest(s)