Doesnt work for other cmds, +1 REP. - 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: Doesnt work for other cmds, +1 REP. (
/showthread.php?tid=475500)
Doesnt work for other cmds, +1 REP. -
Lynet - 13.11.2013
Hello guys, i'm making a admin system to my new GM which i'm about to fix, but only level 1 admin as I made it for, is able to /kick, not even an admin level 11 is able to kick.
Here's my /kick cmd
Код HTML:
CMD:kick(playerid, params[])
{
if(PInfo[playerid][Level] > 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]; //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_RED, "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_RED, "Player is not connected!");
format(str, sizeof(str), "%s has been kicked by %s %s [reason: %s] ", Playername, aLevel(playerid), 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_RED, "You are not admin level 1."); //return this message
}
return 1;
}
Re: Doesnt work for other cmds, +1 REP. -
Avi Raj - 13.11.2013
use it like this :-
pawn Код:
CMD:kick(playerid, params[])
{
if(PInfo[playerid][Level] >= 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]; //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_RED, "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_RED, "Player is not connected!");
format(str, sizeof(str), "%s has been kicked by %s %s [reason: %s] ", Playername, aLevel(playerid), 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_RED, "You are not admin level 1."); //return this message
}
return 1;
}
Re: Doesnt work for other cmds, +1 REP. -
Lynet - 13.11.2013
@Avi Raj that worked, great! Thanks!