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;
}