Help timer
#1

How I can use a command once to 1 minute?



In order that:

pawn Код:
/===================/recrutez==========================================================
if(strcmp(cmd, "/recrutezmedics", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pLeader] != 4)
            {
            SCM(playerid, COLOR_GREY, "* Nu esti Leader Medics!");
            return 1;
            }
            if(PlayerInfo[playerid][pMuted] == 1)
            {
                SendClientMessage(playerid, TEAM_CYAN_COLOR, " You can't speak, you have been silenced!");
                return 1;
            }
            else
            GetPlayerName(playerid, sendername, sizeof(sendername));
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[64];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            if(!strlen(result))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /recrutez [text]");
                return 1;
            }
            if(PlayerInfo[playerid][pAdmin] == 0 || PlayerInfo[playerid][pHelper] == 0)
                {
                    for(new i=0; i<MAX_ENTRY; i++)
                    {
                        if(!Swear[i][0]) continue;
                        Cenzura(result,Swear[i]);
                    }
                }
            SendClientMessageToAll(COLOR_WHITE, "|___________ MEDICS NEWS ANNOUNCEMENT ___________|");
            format(string, sizeof(string), "Leader %s says new announce:  %s", sendername, result);
            SendClientMessageToAll(COLOR_LIGHTRED, string);
        }
        return 1;
    }
Reply
#2

pawn Код:
//top of script
new medictickcount[MAX_PLAYERS];


//your new cmd
if(strcmp(cmd, "/recrutezmedics", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pLeader] != 4) return SCM(playerid, COLOR_GREY, "* Nu esti Leader Medics!");
            if(PlayerInfo[playerid][pMuted] == 1) return SendClientMessage(playerid, TEAM_CYAN_COLOR, " You can't speak, you have been silenced!");
            if((GetTickCount()-medictickcount[playerid])<60*1000) return SCM(playerid,COLOR_GREY,"You can use this command only once every minute!");
           
            GetPlayerName(playerid, sendername, sizeof(sendername));
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[64];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            if(!strlen(result))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /recrutez [text]");
                return 1;
            }
            if(PlayerInfo[playerid][pAdmin] == 0 || PlayerInfo[playerid][pHelper] == 0)
                {
                    for(new i=0; i<MAX_ENTRY; i++)
                    {
                        if(!Swear[i][0]) continue;
                        Cenzura(result,Swear[i]);
                    }
                }
            SendClientMessageToAll(COLOR_WHITE, "|___________ MEDICS NEWS ANNOUNCEMENT ___________|");
            format(string, sizeof(string), "Leader %s says new announce:  %s", sendername, result);
            SendClientMessageToAll(COLOR_LIGHTRED, string);
            medictickcount[playerid] = GetTickCount();
        }
        return 1;
    }
Cheers.
Reply
#3

Код:
new limit[MAX_PLAYERS];
OnPlayerConnect
Код:
limit[playerid] = 0;
OnPlayerDisconnect
Код:
limit[playerid] = 0;
Then,
Код:
if(strcmp(cmd, "/recrutezmedics", true) == 0)
    {
        if(limit[playerid] == 0)
        {
        limit[playerid]=1;
        SetTimerEx("TimeLimit",60000,false,"i",playerid);
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pLeader] != 4)
            {
            SCM(playerid, COLOR_GREY, "* Nu esti Leader Medics!");
            return 1;
            }
            if(PlayerInfo[playerid][pMuted] == 1)
            {
                SendClientMessage(playerid, TEAM_CYAN_COLOR, " You can't speak, you have been silenced!");
                return 1;
            }
            else
            GetPlayerName(playerid, sendername, sizeof(sendername));
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[64];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            if(!strlen(result))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /recrutez [text]");
                return 1;
            }
            if(PlayerInfo[playerid][pAdmin] == 0 || PlayerInfo[playerid][pHelper] == 0)
                {
                    for(new i=0; i<MAX_ENTRY; i++)
                    {
                        if(!Swear[i][0]) continue;
                        Cenzura(result,Swear[i]);
                    }
                }
            SendClientMessageToAll(COLOR_WHITE, "|___________ MEDICS NEWS ANNOUNCEMENT ___________|");
            format(string, sizeof(string), "Leader %s says new announce:  %s", sendername, result);
            SendClientMessageToAll(COLOR_LIGHTRED, string);
        }
        }
        else
        {
         SendClientMessage(playerid,-1,"Wait at least 1 min");
         return 1;
        }
        return 1;
    }
Then,
Код:
forward TimeLimit(playerid);
public TimeLimit(playerid)
{
 limit[playerid] = 0;
}
Reply
#4

But where's the time? I want to put a time using the command, 1 minutes.
Reply
#5

Код:
SetTimerEx("TimeLimit",60000,false,"i",playerid);
This is the function which start the 1 minute countdown.
Reply
#6

And in my code
pawn Код:
if((GetTickCount()-medictickcount[playerid])<60*1000) return SCM(playerid,COLOR_GREY,"You can use this command only once every minute!");
Checks has command been used in previous minute.
Reply
#7

Thank you!

And how do you bag and the other commands?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)