Admin commands and other side-commands. -
mkmk - 17.10.2014
Well, first off, why isn't this working?
Код:
CMD:sethp(playerid,params[])
{
if(IsPlayerAdmin(playerid))
{
new Health;
new PID;
if(sscanf(params, "ud", PID, Health)) return SendClientMessage(playerid, -1, "USAGE: /sethp [playerid] [health]");
if(!IsPlayerConnected(PID)) return SendClientMessage(playerid, -1, "Player is not connected");
SetPlayerHealth(PID, Health);
}
else SendClientMessage(playerid, -1, "You are not authorized to use this command!");
return 1;
}
Secondly, how am I meant to make it where you type /givegun [playerid] [gunid] [ammo]?
Third thing lol, how do I make commands only acceptable by admins?
Fourth, but final thing, how do I make a /setskin command? (only usable for admin level 2 +).
Re: Admin commands and other side-commands. -
Eth - 18.10.2014
try that:
pawn Код:
CMD:sethp(playerid,params[])
{
if(IsPlayerAdmin(playerid))
{
new Health;
new PID;
if(sscanf(params, "ud", PID, Health)) return SendClientMessage(playerid, -1, "USAGE: /sethp [playerid] [health]");
if(!IsPlayerConnected(PID)) return SendClientMessage(playerid, -1, "Player is not connected");
SetPlayerHealth(PID, Health);
}
else if(!IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, -1, "You are not authorized to use this command!");
return 0;
}
return 1;
}
Re: Admin commands and other side-commands. -
Neil. - 18.10.2014
pawn Код:
CMD:setskin(playerid, params[])
{
if(Admin(playerid) >= 2) //Change to gm-specific enum
{
new skinid, targetid;
if(sscanf(params, "ii", targetid, skinid)) return SendClientMessage(playerid, -1, "/setskin (playerid) (skinid)");
SetPlayerSkin(targetid, skinid);
SendClientMessage(playerid, -1, "Skin was set.");
}
return 1;
}
Re: Admin commands and other side-commands. -
DavidBilla - 18.10.2014
But isn't health supposed to be a float value?
Like
Re: Admin commands and other side-commands. -
Kaperstone - 18.10.2014
Quote:
Originally Posted by DavidBilla
But isn't health supposed to be a float value?
Like
|
Both are acceptable, it's up to you.
Quote:
Secondly, how am I meant to make it where you type /givegun [playerid] [gunid] [ammo]?
|
Fetching the player text, slicing it into pieces with a space as the delimiter and then seperating each into the correct array.
instead of breaking your head on how to do so, you can use a command proccessor such as zcmd or ycmd.
and to slice(aka explode) the string into pieces, organizing each data which will pass into the specificied structure which you input in the command, use sscanf which can be found in the plugins board.
Quote:
Third thing lol, how do I make commands only acceptable by admins?
|
Find the array which is responsible for the admin level for each player and check if it's higher than the desired minimum. (or equal, if you want to make it for a specific level)
Quote:
Fourth, but final thing, how do I make a /setskin command? (only usable for admin level 2 +).
|
(answered above)
Re: Admin commands and other side-commands. -
mkmk - 18.10.2014
Quote:
Originally Posted by Eth
try that:
pawn Код:
CMD:sethp(playerid,params[]) { if(IsPlayerAdmin(playerid)) { new Health; new PID; if(sscanf(params, "ud", PID, Health)) return SendClientMessage(playerid, -1, "USAGE: /sethp [playerid] [health]"); if(!IsPlayerConnected(PID)) return SendClientMessage(playerid, -1, "Player is not connected"); SetPlayerHealth(PID, Health); } else if(!IsPlayerAdmin(playerid)) { SendClientMessage(playerid, -1, "You are not authorized to use this command!"); return 0; } return 1; }
|
Working, but only for RCON admins, I need it for admin level 4's +.
Quote:
CMDetskin(playerid, params[])
{
if(Admin(playerid) >= 2) //Change to gm-specific enum
{
new skinid, targetid;
if(sscanf(params, "ii", targetid, skinid)) return SendClientMessage(playerid, -1, "/setskin (playerid) (skinid)");
SetPlayerSkin(targetid, skinid);
SendClientMessage(playerid, -1, "Skin was set.");
}
return 1;
}
|
Not working.
Re: Admin commands and other side-commands. -
Eth - 18.10.2014
which enums do you have in your gamemode?