Makin' different bans? [+Rep] -
Twisted_Insane - 11.02.2012
Hi all!
I got a question: I wanna make different /ban commands: I want, that one bans a player's IP, one bans a player for a few hours (maximum 24), and another one for days...
I don't know how to do this, I also created my own one! Will this one ban the IP or what?
PHP код:
CMD:ban(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >=5) {
new PID;
new reason[64];
new str[128];
new PName[MAX_PLAYER_NAME], AName[MAX_PLAYER_NAME];
GetPlayerName(playerid, AName, sizeof(AName));
GetPlayerName(PID, PName, sizeof(PName));
if(sscanf(params, "us[64]", PID, reason)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /ban [playerid] [reason]");
if(!IsPlayerConnected(PID))
return SendClientMessage(playerid, COLOR_YELLOW, "Player is not connected!");
format(str, sizeof(str), "'%s' has been banned by administrator '%s'. Reason: %s ", PName, AName, reason);
SendClientMessageToAll(COLOR_RED, str);
Ban(PID);
}
else
{
SendClientMessage(playerid, COLOR_RED, "You have to be level 5 to use that command!");
}
return 1;
}
Also, do I have to create the file samp.ban somewhere?
Thank you!
Re: Makin' different bans? [+Rep] -
Rob_Maate - 11.02.2012
The one you have posted there will only ban the player's IP.
It utilizes the standard SA-MP RCON ban system, which will save the IP inside the samp.ban file in the server's root directory.
If you want custom bans, you will need to script a completely custom ban system.
If you REALLY don't wanna script that, you could always do something messy by storing a copy of all processed bans in a separate, server-accessible file with timelimits (ew) and have the script RCON unban them once the time has expired, but personally i'd say it'd be easier just to script a simple sqlite ban-system.
Have you had any experience with sqlite? or PAWN in great detail?
Re: Makin' different bans? [+Rep] -
Twisted_Insane - 11.02.2012
Nope, I didn't! So if I wanna script an hours-ban or tempban, what then? ><
Re: Makin' different bans? [+Rep] -
Mosslah - 11.02.2012
You don't have to make a samp.ban, you could just create a server log and store all names and IP addresses in it. It's not hard to do, but if you need help then I'll assist you with it.
With the temporary bans, I wouldn't know how to do it as that is pretty advanced. Sorry.
Re: Makin' different bans? [+Rep] -
Twisted_Insane - 11.02.2012
Already tested my own command, samp.ban will be created automatically, and my IP is in it! But, when I deleted it from there, I still was banned...I had to delete the whole file!:O
Re: Makin' different bans? [+Rep] -
Johnson_boy - 11.02.2012
I highly recommend using MySQL for storing the bans.
You can easily make temporary bans, store reasons, access them from PHP for instance, so many things you can do.
There is one downside though:
You need to be quite comfortable with both MySQL and Pawn. You don't want to get incorrectly working bans or security vulnerabilities.
Re: Makin' different bans? [+Rep] -
Tanush123 - 11.02.2012
Well i think
https://sampforum.blast.hk/showthread.php?tid=274111 is good for banning people for temp
Re: Makin' different bans? [+Rep] -
Twisted_Insane - 12.02.2012
Yeah...But I don't want a FS, you know? 'Cause there I gotta be RCON, and I want that even level-4-players are able to ban....
Re: Makin' different bans? [+Rep] -
fiki574 - 12.02.2012
IP Ban:
pawn Код:
CMD:banip(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >=5) {
new reason[64];
new IP[20]
new str[128];
new AName[MAX_PLAYER_NAME];
GetPlayerName(playerid, AName, sizeof(AName));
if(sscanf(params, "ss",reason,IP)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /banip [ip] [reason]");
format(str, sizeof(str), "IP: '%s' has been banned by administrator '%s'. Reason: %s ", IP, AName, reason);
SendClientMessageToAll(COLOR_RED, str);
new bannedip[30];
format(bannedip,sizeof(bannedip),"banip %s",IP);
SendRconCommand(bannedip);
}
else
{
SendClientMessage(playerid, COLOR_RED, "You have to be level 5 to use that command!");
}
return 1;
}
Should work, not tested!
Re: Makin' different bans? [+Rep] -
RicaNiel - 12.02.2012
import the FS data to your Game mode script
that is so simple