(1+ REP) Anti Command SPAM
#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


Messages In This Thread
(1+ REP) Anti Command SPAM - by XGreen - 18.08.2014, 00:04
Re: (1+ REP) Anti Command SPAM - by XGreen - 18.08.2014, 00:23
Re: (1+ REP) Anti Command SPAM - by anou1 - 18.08.2014, 00:53
Re: (1+ REP) Anti Command SPAM - by NewbieTester - 18.08.2014, 01:43
Re: (1+ REP) Anti Command SPAM - by XGreen - 18.08.2014, 02:33
Re: (1+ REP) Anti Command SPAM - by XGreen - 18.08.2014, 02:39
Re: (1+ REP) Anti Command SPAM - by gtasarules14 - 18.08.2014, 03:11
Re: (1+ REP) Anti Command SPAM - by XGreen - 18.08.2014, 13:41
Re: (1+ REP) Anti Command SPAM - by Ada32 - 18.08.2014, 14:29
Re: (1+ REP) Anti Command SPAM - by Sarra - 18.08.2014, 15:29

Forum Jump:


Users browsing this thread: 2 Guest(s)