2021-03-29, 09:32 PM
(This post was last modified: 2021-03-29, 09:33 PM by CrypticSin.)
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;
}
Code: CMD:kick(playerid, params[])
{
new target_id, reason[24], kick_string[200];
if (PlayerInfo[playerid][pAdmin] < 1) return SCM(playerid, COLOR_RED, "You are not allowed to use this command!");
if (sscanf(params, "us[24]", target_id, reason)) return SCM(playerid, COLOR_RED, "Usage: /kick [playerid/name] [reason]");
if (!IsPlayerConnected(target_id) return SCM(playerid, COLOR_RED, "Player not found.");
if (PlayerInfo[target_id][pAdmin] >= 1) return SCM(playerid, COLOR_RED, "You are not allowed to kick admins.");
format(kick_string, 200, "%s [%i] has been kicked by %s [%i] due to %s", ReturnName(target_id), target_id, ReturnName(playerid), playerid);
SendClientMessageToAll(COLOR_RED, kick_string);
format(kick_string, 200, "You have been kicked from TWDZS. The Admin who kicked you is: %s", ReturnName(playerid));
SendClientMessage(target_id, COLOR_RED, kick_string);
SendClientMessage(target_id, COLOR_ORANGE, "If you think this kick is unfair complain at www.domain.net");
Kick(target_id);
return 1;
}
This should work, but I didn't test it.
2021-04-02, 10:27 AM
(This post was last modified: 2021-04-02, 10:27 AM by Awide.)
You dont need curly-brackets around this part:
Code: {
? ? ? ? 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);
}
Check out Desolation Roleplay, where zombie AI and scavenging is bothered by player bandits!
(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.
(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.
|