PDA

View Full Version : IP Ban checking


JaKe Elite
07/05/2012, 01:39 AM
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

Yuryfury
07/05/2012, 03:08 AM
If you simply want a way to ban an IP, you can use the IP ban system built into RCON.

/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


dcmd_banip(playerid, params[])
{
new ip[32], adminname[MAX_PLAYER_NAME], banstring1[128];

if(IsPlayerAdmin(playerid)||IsPlayerYAdminLevel(pl ayerid,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;
}

JaKe Elite
07/05/2012, 03:39 AM
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 (c) 1997-2006, ITB CompuPhase


6 Errors.

ViniBorn
07/05/2012, 03:57 AM
Replace \ for another caracter ...


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 ");