/aduty Timer Help
#3

Hello, eh created a system which will tell you how many seconds or minutes you were on duty, I don't recommend using timers, could cause a delay in your server, I can assure you that is very optimized and that works .

pawn Код:
// This is a comment
// uncomment the line below if you want to write a filterscript

#define FILTERSCRIPT

#if defined FILTERSCRIPT

#include <a_samp>
#include <YSI\y_timers>
#include <YSI\y_commands>

new bool:player_duty[MAX_PLAYERS];
new time_duty[MAX_PLAYERS];


public OnFilterScriptInit()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        player_duty[i] = false;
        time_duty[i] = 0;
    }
    return true;
}

CMD:duty(playerid, params[])
{
    if(IsPlayerAdmin(playerid))
    {
        new string[144];
        if(player_duty[playerid] != true)
        {
            strdel(string, 0, 144);
            format(string, sizeof(string), "** %s has been duty.", Name(playerid));
            SendClientMessageToAll(-1, string);
            player_duty[playerid] = true;
        }
        else if(player_duty[playerid] != false)
        {
            strdel(string, 0, 144);
            if(time_duty[playerid] < 60)
            {
                format(string, sizeof(string), "** %s ah mode out of duty, total time on duty: %d seconds.", Name(playerid), time_duty[playerid]*1);
                SendClientMessageToAll(-1, string);
            }
            else if(time_duty[playerid] >= 60)
            {
                format(string, sizeof(string), "** %s ah mode out of duty, total time on duty: %d minutes.", Name(playerid), time_duty[playerid]/60*1);
                SendClientMessageToAll(-1, string);
            }
            time_duty[playerid] = 0;
            player_duty[playerid] = false;
        }
    }
    else
    {
        SendClientMessage(playerid, -1, "You are not administrator.");
    }
    return true;
}

stock Name(playerid)
{
    new name[24];
    GetPlayerName(playerid, name, 24);
    return name;
}

task count_time_duty[1000]()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(player_duty[i] != false)
            {
                time_duty[i]++;
            }
        }
    }
    return true;
}

#endif
Reply


Messages In This Thread
/aduty Timer Help - by Mark_Samp - 06.01.2015, 23:33
Re: /aduty Timer Help - by Rufio - 06.01.2015, 23:46
Respuesta: /aduty Timer Help - by JuanStone - 07.01.2015, 01:22
Re: /aduty Timer Help - by Mark_Samp - 07.01.2015, 14:25

Forum Jump:


Users browsing this thread: 1 Guest(s)