25.04.2013, 15:18
Well, today KiNG3 scripted /kick for me and I script /ban, but when I tested in the server, it shows the message but it didn't kick me, why?
Kick and Ban:
Anyone has idea to fix it?
Kick and Ban:
pawn Код:
CMD:kick(playerid,params[])
{
new string[128], name[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME]; // iu've never used +1 after MAX_PLAYERNAME
new targetid, reason;
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
GetPlayerName(targetid, name2, MAX_PLAYER_NAME);
if(IsPlayerAdmin(playerid) || pInfo[playerid][ALevel] > 1)
{
if(sscanf(params,"us[128]", targetid, reason)) return SendClientMessage(playerid, yellow, "[USAGE]: /kick [id/name] [reason]");
else if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, red, "[ERROR]: The player is not connected!");
else if(targetid <= pInfo[playerid][ALevel]) return SendClientMessage(playerid, red, "[ERROR]: Hey, what are you trying to do?");
format(string, sizeof(string), "[INFO]:{FFFFFF} Administrator %s has kicked %s (Reason: %s)", name, name2, reason);
SendClientMessageToAll(COLOR_BLUE, string);
Kick(targetid);
}
else return SendClientMessage(playerid, red, "[ERROR]: You have no permission to use this command.");
return 1;
}
CMD:ban(playerid,params[])
{
new string[128], name[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME];
new targetid, reason;
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
GetPlayerName(targetid, name2, MAX_PLAYER_NAME);
if(IsPlayerAdmin(playerid) || pInfo[playerid][ALevel] > 2)
{
if(sscanf(params,"us[128]", targetid, reason)) return SendClientMessage(playerid, yellow, "[USAGE]: /ban [id/name] [reason]");
else if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, red, "[ERROR]: The player is not connected!");
else if(targetid <= pInfo[playerid][ALevel]) return SendClientMessage(playerid, red, "[ERROR]: Hey, what are you trying to do?");
format(string, sizeof(string), "[INFO]:{FFFFFF} Administrator %s has banned %s (Reason: %s)", name, name2, reason);
SendClientMessageToAll(COLOR_BLUE, string);
Kick(targetid);
{
new INI:file = INI_Open(Path(targetid));
INI_WriteInt(file, "Banned", 1);
INI_Close(file);
}
}
else return SendClientMessage(playerid, red, "[ERROR]: You have no permission to use this command.");
return 1;
}