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



kick command problem - b0b - 01.08.2016

PHP код:
CMD:kick(playeridparams[])
    {
    if(
PlayerInfo[playerid][pAdmin] >= 1) {
    new 
PID//define the playerid we wanna kick
    
new reason[64]; //the reason, put into a string
    
new str[128]; //a new message string
    
new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME]; 
    
GetPlayerName(playeridAdminnamesizeof(Adminname)); 
    
GetPlayerName(PIDPlayernamesizeof(Playername));
    if(
sscanf(params"di[64]"PID,reason)) return SendClientMessage(playeridCOLOR_GREY"{3BB9FF}KASUTA: {FFFFFF}/kick [playerid] [reason]"); //tell sscanf if the parameters/the syntax is written wrong to return a message (PID and the reason used here)
    
if(!IsPlayerConnected(PID))
    return 
SendClientMessage(playeridCOLOR_GREY"Kasutaja ei ole hetkel sees");
     
format(strsizeof(str), "'%s' sai kicki administraator '%s'. Pхhjus: %s "PlayernameAdminnamereason); //format the string we've defined to send the message, playername and adminname are used to receive the information about the names
    
SendClientMessageToAll(COLOR_REDstr); //send that message to all
    
Kick(PID); //kick the playerid we've defined
        
}
        else 
//if he has not got the permissions
        
{
            
SendClientMessage(playeridCOLOR_GREY"Sul pole хigusi, seda commandi kasutada."); //return this message
        
}
    return 
1;
    } 
SO.. If i go ingame and ty kick my self it says my
"KASUTA: /kick [playerid] [reason]"

And dont kick out my ingame. why?


Re: kick command problem - jlalt - 01.08.2016

Код:
if(sscanf(params, "di[64]", PID,reason))
you have to use s for strings
PHP код:
if(sscanf(params"ds[64]"PID,reason)) 
full code:
PHP код:
CMD:kick(playeridparams[])
    {
    if(
PlayerInfo[playerid][pAdmin] >= 1) {
    new 
PID//define the playerid we wanna kick
    
new reason[64]; //the reason, put into a string
    
new str[128]; //a new message string
    
new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
    
GetPlayerName(playeridAdminnamesizeof(Adminname));
    
GetPlayerName(PIDPlayernamesizeof(Playername));
    if(
sscanf(params"ds[64]"PID,reason)) return SendClientMessage(playeridCOLOR_GREY"{3BB9FF}KASUTA: {FFFFFF}/kick [playerid] [reason]"); //tell sscanf if the parameters/the syntax is written wrong to return a message (PID and the reason used here)
    
if(!IsPlayerConnected(PID))
    return 
SendClientMessage(playeridCOLOR_GREY"Kasutaja ei ole hetkel sees");
     
format(strsizeof(str), "'%s' sai kicki administraator '%s'. Pхhjus: %s "PlayernameAdminnamereason); //format the string we've defined to send the message, playername and adminname are used to receive the information about the names
    
SendClientMessageToAll(COLOR_REDstr); //send that message to all
    
Kick(PID); //kick the playerid we've defined

        
}
        else 
//if he has not got the permissions
        
{
            
SendClientMessage(playeridCOLOR_GREY"Sul pole хigusi, seda commandi kasutada."); //return this message
        
}
    return 
1