Makin' different bans? [+Rep]
#1

Hi all!

I got a question: I wanna make different /ban commands: I want, that one bans a player's IP, one bans a player for a few hours (maximum 24), and another one for days...

I don't know how to do this, I also created my own one! Will this one ban the IP or what?

PHP код:
CMD:ban(playeridparams[])
{
        if(
PlayerInfo[playerid][pAdmin] >=5) {
        new 
PID;
        new 
reason[64];
        new 
str[128];
        new 
PName[MAX_PLAYER_NAME], AName[MAX_PLAYER_NAME];
        
GetPlayerName(playeridANamesizeof(AName));
        
GetPlayerName(PIDPNamesizeof(PName));
        if(
sscanf(params"us[64]"PIDreason)) return SendClientMessage(playeridCOLOR_YELLOW"USAGE: /ban [playerid] [reason]");
        
        if(!
IsPlayerConnected(PID))
            return 
SendClientMessage(playeridCOLOR_YELLOW"Player is not connected!");
            
        
format(strsizeof(str), "'%s' has been banned by administrator '%s'. Reason: %s "PNameANamereason);
        
SendClientMessageToAll(COLOR_REDstr);
        
Ban(PID);
        }
     else
     {
        
SendClientMessage(playeridCOLOR_RED"You have to be level 5 to use that command!");
     }
     return 
1;

Also, do I have to create the file samp.ban somewhere?

Thank you!
Reply
#2

The one you have posted there will only ban the player's IP.

It utilizes the standard SA-MP RCON ban system, which will save the IP inside the samp.ban file in the server's root directory.

If you want custom bans, you will need to script a completely custom ban system.

If you REALLY don't wanna script that, you could always do something messy by storing a copy of all processed bans in a separate, server-accessible file with timelimits (ew) and have the script RCON unban them once the time has expired, but personally i'd say it'd be easier just to script a simple sqlite ban-system.

Have you had any experience with sqlite? or PAWN in great detail?
Reply
#3

Nope, I didn't! So if I wanna script an hours-ban or tempban, what then? ><
Reply
#4

You don't have to make a samp.ban, you could just create a server log and store all names and IP addresses in it. It's not hard to do, but if you need help then I'll assist you with it.

With the temporary bans, I wouldn't know how to do it as that is pretty advanced. Sorry.
Reply
#5

Already tested my own command, samp.ban will be created automatically, and my IP is in it! But, when I deleted it from there, I still was banned...I had to delete the whole file!:O
Reply
#6

I highly recommend using MySQL for storing the bans.

You can easily make temporary bans, store reasons, access them from PHP for instance, so many things you can do.

There is one downside though:
You need to be quite comfortable with both MySQL and Pawn. You don't want to get incorrectly working bans or security vulnerabilities.
Reply
#7

Well i think https://sampforum.blast.hk/showthread.php?tid=274111 is good for banning people for temp
Reply
#8

Yeah...But I don't want a FS, you know? 'Cause there I gotta be RCON, and I want that even level-4-players are able to ban....
Reply
#9

IP Ban:
pawn Код:
CMD:banip(playerid, params[])
{
        if(PlayerInfo[playerid][pAdmin] >=5) {
        new reason[64];
        new IP[20]
        new str[128];
        new AName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, AName, sizeof(AName));
        if(sscanf(params, "ss",reason,IP)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /banip [ip] [reason]");              
        format(str, sizeof(str), "IP: '%s' has been banned by administrator '%s'. Reason: %s ", IP, AName, reason);
        SendClientMessageToAll(COLOR_RED, str);
        new bannedip[30];
        format(bannedip,sizeof(bannedip),"banip %s",IP);        
        SendRconCommand(bannedip);
        }
        else
        {
          SendClientMessage(playerid, COLOR_RED, "You have to be level 5 to use that command!");
        }
     return 1;
}
Should work, not tested!
Reply
#10

import the FS data to your Game mode script
that is so simple
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)