2021-04-03, 10:08 PM
(2021-04-03, 07:48 PM)ImOver Wrote:(2021-03-29, 09:32 PM)CrypticSin Wrote: Hi i've written a admin command for /kick and im currently multi logging into my server to test it out.
Everything seems like it's working when i kick my 2nd character but, it doesn't actually kick the player even though the message comes up that?they've been kicked?
Could this be because im accessing the server on two different accounts with?the same PC and the same IP??
Or if a randomer from a different ip joined would it work??
Code:
PHP Code:CMD:kick(playerid, params[])
{
? ? if(PlayerInfo[playerid][pAdmin] < 1)
? ? return SCM(playerid, COLOR_RED, "You are not allowed to use this command");
new playerb, reason[24];
new fstr[200];
if(sscanf(params, "us[24]", playerb, reason))
? ? return SCM(playerid, COLOR_RED, "Usage: /kick [playerid/name] [reason]");
? ?
? ? if(!IsPlayerConnected(playerb))
return SendClientMessage(playerid, COLOR_RED, "Player not found.");
? ?
? ? if(PlayerInfo[playerb][pAdmin] >= 1)
return SendClientMessage(playerid, COLOR_RED, "You cant kick admins.");
? ? {
? ? ? ? format(fstr, sizeof(fstr), "Admin %s (%d) has kicked %s [%d] from TWDZS - Reason: %s", ReturnName(playerid), playerid, ReturnName(playerb), playerb, reason);
? ? ? ? SendClientMessageToAll(COLOR_RED, fstr);
? ? ? ? PlayerInfo[playerb][pKicks] ;
? ? ? ? GameTextForPlayer(playerb, "~r~Kicked", 5000, 5);
? ? ? ? format(fstr, sizeof(fstr), "You have been kicked from TWDZS. You were kicked by admin %s.", ReturnName(playerid));
? ? ? ? SendClientMessage(playerb, COLOR_RED, fstr);
? ? ? ? SendClientMessage(playerb, COLOR_ORANGE, "If you think this kick is unfair complain at www.domain.net");
? ? ? ? KickEx(playerb);
? ? }
? ? return true;
}
Hey. Firstly remove "SCM". Just don't use it, it's really bad to use SCM, even if we talk about programming in general it's bad to use short function names.
I've fixed the problem. But sure, i'll stop using the shortcut.