Making a accurate ban system [HELP]
#1

Alright, i've been scripting a ban system and it works well, I am using this ban system to my Weapon Hack Anti-Cheat and it works great, Now, the thing i really want to improve to this system is the ban evading checking, the Check_Ban function object is not enough for me as it only reads the Banned var of the Player's account instead of checking the IP if it is banned.

Codes:

pawn Код:
stock Check_Ban(playerid)
{
    new string[2500];
    if(fexist(UserPath(playerid)))
    {
        pInfo[playerid][Banned] = dini_Int(UserPath(playerid), "Banned");
        format(pInfo[playerid][BanBy], 256, "%s", dini_Get(UserPath(playerid), "BanBy"));
        format(pInfo[playerid][BanReason], 256, "%s", dini_Get(UserPath(playerid), "BanReason"));
        format(pInfo[playerid][WhenBan], 256, "%s", dini_Get(UserPath(playerid), "WhenBan"));
        if(pInfo[playerid][Banned] == 1)
        {
            ClearBox(playerid);
       
            format(string, sizeof(string), ""grey"Sorry, But you are banned from San Andreas Chaos.\nBan Details:\n\n"red"Banned by "white"%s\n"red"Ban Reason "white"(%s)\n"red"Date "white"(%s)\n\n"grey"If you think it is a false ban, Please refer to "#SERVER_URL" and file a ban appeal.\nMake sure to take a screenshot of this (Press F8).", pInfo[playerid][BanBy], pInfo[playerid][BanReason], pInfo[playerid][WhenBan]);
            ShowPlayerDialog(playerid, DIALOG_BANS, DIALOG_STYLE_MSGBOX, ""red"Banned from SAC", string, "Close", "");
            SendClientMessage(playerid, COLOR_RED, "You are banned from the server.");
            format(string, sizeof(string), "Banned by: "white"%s, "red"Reason: "white"%s, "red"When: "white"%s", pInfo[playerid][BanBy], pInfo[playerid][BanReason], pInfo[playerid][WhenBan]);
            SendClientMessage(playerid, COLOR_RED, string);
            SendClientMessage(playerid, -1, "You have been kicked.");
            KickX(playerid);
            return 0;
        }
    }
    return 1;
}
stock AddBan(playerid = -1, targetid, reason[])
{
    new band, bany, banm;
    getdate(bany, banm, band);
    new string[190];

    if(playerid != -1)
    {
        if(fexist(UserPath(targetid)))
        {
            if(logged[targetid] == 1)
            {
                format(pInfo[targetid][BanBy], 256, "%s", GetName(playerid));
                format(pInfo[targetid][BanReason], 256, "%s", reason);
                format(pInfo[targetid][WhenBan], 256, "%d-%d-%d", banm, band, bany);

                ClearBox(targetid, 100);

                format(string, sizeof(string), "** "red"%s has been banned from the server by %s (%s)", GetName(targetid), GetName(playerid), reason);
                SendClientMessageToAll(-1, string);
               
                format(string, sizeof(string), "%s %s banned %s for %s (%s) (IP: %s)", GetA_Rank(playerid), GetName(playerid), GetName(targetid), reason, pInfo[targetid][WhenBan], GetIP(targetid));
                SaveLog("banlog", string);
               
                format(string, sizeof(string), "** "red"You have been banned from the server by %s for %s (%s)", GetName(playerid), reason, pInfo[targetid][WhenBan]);
                SendClientMessage(targetid, -1, string);
               
                SendClientMessage(targetid, -1, "If you think this is a wrongful ban, Visit us at "#SERVER_URL" and file a ban appeal.");
                SendClientMessage(targetid, -1, "Make sure to screenshot this ban for evidence. (Press F8 to take a screenshot)");
               
                pInfo[targetid][Banned] = 1;
               
                KickX(targetid);
            }
        }
    }
    else if(playerid == -1)
    {
        if(fexist(UserPath(targetid)))
        {
            if(logged[targetid] == 1)
            {
                format(pInfo[targetid][BanBy], 256, "Anticheat");
                format(pInfo[targetid][BanReason], 256, "%s", reason);
                format(pInfo[targetid][WhenBan], 256, "%d-%d-%d", banm, band, bany);

                ClearBox(playerid, 100);

                format(string, sizeof(string), "** "red"%s has been banned from the server by the Anticheat (%s)", GetName(targetid), reason);
                SendClientMessageToAll(-1, string);

                format(string, sizeof(string), "Anticheat banned %s for %s (%s) (IP: %s)", GetName(targetid), reason, pInfo[targetid][WhenBan], GetIP(targetid));
                SaveLog("banlog", string);

                format(string, sizeof(string), "** "red"You have been banned from the server by the Anticheat for %s (%s)", reason, pInfo[targetid][WhenBan]);
                SendClientMessage(targetid, -1, string);

                SendClientMessage(targetid, -1, "If you think this is a wrongful ban, Visit us at "#SERVER_URL" and file a ban appeal.");
                SendClientMessage(targetid, -1, "Make sure to screenshot this ban for evidence. (Press F8 to take a screenshot)");

                KickX(targetid);
            }
        }
    }
    return 1;
}
Now, the thing i want to improve here is that to ban the IP as-well adding it to a file, then if the player connects, it checks if the account is banned through Check_Ban, if it is not banned, we will move in checking if the IP matches on the banned IP, if it is banned then we will ban the IP including the account. For the unban, I also need help on removing the IP from the banned list if the player is unbanned .

Help me brothers.
Reply
#2

Well to be honest I've never worked with such things but I'll tell you something try when a player registers save his IP in his data file.

Then when someone registers/logs/connects to the server loop through all players IP(s) from the files and then check if that ban variable is "true" if it's true compare if the player who connected to the server has the same IP as the IP in the file that means the IP is banned. This might be outdated, hard, or how you call it but it just came up to my mind.

If you didn't understand me tell me I'll try to explain it more for you.
Reply
#3

Alright i got that, But the thing is, how do i remove the ban IP from the file for example

Код:
IP1
IP2
IP3
IP2 gets unban, How do i keep these IPs stored in the file?
Reply
#4

Well to answer your question I don't know but as I said no need of making a file which contains a whole server player IPs.
Instead in the player's data saving include his ip there then check if that player is banned then that IP is forbidden.

I'm on phone right now will provide an example later.
Reply
#5

Anyone?
Reply
#6

Make another file, 'banips' and save all banned ips there
then whenever anyone connects, try to match his ip with the one in 'banips', if it matches then ban him simple but maybe hard to script..
Reply
#7

I don't know how to remove something from a list, I'll try to search for an answer, I'll reply if I found one.

Here's another idea:
How about making a new folder called something like "bannedips" and then listing every IP as a new txt file.
Then if you want to unban, fremove.

Quote:
Originally Posted by PMH
Посмотреть сообщение
Make another file, 'banips' and save all banned ips there
then whenever anyone connects, try to match his ip with the one in 'banips', if it matches then ban him simple but maybe hard to script..
He wants to know how to remove an IP from a whole list of IPs.
Reply
#8

Quote:
Originally Posted by Stinged
Посмотреть сообщение
I don't know how to remove something from a list, I'll try to search for an answer, I'll reply if I found one.

Here's another idea:
How about making a new folder called something like "bannedips" and then listing every IP as a new txt file.
Then if you want to unban, fremove.



He wants to know how to remove an IP from a whole list of IPs.
then he should use Y_ini as it has function:
pawn Код:
new
    INI:ini = INI_Open("myini.ini");
INI_RemoveEntry(ini, "NAME");
INI_Close(ini);
Reply
#9

Quote:
Originally Posted by PMH
Посмотреть сообщение
then he should use Y_ini as it has function:
pawn Код:
new
    INI:ini = INI_Open("myini.ini");
INI_RemoveEntry(ini, "NAME");
INI_Close(ini);
And how is he going to add new IPs..
INI: Name = Value

While he wants to list IPs like
Код:
IP1
IP2
IP3
IP4
IP5
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)