03.08.2016, 12:09
When I ban someone, he can still join the server and login.
Where is the problem?
Where is the problem?
PHP код:
CMD:ban(playerid, params[])
{
LevelCheck(playerid, 1);
new target, reason[35], days;
if(sscanf(params, "is[35]I(0)", target, reason, days)) return Usage(playerid, "ban [playerid] [reason] [days(0 for permanent ban)]");
if(!IsPlayerConnected(target)) return Error(playerid, "The specified player is not connected, use /oban instead.");
if(target == playerid) return Error(playerid, "You cannot ban yourself.");
if(GetLevel(playerid) < GetLevel(target)) return Error(playerid, "You cannot use this command on higher level admin.");
if(days < 0) return Error(playerid, "Invalid days, must be greater than 0 for temp ban, or 0 for permanent ban.");
if(strlen(reason) < 3 || strlen(reason) > 35) return Error(playerid, "Invalid reason length, must be b/w 0-35 characters.");
new bandate[18], date[3], time;
getdate(date[0], date[1], date[2]);
format(bandate, sizeof(bandate), "%02i/%02i/%i", date[2], date[1], date[0]);
if(days == 0) time = 0;
else time = ((days * 24 * 60 * 60) + gettime());
new handle = SQL::Open(SQL::INSERT, ""BANS_TABLE"");
SQL::ToggleAutoIncrement(handle, true);
SQL::WriteString(handle, "ban_username", GetName(target));
SQL::WriteString(handle, "ban_ip", GetIP(target));
SQL::WriteString(handle, "ban_by", GetName(playerid));
SQL::WriteString(handle, "ban_on", bandate);
SQL::WriteString(handle, "ban_reason", reason);
SQL::WriteInt(handle, "ban_expire", time);
SQL::Close(handle);
if(days == 0)
{
new string[144];
format(string, sizeof(string), "* %s(%i) has been banned by Admin %s(%d) "orange"[Reason: %s]", GetName(target), target, GetName(playerid), playerid, reason);
SendClientMessage(target, COLOR_RED, string);
#if defined SAVE_LOGS
SaveLog("bans.txt", string);
#endif
}
else
{
new string[258];
format(string, sizeof(string), "* %s(%i) has been temp banned by Admin %s(%d) "orange"[Reason: %s] [Days: %i]", GetName(target), target, GetName(playerid), playerid, reason, days);
SendClientMessage(target, COLOR_RED, string);
#if defined SAVE_LOGS
SaveLog("bans.txt", string);
#endif
format(string, sizeof(string), "* Temp banned for %i days "orange"[Unban on %s]", days, ConvertTime(time));
SendClientMessage(target, COLOR_RED, string);
}
PlayerPlaySound(target, 1057, 0.0, 0.0, 0.0);
PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
DelayKick(target);
return 1;
}