16.03.2015, 18:22
(
Последний раз редактировалось Sc0pion; 17.08.2017 в 10:55.
)
Fixed!
/rcon reloadbans - reloads the samp.ban where the banned IP addresses are stored. Should be used after unbanning and IP address.
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; }
format(fquery,sizeof(fquery), "SELECT UnbanTime FROM `PlayerBans` WHERE IP = '%s'",IP[playerid]); mysql_tquery(mysql,fquery,"CheckBans","i",playerid);
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; }
SendRconCommand("reloadbans");
format(fquery,sizeof(fquery),"UPDATE `PlayerBans`SET `UnbanTime`=0 WHERE `Name`='%s'",Name[tID]); mysql_query(mysql,fquery);