Help with /kick - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help with /kick (
/showthread.php?tid=533194)
Help with /kick -
Snail - 23.08.2014
Hi everyone
I am having some problems with my /kick command
What happens is when I type /kick 0 It kicks the player but without a reason
The next problem is when I type a ID in when the player isn't connected it shows I kicked someone but without a name and a reason.
Here is the code:
pawn Код:
CMD:kick(playerid,params[])
{
new nub, str[128], reason[128], an[MAX_PLAYER_NAME], nub1[MAX_PLAYER_NAME];
if(!IsPlayerAdmin(playerid)) return SCM(playerid, COLOR_RED, "ERROR: You must be an RCON to use this command!");
if(!IsPlayerConnected(nub)) return SCM(playerid, COLOR_RED, "ERROR: That player isn't connected!");
if(sscanf(params,"is", nub)) return SCM(playerid, COLOR_RED, "USAGE: /kick <playerid> <reason>");
GPN(playerid, an, MAX_PLAYER_NAME);
GPN(nub, nub1, MAX_PLAYER_NAME);
FT(str, sizeof(str), "[KICK]:%s has kicked %s! Reason: %s", an, nub1, reason);
SCMTA(COLOR_RED, str);
Kick(nub);
return 1;
}
I changed the sscanf params to "ud" but still doesn't work.
Thank you
Re: Help with /kick -
Kyance - 23.08.2014
if(sscanf(params,"is", nub)) return SCM(playerid, COLOR_RED, "USAGE: /kick <playerid> <reason>");
It needs to be
pawn Код:
if(sscanf(params,"us[128]", nub, reason)) return SCM(playerid, COLOR_RED, "USAGE: /kick <playerid> <reason>");
u = Player's ID(nub)
s[128] = String(reason)
Re: Help with /kick -
HazardouS - 23.08.2014
I recommend you to make the reason smaller, you don't need 128 characters and if it is that big, it won't fit in the "str" string.
pawn Код:
CMD:kick(playerid, params[])
{
new nub, str[128], reason[128], an[MAX_PLAYER_NAME], nub1[MAX_PLAYER_NAME];
if(!IsPlayerAdmin(playerid)) return SCM(playerid, COLOR_RED, "ERROR: You must be an RCON to use this command!");
if(sscanf(params,"is[128]", nub, reason)) return SCM(playerid, COLOR_RED, "USAGE: /kick <playerid> <reason>");
//you might want to make sure that "nub" is between 0 and 999 [ if(nub < 0 || nub > 999) return SCM(playerid, COLOR_RED, "error"); ]
if(!IsPlayerConnected(nub)) return SCM(playerid, COLOR_RED, "ERROR: That player isn't connected!");
GPN(playerid, an, MAX_PLAYER_NAME);
GPN(nub, nub1, MAX_PLAYER_NAME);
FT(str, sizeof(str), "[KICK]:%s has kicked %s! Reason: %s", an, nub1, reason);
SCMTA(COLOR_RED, str);
Kick(nub);
return 1;
}
Re: Help with /kick -
PrivatioBoni - 23.08.2014
You need to put the kick function into a timer of e.g. 1000ms so the kicked player gets the message, otherwise they won't know why they were kicked.
Re: Help with /kick -
Snail - 23.08.2014
Quote:
Originally Posted by HazardouS
I recommend you to make the reason smaller, you don't need 128 characters and if it is that big, it won't fit in the "str" string.
pawn Код:
CMD:kick(playerid, params[]) { new nub, str[128], reason[128], an[MAX_PLAYER_NAME], nub1[MAX_PLAYER_NAME]; if(!IsPlayerAdmin(playerid)) return SCM(playerid, COLOR_RED, "ERROR: You must be an RCON to use this command!"); if(sscanf(params,"is[128]", nub, reason)) return SCM(playerid, COLOR_RED, "USAGE: /kick <playerid> <reason>"); //you might want to make sure that "nub" is between 0 and 999 [ if(nub < 0 || nub > 999) return SCM(playerid, COLOR_RED, "error"); ] if(!IsPlayerConnected(nub)) return SCM(playerid, COLOR_RED, "ERROR: That player isn't connected!"); GPN(playerid, an, MAX_PLAYER_NAME); GPN(nub, nub1, MAX_PLAYER_NAME); FT(str, sizeof(str), "[KICK]:%s has kicked %s! Reason: %s", an, nub1, reason); SCMTA(COLOR_RED, str); Kick(nub); return 1; }
|
Thank you very much
Your one worked!
Thanks again