IP address ban
#1

How to check if players IP address is banned?
I want to replace default SA-MP text (You are banned from this server) with something else.
Reply
#2

You using mysql or files?
Reply
#3

samp.ban must be in Gamemode Folder
Reply
#4

Quote:
Originally Posted by Raimis_R
View Post
You using mysql or files?
MySQL
Reply
#5

if you using samp.ban just open it with notepad and delete his ip if want unban him i hope this helped
Reply
#6

You can make your own system, but it will give the warning "Server closed connection" anyway.

Here's a method how to make your own IP ban system.
Create a table "ipbans", within that table create a field "ip", varchar 16 characters.
Then create a command, e.g /banip [playerid/PartOfName] (using ZCMD):
pawn Code:
CMD:banip(playerid, params[])
{
    new query[128], giveplayerid, IP[16];
    if(IsPlayerAdmin(playerid)) // Checks if the player is a RCON admin
    {
        if(sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, -1, "Usage: /ban [Playerid/PartOfName]");
        if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, -1, "This player is not connected.");
        GetPlayerIp(giveplayerid, IP, sizeof(IP));
        format(query, sizeof(query), "INSERT INTO `ipbans` (`ip`) VALUES ('%s')", IP);
        mysql_query(query);
        SendClientMessage(giveplayerid, -1, "You are banned, bai.");
        Kick(giveplayerid);
    }
    else
    {
        SendClientMessage(playerid, -1, "You are not an admin");
    }
    return 1;
}
Somewhere in your script:
pawn Code:
stock IsPlayerBanned(playerid)
{
    new query[128], ip[16];
    GetPlayerIp(playerid, ip, sizeof(ip));
    format(query, sizeof(query), "SELECT * FROM `ipbans` WHERE `ip` = '%s'", ip);
    mysql_query(query);
    mysql_store_result();
    if(mysql_num_rows() == 0)
    {
        return 0; // He's not banned
    }
    mysql_free_result();
    return 1; // Yes he's banned
}
At OnPlayerConnect:
pawn Code:
if(IsPlayerBanned(playerid))
{
    SendClientMessage(playerid, -1, "You're banned, bai bai");
    Kick(playerid);
    return 1;
}
I recommend you to use the normal Ban(playerid); function though.
Good luck
Reply
#7

Take a look at this script: https://sampforum.blast.hk/showthread.php?tid=186695
pawn Code:
public rplayer_OnConnect(playerid)
{
    new string[128], fstring[288], IP[16];
    GetPlayerIp(playerid, IP, 16);
    GetPlayerName(playerid, kPlayerName[playerid], MAX_PLAYER_NAME);
    format(fstring, sizeof(fstring), "Bans/%s.ban", IP);
    if(dini_Exists(fstring)){
        format(string, sizeof(string), "YOU ARE BANNED! Reason: %s", dini_Get(fstring, "BanReason"));
        SendClientMessage(playerid, COLOR_RED, string);
        Kick(playerid);
        return 1;
    }
    return 1;
}
So instead of "You have been banned from this server" you'll see "YOU ARE BANNED! Reason: {reason}"
I wouldn't use the include itself if I was you, because my server crashed once (only once) with it. Just take a look at the script and try to put it in your gamemode or filterscript.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)