CMD:ban(playerid, params[])
{
if(!IsAdmin(playerid, 1)) return ErrorMsg(playerid);
new target;
new reason = Info[playerid][BanReason];
if(sscanf(params, "rs[32]", target, reason)) return Usage(playerid, "/ban [player] [reason]");
if(!IsPlayerConnected(target)) return SendClientMessage(playerid, COLOR_RED, "ERROR: Player is not connected");
new string[128];
format(string, sizeof(string), "[ADMIN BAN]: %s has been banned from the server - %s", Name(target), reason);
SendClientMessageToAll(COLOR_ADMIN, string);
IRC_GroupSay(gGroupID, IRC_CHANNEL, string);
format(string,sizeof(string), "[ADMIN CMD]: %s[%i] has banned %s[%i] - %s",Name(playerid),playerid,Name(target),target,reason);
IRC_GroupSay(gGroupID, IRC_CHANNEL_ADMIN, string);
format(string,sizeof(string), "~w~Banned from the server~n~~r~Reason: %s",reason);
TextDrawSetString(AnnText, string);
TextDrawShowForPlayer(target, AnnText);
BanPlayer(target);
return 1;
}
stock BanPlayer(playerid)
{
new INI:File = INI_Open(UserPath(playerid));
INI_WriteInt(File,"Banned",1);
INI_WriteInt(File,"BanReason",Info[playerid][BanReason]);
INI_Close(File);
Kick(playerid);
return 1;
}
if(sscanf(params, "us[32]", target, reason)) return Usage(playerid, "/ban [player] [reason]");
if(target == INVALID_PLAYER_ID)
[ADMIN BAN]: has been banned from the server - reason |
That's to do with the rest of the banning process, the original problem was fixed.
In your ban stock, instead of opening the player file, just do Info[playerid][Banned] = 1 and format your BanReason too. Then when they disconnect it'll write to their file anyway. Also, you need to have a timer before the player actually gets kicked, read about it here. https://sampwiki.blast.hk/wiki/Kick |