open.mp forum
[Pawn] Not sure if my /kick works? - Printable Version

+ open.mp forum (https://forum.open.mp)
-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3)
--- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10)
--- Thread: [Pawn] Not sure if my /kick works? (/showthread.php?tid=1819)



Not sure if my /kick works? - CrypticSin - 2021-03-29

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(playeridparams[])

{

? ? if(
PlayerInfo[playerid][pAdmin] < 1)

? ? return 
SCM(playeridCOLOR_RED"You are not allowed to use this command");



new 
playerbreason[24];

new 
fstr[200];

if(
sscanf(params"us[24]"playerbreason))

? ? return 
SCM(playeridCOLOR_RED"Usage: /kick [playerid/name] [reason]");

? ? 

? ? if(!
IsPlayerConnected(playerb))

return 
SendClientMessage(playeridCOLOR_RED"Player not found.");

? ? 

? ? if(
PlayerInfo[playerb][pAdmin] >= 1)

return 
SendClientMessage(playeridCOLOR_RED"You cant kick admins.");

? ? {

? ? ? ? 
format(fstrsizeof(fstr), "Admin %s (%d) has kicked %s [%d] from TWDZS - Reason: %s"ReturnName(playerid), playeridReturnName(playerb), playerbreason);

? ? ? ? 
SendClientMessageToAll(COLOR_REDfstr);

? ? ? ? 
PlayerInfo[playerb][pKicks] ;

? ? ? ? 
GameTextForPlayer(playerb"~r~Kicked"50005);

? ? ? ? 
format(fstrsizeof(fstr), "You have been kicked from TWDZS. You were kicked by admin %s."ReturnName(playerid));

? ? ? ? 
SendClientMessage(playerbCOLOR_REDfstr);

? ? ? ? 
SendClientMessage(playerbCOLOR_ORANGE"If you think this kick is unfair complain at www.domain.net");

? ? ? ? 
KickEx(playerb);

? ? }

? ? return 
true;





RE: Not sure if my /kick works? - destiezk - 2021-04-02

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.


RE: Not sure if my /kick works? - Awide - 2021-04-02

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);

}



RE: Not sure if my /kick works? - ImOver - 2021-04-03

(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(playeridparams[])

{

? ? if(
PlayerInfo[playerid][pAdmin] < 1)

? ? return 
SCM(playeridCOLOR_RED"You are not allowed to use this command");



new 
playerbreason[24];

new 
fstr[200];

if(
sscanf(params"us[24]"playerbreason))

? ? return 
SCM(playeridCOLOR_RED"Usage: /kick [playerid/name] [reason]");

? ? 

? ? if(!
IsPlayerConnected(playerb))

return 
SendClientMessage(playeridCOLOR_RED"Player not found.");

? ? 

? ? if(
PlayerInfo[playerb][pAdmin] >= 1)

return 
SendClientMessage(playeridCOLOR_RED"You cant kick admins.");

? ? {

? ? ? ? 
format(fstrsizeof(fstr), "Admin %s (%d) has kicked %s [%d] from TWDZS - Reason: %s"ReturnName(playerid), playeridReturnName(playerb), playerbreason);

? ? ? ? 
SendClientMessageToAll(COLOR_REDfstr);

? ? ? ? 
PlayerInfo[playerb][pKicks] ;

? ? ? ? 
GameTextForPlayer(playerb"~r~Kicked"50005);

? ? ? ? 
format(fstrsizeof(fstr), "You have been kicked from TWDZS. You were kicked by admin %s."ReturnName(playerid));

? ? ? ? 
SendClientMessage(playerbCOLOR_REDfstr);

? ? ? ? 
SendClientMessage(playerbCOLOR_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.


RE: Not sure if my /kick works? - CrypticSin - 2021-04-03

(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(playeridparams[])

{

? ? if(
PlayerInfo[playerid][pAdmin] < 1)

? ? return 
SCM(playeridCOLOR_RED"You are not allowed to use this command");



new 
playerbreason[24];

new 
fstr[200];

if(
sscanf(params"us[24]"playerbreason))

? ? return 
SCM(playeridCOLOR_RED"Usage: /kick [playerid/name] [reason]");

? ? 

? ? if(!
IsPlayerConnected(playerb))

return 
SendClientMessage(playeridCOLOR_RED"Player not found.");

? ? 

? ? if(
PlayerInfo[playerb][pAdmin] >= 1)

return 
SendClientMessage(playeridCOLOR_RED"You cant kick admins.");

? ? {

? ? ? ? 
format(fstrsizeof(fstr), "Admin %s (%d) has kicked %s [%d] from TWDZS - Reason: %s"ReturnName(playerid), playeridReturnName(playerb), playerbreason);

? ? ? ? 
SendClientMessageToAll(COLOR_REDfstr);

? ? ? ? 
PlayerInfo[playerb][pKicks] ;

? ? ? ? 
GameTextForPlayer(playerb"~r~Kicked"50005);

? ? ? ? 
format(fstrsizeof(fstr), "You have been kicked from TWDZS. You were kicked by admin %s."ReturnName(playerid));

? ? ? ? 
SendClientMessage(playerbCOLOR_REDfstr);

? ? ? ? 
SendClientMessage(playerbCOLOR_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.