Admin commands and other side-commands.
#1

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 +).
Reply
#2

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;
}
Reply
#3

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;
}
Reply
#4

But isn't health supposed to be a float value?
Like
pawn Код:
new Float:Health;
Reply
#5

Quote:
Originally Posted by DavidBilla
Посмотреть сообщение
But isn't health supposed to be a float value?
Like
pawn Код:
new Float:Health;
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)
Reply
#6

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.
Reply
#7

which enums do you have in your gamemode?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)