Problem at /kick. -
GabiXx - 01.08.2015
I use this.
PHP код:
CMD:kick(playerid, params[])
{
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(playerid, Adminname, sizeof(Adminname)); //defines the function with the adminname we wanna get
GetPlayerName(PID, Playername, sizeof(Playername));
if(sscanf(params, "us[64]", PID,reason)) return SendClientMessage(playerid, COLOR_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(playerid, COLOR_GREY, "Player is not connected!");
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(COLOR_RED, str); //send that message to all
Kick(PID); //kick the playerid we've defined
}
else //if he has not got the permissions
{
SendClientMessage(playerid, COLOR_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.
AW: Problem at /kick. -
Macronix - 01.08.2015
PHP код:
CMD:kick(playerid, params[])
{
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(playerid, COLOR_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(playerid, COLOR_GREY, "Player is not connected!");
GetPlayerName(playerid, Adminname, sizeof(Adminname)); //defines the function with the adminname we wanna get
GetPlayerName(PID, Playername, sizeof(Playername));
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(COLOR_RED, str); //send that message to all
Kick(PID); //kick the playerid we've defined
}
else //if he has not got the permissions
{
SendClientMessage(playerid, COLOR_GREY, "You have to be level 3 to use that command!"); //return this message
}
return 1;
}
Re: Problem at /kick. -
GabiXx - 01.08.2015
So sorry, i paste wrong.
This is the CMD.
PHP код:
CMD:kick(playerid, params[])
{
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(playerid, 0xFF0000FF, "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(playerid, Adminname, sizeof(Adminname)); //defines the function with the adminname we wanna get
GetPlayerName(PID, Playername, sizeof(Playername));
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)
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
if(!IsPlayerConnected(PID)) // if the ID is wrong or not connected, return a message! (PID used here)
return SendClientMessage(playerid, 0xFF0000FF, "Player is not connected!");
Kick(PID);
return 1;
}
AW: Problem at /kick. -
Macronix - 01.08.2015
Still the same...
Here:
PHP код:
CMD:kick(playerid, params[])
{
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(playerid, 0xFF0000FF, "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(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)
GetPlayerName(playerid, Adminname, sizeof(Adminname)); //defines the function with the adminname we wanna get
GetPlayerName(PID, Playername, sizeof(Playername));
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
if(!IsPlayerConnected(PID)) // if the ID is wrong or not connected, return a message! (PID used here)
return SendClientMessage(playerid, 0xFF0000FF, "Player is not connected!");
Kick(PID);
return 1;
}
"GetPlayerName" needs to be after "sscanf"
Re: Problem at /kick. -
xVIP3Rx - 01.08.2015
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;
}
Re: Problem at /kick. -
GabiXx - 01.08.2015
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(playerid, params[])
{
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(playerid, 0xFF0000FF, "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(playerid, Adminname, sizeof(Adminname)); //defines the function with the adminname we wanna get
GetPlayerName(PID, Playername, sizeof(Playername));
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)
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
if(!IsPlayerConnected(PID)) // if the ID is wrong or not connected, return a message! (PID used here)
return SendClientMessage(playerid, 0xFF0000FF, "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.
Re: Problem at /kick. -
xVIP3Rx - 01.08.2015
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;
}
Re: Problem at /kick. -
GabiXx - 01.08.2015
PHP код:
if(PID = playerid) return SendClientMessage(playerid, 0xFF0000FF, "You're trying to ban yourself.");
At this line i get next error.
warning 211: possibly unintended assignment
AW: Problem at /kick. -
Macronix - 01.08.2015
Код:
if(PID == playerid) return SendClientMessage(playerid, 0xFF0000FF, "You're trying to ban yourself.");
Re: Problem at /kick. -
GabiXx - 01.08.2015
I put this.
But same problem. The player who i want ban, get ban. Wait 30 sec, and i get banned to...