(1+ REP) Anti Command SPAM
#1

as title says, i want an anti-command spam for ONLY 1 command.... im using zcmd

i found ant-command spam but they are for ALL Commands, and some is using different types of cmd or others.
Reply
#2

anyone?
Reply
#3

Maybe you could see with "OnPlayerCommandPerformed(playerid,cmdtext[],success)" ?
Reply
#4

Use SetTimerEX
Reply
#5

Quote:
Originally Posted by NewbieTester
Посмотреть сообщение
Use SetTimerEX
I Dont Know Where To Add Here:
PHP код:
CMD:sharexp(playerid,params[])
{
    if(
pInfo[playerid][pLogged] == 1)
    {
        if(
pInfo[playerid][pHour] >= 10)
        {
            new 
targetid,givexp,reason[105],stringxp[256];
            if(
sscanf(params,"uis[105]"targetid,givexp,reason)) return SendClientMessage(playerid,-1,""chat" /sharexp [playerid] [amount] [reason]");
            if(!
IsPlayerConnected(targetid)) return SendClientMessage(playerid,-1,""chat" Player is not online");
            if(
targetid == playerid) return SendClientMessage(playerid,-1,""chat" You cannot give xp to yourself");
            if(
givexp 49 || givexp 5000) return SendClientMessage(playerid,-1,""chat"  You can only give xp between 50-5000");
            if (
givexp && pInfo[playerid][pXP] >= givexp)
            {
                
pInfo[targetid][pXP] += givexp;
                
pInfo[playerid][pXP] -= givexp;
                
format(stringxp,sizeof(stringxp),""chat" Player %s has shared %d xp to %s [Reason: %s]"PlayerName(playerid), givexpPlayerName(targetid), reason);
                
SendClientMessageToAll(-1,stringxp);
                
printf("Player %s has shared %d xp to %s [Reason: %s]"PlayerName(playerid), givexpPlayerName(targetid), reason);
            }
            else
            {
                
SendClientMessage(playerid,-1,""chat" You don't have enough XP");
            }
        }
        else 
SendClientMessage(playerid,-1,""chat" You need to play 10 hours before you can share xp!");
    }
    else if(
pInfo[playerid][pLogged] == 0)
    {
        
SendClientMessage(playerid,-1,""chat""COL_LIGHTBLUE" Nice try u fucking fag gay!");
        
printf("%s has been kicked for trying to use a command without being logged in!"PlayerName(playerid));
        
Kick(playerid);
    }
    return 
1;

Can You Do It For me?
Reply
#6

Please Add Comments To Make Me Understand.
Reply
#7

Put this at the top.
pawn Код:
new sharexptimer[MAX_PLAYERS];
new sharetimer[MAX_PLAYERS];
Now do this.
pawn Код:
CMD:sharexp(playerid,params[])
{
    if(sharetimer[playerid] == 1) return SendClientMessage(playerid, -1, "You must wait 3 minutes to use this cmd!");//checks if the player used the cmd already.
    if(pInfo[playerid][pLogged] == 1)
    {
        if(pInfo[playerid][pHour] >= 10)
        {
            new targetid,givexp,reason[105],stringxp[256];
            if(sscanf(params,"uis[105]", targetid,givexp,reason)) return SendClientMessage(playerid,-1,""chat" /sharexp [playerid] [amount] [reason]");
            if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,-1,""chat" Player is not online");
            if(targetid == playerid) return SendClientMessage(playerid,-1,""chat" You cannot give xp to yourself");
            if(givexp < 49 || givexp > 5000) return SendClientMessage(playerid,-1,""chat"  You can only give xp between 50-5000");
            if (givexp > 0 && pInfo[playerid][pXP] >= givexp)
            {
                pInfo[targetid][pXP] += givexp;
                pInfo[playerid][pXP] -= givexp;
                sharetimer[playerid] = 1; // Once you use the command it makes it 1, stating you can not use it again, until the timer ends
                sharexptimer[playerid] = SetTimerEx("XP", 200000,false, "d", playerid); //starts the timer
                format(stringxp,sizeof(stringxp),""chat" Player %s has shared %d xp to %s [Reason: %s]", PlayerName(playerid), givexp, PlayerName(targetid), reason);
                SendClientMessageToAll(-1,stringxp);
                printf("Player %s has shared %d xp to %s [Reason: %s]", PlayerName(playerid), givexp, PlayerName(targetid), reason);

            }
            else
            {
                SendClientMessage(playerid,-1,""chat" You don't have enough XP");
            }
        }
        else SendClientMessage(playerid,-1,""chat" You need to play 10 hours before you can share xp!");
    }
    else if(pInfo[playerid][pLogged] == 0)
    {
        SendClientMessage(playerid,-1,""chat""COL_LIGHTBLUE" Nice try u fucking fag gay!");
        printf("%s has been kicked for trying to use a command without being logged in!", PlayerName(playerid));
        Kick(playerid);
    }
    return 1;
}
Now forward the Timer
pawn Код:
forward XP(playerid);
public XP(playerid)
{
   sharetimer[playerid] = 0;//lets you use the cmd again once the timer has ended
   SendClientMessage(playerid, -1, "You can use share XP again");
   return 1;
}
Let me know if this helps
Reply
#8

