IP Ban checking
#1

Creating IP Ban Checking is a great idea so ban evader cannot pass the server (they can if their ip can change)

Saving IP in Y_INI using INI_WriteString is good idea too but.
i want to know how to check if the IP is banned.

Ex.

my IP in my server files is

Код:
IP = 192.168.1.100
and if the ip is banned using by /ban or anticheat, when he connects again he cannot pass.

How do i do that
Reply
#2

If you simply want a way to ban an IP, you can use the IP ban system built into RCON.
pawn Код:
/rcon banip 192.168.1.100
It seems to me though, that you want to make your own ban system using Y_INI. I made an admin system through dini, that should be a good example.

- I make a file for every IP banned. (ex. 192.168.1.100.ini)
- save stuff like reason, admin, day of ban to the file
- If the file exists, Kick the player OnPlayerConnect
- delete the file to "unban" the player

pawn Код:
dcmd_banip(playerid, params[])
{
    new ip[32], adminname[MAX_PLAYER_NAME], banstring1[128];

    if(IsPlayerAdmin(playerid)||IsPlayerYAdminLevel(playerid,3))
    {
        if (sscanf(params, "z", ip)) SendClientMessage(playerid, ORANGE, "Server: Usage: \"/banip [ip]\"");

        else
        {
            new file[256];
            format(file,256,"YAdmin/Bans/%s.ban",ip);
            if(dini_Exists(file))
            {
                SendClientMessage(playerid, ORANGE, "Server: This IP Is Already Banned!");
            }
            else
            {
                GetPlayerName(playerid,adminname,MAX_PLAYER_NAME);
                format(banstring1,128,"Server: Administrator %s[%i] has banned the IP %s",adminname,playerid,ip);
                SendClientMessageToAll(ORANGE, banstring1);

                new date[128],month,day,year;
                getdate(year,month,day);
                format(date,64,"%i/%i/%i",month,day,year);

                dini_Create(file);
                dini_Set(file,"Player","Not Available");
                dini_Set(file,"BanReason","Not Available");
                dini_Set(file,"Date",date);
                dini_Set(file,"IP",ip);
                dini_Set(file,"Admin",adminname);
            }
        }
    }
    else
    {
        SendClientMessage(playerid, ORANGE, "Server: Only Certain Level Admins Can Use This Command!");
    }
    return 1;
}
Reply
#3

I need another help i cannot seem to see the error here

Код:
main()
{
	print("\n___________     ________      __________  ");
	print("/  __   __  \    /  ______|    |  ______  \ ");
	print("| |  \ /  | |    | |           | |      | | ");
	print("| |  | |  | |    | |  ___      | |      | | ");
	print("| |  | |  | |    | | |_  |     | |______| | ");
	print("| |  | |  | |    | |   | |     | ________/  ");
	print("| |  | |  | |    | |___| |     | |          ");
	print("| |  | |  | |    \_______|     | |          ");
	print(" -    -    -                    -           ");
	print("\n ");
	print("\n ");
	print("____________________________________________________ ");
	print("\n ");
	print("Mini Game Play ");
	print("\n ");
	print("\n ");
	print("made by Romel Rowan\n ");
}
ERROR:

Код:
C:\Documents and Settings\Romel\My Documents\MGP GM\gamemodes\MGP.pwn(40) : error 027: invalid character constant
C:\Documents and Settings\Romel\My Documents\MGP GM\gamemodes\MGP.pwn(40) : error 027: invalid character constant
C:\Documents and Settings\Romel\My Documents\MGP GM\gamemodes\MGP.pwn(41) : error 027: invalid character constant
C:\Documents and Settings\Romel\My Documents\MGP GM\gamemodes\MGP.pwn(41) : error 027: invalid character constant
C:\Documents and Settings\Romel\My Documents\MGP GM\gamemodes\MGP.pwn(46) : error 027: invalid character constant
C:\Documents and Settings\Romel\My Documents\MGP GM\gamemodes\MGP.pwn(46) : error 027: invalid character constant
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


6 Errors.
Reply
#4

Replace \ for another caracter ...

pawn Код:
print("\n___________     ________      __________  ");
print("/  __   __  |    /  ______|    |  ______  | ");
print("| |  | /  | |    | |           | |      | | ");
print("| |  | |  | |    | |  ___      | |      | | ");
print("| |  | |  | |    | | |_  |     | |______| | ");
print("| |  | |  | |    | |   | |     | ________/  ");
print("| |  | |  | |    | |___| |     | |          ");
print("| |  | |  | |    |_______|     | |          ");
print(" -    -    -                    -           ");
print("\n ");
print("\n ");
print("____________________________________________________ ");
print("\n ");
print("Mini Game Play ");
print("\n ");
print("\n ");
print("made by Romel Rowan\n ");
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)