Bug kick command on id 1 -
AlexGheorghe - 14.05.2017
Hello! I have a problem with kick command with id 1, even if the player is not connected command is still running and send message with " has been kicked by x. Reason: y".
Here is the code:
CMD:kick(playerid, params[])
{
if(pLogged[playerid] == 0) return LoginError(playerid);
new id, reason[100], string[100], playername[100], targetname[100];
if(PlayerInfo[playerid][pAdmin] >= 1)
{
if(sscanf(params, "ds[100]", id, reason)) return SendClientMessage(playerid, COLOR_SYNTAX, "Syntax: /kick [playerid] [reason].");
{
if(id != INVALID_PLAYER_ID)
{
if(id == playerid) return SendClientMessage(playerid, -1, "Error: You can't kick yourself.");
GetPlayerName(id, targetname, sizeof(targetname));
GetPlayerName(playerid, playername, sizeof(playername));
format(string, sizeof(string), "Kick: %s has been kicked by %s. Reason: %s", targetname, playername, reason);
SendClientMessageToAll(COLOR_KICK, string);
Kick(id);
}
else return SendClientMessage(playerid, COLOR_SYNTAX, "Error: Player not connected.");
}
}
else
{
AdminError(playerid);
}
return 1;
}
Re: Bug kick command on id 1 -
Toroi - 14.05.2017
The problem relies inside this statement
Код:
if(id != INVALID_PLAYER_ID)
INVALID_PLAYER_ID is defined as 65535, what that conditional is checking is not what you want to check there.
What you really want to check there is the returning value of the function
IsPlayerConnected, and if true continue with the rest of the function.
Re: Bug kick command on id 1 -
AlexGheorghe - 14.05.2017
That was the problem. Thank you very much!