[Tutorial] Simple anti-log spam
#1

Welcome to my tutorial, this tutorial will show you how to make a basic anti log-spam for admin commands system.

What this does, is check if the player is trying to submit admin actions, it'll tell the server, then it'll kick the player.

Firstly we must define Zeex's CMD processor. Z-CMD.

Link for the include:
https://sampforum.blast.hk/showthread.php?tid=91354

We need SSCANF2 too, made by *****.
http://forum.sa-mp.com/showthread.ph...hlight=sscanf2


alright, firstly we must define the variable to store data into, make sure it's above our functions or it won't work! (because it is not reading the definition of the variable first).

pawn Код:
new logSpam[MAX_PLAYERS]
under OnPlayerConnect you might want to reset the variable to 0.
pawn Код:
logSpam[playerid] = 0;
(Only do that if you want it to reset that session)

Now, let's make our command, I'll choose the kick command.

pawn Код:
CMD:ban(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] > 2)
    {
    }
    else
    {
       
    }
}
That is the structure of our command. (Change the PlayerInfo and the pAdmin to match your enumerations!

We must now make a few definitions in the command, then put it into the sscanf function.
pawn Код:
CMD:ban(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] > 2)
    {
        new msg[128], string[128];
        if(sscanf(params, us[128]), playerid, msg) return SendClientMessage(playerid, -1, "Usage: /ban [playerid] [reason]");
        {
        }
    }
    else
    {
       
    }
}
Now, I'll explain what the sscanf function is doing.

PARAMS means the parameter of the command, basically if you want anything else alongside that.
"us[128]" means check/split for the playerid ("u") and for the variable msg ("s[128]"). (msg=reason)

Then it returns the message.

Let's put some code into it, for now we'll just use 'BanEx'.

P.S: 'id' is our target.

pawn Код:
CMD:ban(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] > 2)
    {
        new msg[128], string[128], id;
        if(sscanf(params, us[128]), playerid, msg) return SendClientMessage(playerid, -1, "Usage: /ban [playerid] [reason]");
        {
            BanEx(id, msg);
            format(string, sizeof(string), "[ANNOUNCEMENT] A user has been banned from the server! [Reason: %s]", msg);
            SendClientMessageToAll(-1, string);
        }
    }
    else
    {
        logSpam[playerid]++;
        if(logSpam[playerid] > 2)
        {
            new pname;
            GetPlayerName(playerid, pname, sizeof(pname));
            Kick(playerid);
            printf("%s has just been kicked due to spamming of an admin command.", pname);
        }
    }
}
Alright, we've sorted that.

In the 'else' statement, that is where we put our variable.

It is self explanitory, but for subernewbies here is an explination:

We've just added 1 to the user's variable with the symbol "++", meaning "add one". Then we asked the server if the variable returns a value of 3, if so then kick him. Easy.

Now we're done.

Simple function, though useful for catching people who are trying to misuse commands.

~ Mitchy

Please leave some feedback and things that i could improve on!
Reply
#2

nice
Reply
#3

Thanks also, sorry bout the wrong section i did it wrong place sorry
Reply
#4

Well this is a no tutorials? put it in the location of tutorials contributions not like this very good congratulations!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)