Quote:
Originally Posted by gtasarules14
Посмотреть сообщение
Put this at the top.
pawn Код:
new sharexptimer[MAX_PLAYERS];
new sharetimer[MAX_PLAYERS];
Now do this.
pawn Код:
CMD:sharexp(playerid,params[])
{
    if(sharetimer[playerid] == 1) return SendClientMessage(playerid, -1, "You must wait 3 minutes to use this cmd!");//checks if the player used the cmd already.
    if(pInfo[playerid][pLogged] == 1)
    {
        if(pInfo[playerid][pHour] >= 10)
        {
            new targetid,givexp,reason[105],stringxp[256];
            if(sscanf(params,"uis[105]", targetid,givexp,reason)) return SendClientMessage(playerid,-1,""chat" /sharexp [playerid] [amount] [reason]");
            if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,-1,""chat" Player is not online");
            if(targetid == playerid) return SendClientMessage(playerid,-1,""chat" You cannot give xp to yourself");
            if(givexp < 49 || givexp > 5000) return SendClientMessage(playerid,-1,""chat"  You can only give xp between 50-5000");
            if (givexp > 0 && pInfo[playerid][pXP] >= givexp)
            {
                pInfo[targetid][pXP] += givexp;
                pInfo[playerid][pXP] -= givexp;
                sharetimer[playerid] = 1; // Once you use the command it makes it 1, stating you can not use it again, until the timer ends
                sharexptimer[playerid] = SetTimerEx("XP", 200000,false, "d", playerid); //starts the timer
                format(stringxp,sizeof(stringxp),""chat" Player %s has shared %d xp to %s [Reason: %s]", PlayerName(playerid), givexp, PlayerName(targetid), reason);
                SendClientMessageToAll(-1,stringxp);
                printf("Player %s has shared %d xp to %s [Reason: %s]", PlayerName(playerid), givexp, PlayerName(targetid), reason);

            }
            else
            {
                SendClientMessage(playerid,-1,""chat" You don't have enough XP");
            }
        }
        else SendClientMessage(playerid,-1,""chat" You need to play 10 hours before you can share xp!");
    }
    else if(pInfo[playerid][pLogged] == 0)
    {
        SendClientMessage(playerid,-1,""chat""COL_LIGHTBLUE" Nice try u fucking fag gay!");
        printf("%s has been kicked for trying to use a command without being logged in!", PlayerName(playerid));
        Kick(playerid);
    }
    return 1;
}
Now forward the Timer
pawn Код:
forward XP(playerid);
public XP(playerid)
{
   sharetimer[playerid] = 0;//lets you use the cmd again once the timer has ended
   SendClientMessage(playerid, -1, "You can use share XP again");
   return 1;
}
Let me know if this helps
Thanks For Help Dude! I Will Try It! +REP
Reply
#9

just use gettickcount

Код:
static tick;
if((GetTickCount() - tick) > 60000) //if one minute passed since the last time the command was used
{
	//your code
	tick = GetTickCount();
}
Reply
#10

using tickcount is better then SetTimerEx,
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)