SA-MP Forums Archive
Problem with my kick command - 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: Problem with my kick command (/showthread.php?tid=605383)



Problem with my kick command - iCurse - 18.04.2016

I made this command long time ago, i found it at the script that i once made so i pasted it to the script that i'm recently scripting.

The problem is when i /kick 0 (playerid) DM it sends me a message saying "SERVER: Unknown Command" And i really don't know why. But when i /kick 0 0(a number) It kicks me.

I tried /kick 1 0 even though my ID is 0, and i'm the only player at the server it just kicked me.

This is the code.

PHP код:
CMD:kick(playeridparams[])
{
    if(
pInfo[playerid][pAdmin] <= 1)
        return 
SendClientMessage(playeridGREY"You are not authorized to use that command.");
    new
        
targetid,
        
reason,
        
str[128]
    ;
    if(
sscanf(params"us"targetidreason))
        return 
SendClientMessage(playeridGREY"USAGE: /kick [playerid] [reason]");
    if(!
IsPlayerConnected(targetid))
        return 
SendClientMessage(playeridGREY"Player is not connected");
    new
        
pname[MAX_PLAYER_NAME],
        
tname[MAX_PLAYER_NAME]
    ;
    
GetPlayerName(playeridpnamesizeof(pname));
    
GetPlayerName(targetidtnamesizeof(tname));
    
format(strsizeof(str), "You have been kicked by %s. REASON: %s"pnamereason);
    
SendClientMessage(targetidLIGHTBLUEstr);
    
format(strsizeof(str), "You have kicked %s REASON: %s."tnamereason);
    
SendClientMessage(playeridLIGHTBLUEstr);
    
SetTimerEx("KickPlayer"100false"i"targetid);
    return 
1;
}
forward KickPlayer(targetid);
public 
KickPlayer(targetid)
{
    
Kick(targetid);




Re: Problem with my kick command - iCurse - 18.04.2016

ADD: If okay, please edit some of the lines to a better one. I messed up some lines, i think.


Re: Problem with my kick command - Saliim - 18.04.2016

Hi bro, for SERVER: Unknown Command, add
Код:
return 1;
else have you a warning or error in your compiler ?


Re: Problem with my kick command - SyS - 18.04.2016

Look in your codes the variable "reason" should be a string try the following codes
PHP код:
CMD:kick(playeridparams[]) 

    if(
pInfo[playerid][pAdmin] <= 1
        return 
SendClientMessage(playeridGREY"You are not authorized to use that command."); 
    new 
        
targetid
        
reason[24], 
        
str[128
    ; 
    if(
sscanf(params"us[24]"targetidreason)) 
        return 
SendClientMessage(playeridGREY"USAGE: /kick [playerid] [reason]"); 
    if(!
IsPlayerConnected(targetid)) 
        return 
SendClientMessage(playeridGREY"Player is not connected"); 
    new 
        
pname[MAX_PLAYER_NAME], 
        
tname[MAX_PLAYER_NAME
    ; 
    
GetPlayerName(playeridpnamesizeof(pname)); 
    
GetPlayerName(targetidtnamesizeof(tname)); 
    
format(strsizeof(str), "You have been kicked by %s. REASON: %s"pnamereason); 
    
SendClientMessage(targetidLIGHTBLUEstr); 
    
format(strsizeof(str), "You have kicked %s REASON: %s."tnamereason); 
    
SendClientMessage(playeridLIGHTBLUEstr); 
    
SetTimerEx("KickPlayer"100false"i"targetid); 
    return 
1




Re: Problem with my kick command - Threshold - 18.04.2016

First off, make sure your sscanf plugin and includes are up to date. Secondly, show us your KickPlayer function. Check your console for any errors when using the command.


Re: Problem with my kick command - AdrianG - 20.04.2016

Use crashdetect.


Re: Problem with my kick command - Ritzy2K - 20.04.2016

You need to use the "number" after ID because you've declared the "reason" variable as an integer type. Change it into string.