IP address ban - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: IP address ban (
/showthread.php?tid=257790)
IP address ban -
Pooh7 - 27.05.2011
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.
Re: IP address ban -
Raimis_R - 27.05.2011
You using mysql or files?
Re: IP address ban -
rati555 - 27.05.2011
samp.ban must be in Gamemode Folder
Re: IP address ban -
Pooh7 - 27.05.2011
Quote:
Originally Posted by Raimis_R
You using mysql or files?
|
MySQL
Re: IP address ban -
ironmenpr17 - 27.05.2011
if you using samp.ban just open it with notepad and delete his ip if want unban him i hope this helped
Re: IP address ban -
Biesmen - 27.05.2011
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
Re: IP address ban -
Kwarde - 27.05.2011
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.