Problem at /kick.
#1

I use this.
PHP код:
CMD:kick(playeridparams[])
    {
        if(
PlayerInfo[playerid][pAdmin] >= 3) {
            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]; //defines the function with the playername we wanna get
            
GetPlayerName(playeridAdminnamesizeof(Adminname)); //defines the function with the adminname we wanna get
               
GetPlayerName(PIDPlayernamesizeof(Playername));
            if(
sscanf(params"us[64]"PID,reason)) return SendClientMessage(playeridCOLOR_GREY"USAGE: /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)) // if the ID is wrong or not connected, return a message! (PID used here)
                
return SendClientMessage(playeridCOLOR_GREY"Player is not connected!");
            
format(strsizeof(str), "'%s' has been kicked by administrator '%s'. Reason: %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"You have to be level 3 to use that command!"); //return this message
        
}
        return 
1;
    } 
The problem is. If i kick a player, i will see this.
"My name" has been kicked by administrator "My name"....
But i kick other player, not me.
Reply
#2

PHP код:
CMD:kick(playeridparams[])
{
        if(
PlayerInfo[playerid][pAdmin] >= 3)
        {
            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]; //defines the function with the playername we wanna get
            
if(sscanf(params"us[64]"PID,reason)) return SendClientMessage(playeridCOLOR_GREY"USAGE: /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)) // if the ID is wrong or not connected, return a message! (PID used here)
                
return SendClientMessage(playeridCOLOR_GREY"Player is not connected!");
            
GetPlayerName(playeridAdminnamesizeof(Adminname)); //defines the function with the adminname we wanna get
            
GetPlayerName(PIDPlayernamesizeof(Playername));
            
format(strsizeof(str), "'%s' has been kicked by administrator '%s'. Reason: %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"You have to be level 3 to use that command!"); //return this message
        
}
        return 
1;

Reply
#3

So sorry, i paste wrong.
This is the CMD.
PHP код:
CMD:kick(playeridparams[])
{
            new 
PID//define the playerid we wanna kick
            
new reason[64]; //the reason, put into a string
            
new str[128];
            if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid0xFF0000FF"You need to be admin for use this command.");
            new 
Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME]; //defines the function with the playername we wanna get
            
GetPlayerName(playeridAdminnamesizeof(Adminname)); //defines the function with the adminname we wanna get
               
GetPlayerName(PIDPlayernamesizeof(Playername));
            if(
sscanf(params"us[64]"PID,reason)) return SendClientMessage(playerid0xFF0000FF"/kick [playerid] [reason]"); //tell sscanf if the parameters/the syntax is written wrong to return a message (PID and the reason used here)
            
format(strsizeof(str), "'%s' has been kicked by administrator '%s'. Reason: %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(0xFF6C00FFstr); //send that message to all
            
if(!IsPlayerConnected(PID)) // if the ID is wrong or not connected, return a message! (PID used here)
            
return SendClientMessage(playerid0xFF0000FF"Player is not connected!");
            
Kick(PID);
            return 
1;

Reply
#4

Still the same...
Here:

PHP код:
CMD:kick(playeridparams[])
{
    new 
PID//define the playerid we wanna kick
    
new reason[64]; //the reason, put into a string
    
new str[128];
    if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid0xFF0000FF"You need to be admin for use this command.");
    new 
Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME]; //defines the function with the playername we wanna get
    
if(sscanf(params"us[64]"PID,reason)) return SendClientMessage(playerid0xFF0000FF"/kick [playerid] [reason]"); //tell sscanf if the parameters/the syntax is written wrong to return a message (PID and the reason used here)
    
GetPlayerName(playeridAdminnamesizeof(Adminname)); //defines the function with the adminname we wanna get
     
GetPlayerName(PIDPlayernamesizeof(Playername));
    
format(strsizeof(str), "'%s' has been kicked by administrator '%s'. Reason: %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(0xFF6C00FFstr); //send that message to all
    
    
if(!IsPlayerConnected(PID)) // if the ID is wrong or not connected, return a message! (PID used here)
    
return SendClientMessage(playerid0xFF0000FF"Player is not connected!");
    
Kick(PID);
    
    return 
1;

"GetPlayerName" needs to be after "sscanf"
Reply
#5

The code you posted should be working, I optimized it a bit though
pawn Код:
CMD:kick(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "You need to be admin for use this command.");

    new PID, reason[64]; //the reason/playerid
    if(sscanf(params, "us[64]", PID,reason)) return SendClientMessage(playerid, 0xFF0000FF, "/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(playerid, 0xFF0000FF, "Player is not connected!");

    new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME]; //defines the function with the playername we wanna get
    GetPlayerName(playerid, Adminname, sizeof(Adminname)); //defines the function with the adminname we wanna get
    GetPlayerName(PID, Playername, sizeof(Playername));

    new str[128];
    format(str, sizeof(str), "'%s' has been kicked by administrator '%s'. Reason: %s.", Playername, Adminname, reason); //format the string we've defined to send the message, playername and adminname are used to receive the information about the names
    SendClientMessageToAll(0xFF6C00FF, str); //send that message to all
   
    Kick(PID);
    return 1;
}
Reply
#6

Ty. Now can help me at /ban?
When i ban a player, we get ban both.
And same "My name" has been banned by administrator "My name"...
PHP код:
CMD:ban(playeridparams[])
{
            new 
PID//define the playerid we wanna kick
            
new reason[64]; //the reason, put into a string
            
new str[128];
            if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid0xFF0000FF"You need to be admin for use this command.");
            new 
Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME]; //defines the function with the playername we wanna get
            
GetPlayerName(playeridAdminnamesizeof(Adminname)); //defines the function with the adminname we wanna get
               
GetPlayerName(PIDPlayernamesizeof(Playername));
            if(
sscanf(params"us[64]"PID,reason)) return SendClientMessage(playerid0xFF0000FF"/ban [playerid] [reason]"); //tell sscanf if the parameters/the syntax is written wrong to return a message (PID and the reason used here)
            
format(strsizeof(str), "'%s' has been banned by administrator '%s'. Reason: %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(0xFF6C00FFstr); //send that message to all
            
if(!IsPlayerConnected(PID)) // if the ID is wrong or not connected, return a message! (PID used here)
            
return SendClientMessage(playerid0xFF0000FF"Player is not connected!");
            
Ban(PID);
            return 
1;

Edit: I resolve "My name" has been banned by administrator "My name". But still got ban both.
Reply
#7

You should add a line to check if you're trying to ban/kick yourself on the kick command too.

pawn Код:
CMD:ban(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "You need to be admin for use this command.");

    new PID, reason[64];
    if(sscanf(params, "us[64]", PID,reason)) return SendClientMessage(playerid, 0xFF0000FF, "/ban [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(playerid, 0xFF0000FF, "Player is not connected!");
    if(PID = playerid) return SendClientMessage(playerid, 0xFF0000FF, "You're trying to ban yourself.");

    new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME]; //defines the function with the playername we wanna get
    GetPlayerName(playerid, Adminname, sizeof(Adminname)); //defines the function with the adminname we wanna get
    GetPlayerName(PID, Playername, sizeof(Playername));

    new str[128];
    format(str, sizeof(str), "'%s' has been banned by administrator '%s'. Reason: %s.", Playername, Adminname, reason); //format the string we've defined to send the message, playername and adminname are used to receive the information about the names
    SendClientMessageToAll(0xFF6C00FF, str); //send that message to all
           
    Ban(PID);
    return 1;
}
Reply
#8

PHP код:
if(PID playerid) return SendClientMessage(playerid0xFF0000FF"You're trying to ban yourself."); 
At this line i get next error.
warning 211: possibly unintended assignment
Reply
#9

Код:
if(PID == playerid) return SendClientMessage(playerid, 0xFF0000FF, "You're trying to ban yourself.");
Reply
#10

I put this.
But same problem. The player who i want ban, get ban. Wait 30 sec, and i get banned to...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)