Need help with my /ban command.
#1

Fixed!
Reply
#2

PHP код:
/rcon reloadbans reloads the samp.ban where the banned IP addresses are storedShould be used after unbanning and IP address
Reply
#3

samp.ban is the default sort of file for the BanEx and Ban commands, that is how the default banning commands work, to get a system that doesn't work that way, takes quite a bit more effort, take mine, for example, the one below is a timed ban system (I actually dunno if it works, but I would think it does...) Which saves the bans to a mysql database and kicks players, this means it creates it's own database and logs, so if I were to put in an unban command (I don't have one, as I have mine on time based system) I could unban a user quickly, it, however, has to cross-reference the users when they log in to make sure they aren't banned, and if they are, kick them if their bantime hasn't expired.

Код:
YCMD:ban(playerid, params[], help) {
	if(help) return SPD(playerid,dHelp,DSM,"Help","HELP: Bans a player.","OK","");
	new tID, reason[126],hours,secs,days,ubTime;
	if(sscanf(params, "udS(No Reason Given)[126]",tID,hours,reason)) return SCM(playerid,SCM_C_RED,"USAGE: \"/ban [playerid][hours](Optional: reason)\"");
	if(tID == INVALID_PLAYER_ID) return Error(playerid,"Player not found!");
	if(tID == playerid) return Error(playerid,"Cant ban yourself!");
	if(pInfo[tID][pAdmin] > pInfo[playerid][pAdmin]) return Error(playerid,"You cant ban an admin higher than your rank!");
	if(hours < 1 || hours > 720) return Error(playerid,"Hours must be between 1 and 720(30 days)");
	new loopHours = 0;
	secs = hours*3600;
	while(loopHours != hours) {
	    if(loopHours == 24) {
			days++;
			hours -= 24; }
		loopHours++; }
	ubTime = gettime()+secs;
	format(fquery,sizeof(fquery),"INSERT INTO `PlayerBans` (`BanID`,`PlayerName`,`IP`,`Administrator`,`Reason`,`BanTime`,`UnbanTime`) VALUES(0,'%s','%s','%s','%s',%d,%d)",
	Name[tID],IP[tID],Name[playerid],gettime(),ubTime);
	mysql_query(mysql,fquery);
	if(days > 0) SCFMTA(SCM_C_YELLOW,"%s(%d) has banned %s(%d) for %d days and %d hours. Reason: %s",Name[playerid],playerid,Name[tID],tID,days,hours,reason);
	else SCFMTA(SCM_C_YELLOW,"%s(%d) has banned %s(%d) for %d hours. Reason: %s",Name[playerid],playerid,Name[tID],tID,hours,reason);
	KickWithDelay(tID);
	return 1; }
That's the Banning command, this cross-references it with the player data on login...

Код:
	format(fquery,sizeof(fquery), "SELECT UnbanTime FROM `PlayerBans` WHERE IP = '%s'",IP[playerid]);
	mysql_tquery(mysql,fquery,"CheckBans","i",playerid);
And the function it calls:

Код:
public CheckBans(playerid) {
	new rows, fields;
	cache_get_data(rows,fields,mysql);
	if(rows) {
	    new ubTime = cache_get_field_content_int(0, "UnbanTime");
	    if(ubTime > gettime()) {
	        SCM(playerid,SCM_C_RED,"You are currently banned from this server!");
	        KickWithDelay(playerid); }
	} return 1; }
Naturally, however, this would work too, for your unban command (part of it: )

Код:
SendRconCommand("reloadbans");
Reply
#4

Fixed!
Reply
#5

Yeah!

Quote:
Originally Posted by Zonoya
Посмотреть сообщение
Код:
SendRconCommand("reloadbans");
Reply
#6

Fixed!
Reply
#7

You wouldn't have to change anything really, it's a good system setup in all honesty for perma-bans, just on your unban command, you have to unban an ip, which is pretty hard to do because ingame admins probably wouldn't know the ip, which is why a user created ban system is much better, for my ban system, I can just use a mysql query to unban a certain player so long as I know their name by doing something like this:

Код:
format(fquery,sizeof(fquery),"UPDATE `PlayerBans`SET `UnbanTime`=0 WHERE `Name`='%s'",Name[tID]);
mysql_query(mysql,fquery);
Reply
#8

Fixed!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)