i want to make admin command
#1

Hello, I want to make the command only for administrators and that can be used when they are duty



enum @ID
{
Admin,
// identifier (I do not know how this works)

};

new Info23[MAX_PLAYERS][@ID];

CMD:heal(playerid, params[])
{
if(!(Info23[playerid][Admin] >=5)) return SendClientMessage(playerid,-1,"ERROR: You can't use this command");
SetPlayerHealth(playerid, 100);
SendClientMessage(playerid, -1, "Now, you have 100 HP");
return 1;
}
Reply
#2

use this:
CMD:heal(playerid, params[])
{

if(Info23[playerid][Admin] >= 5)
{
if(Info23[playerid][Duty] >=1)
{
SetPlayerHealth(playerid, 100);
SendClientMessage(playerid, -1, "Now, you have 100 HP");
}
else
{
SendClientMessage(playerid,-1,"You can use this command when you are ON DUTY!");
}
}
else
{
SendClientMessage(playerid,-1,"You don't have permissions to do that");
}
return 1;
}
Reply
#3

pawn Код:
enum pInfo
{
      pMoney,
      pAdmin,   // we need only this one
      pAduty,   // and this one for this command
      Float:pPosX,
      Float:pPosY,
      Float:pPosZ
}
new PlayerInfo[MAX_PLAYERS][pInfo];


CMD:heal(playerid, params[])
{
         new targetid;
         if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, -1, "/heal [id]");
         if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "That player isn't logged in.");
         if(PlayerInfo[playerid][pAdmin] != 1) return SendClientMessage(playerid, -1, "You aren't an admin");
         if(PlayerInfo[playerid][pAduty] != 0) return SendClientMessage(playerid, -1, "You aren't on admin duty.");
         if(targetid == playerid)
         {
               SendClientMessage(playerid, -1, "You have healed yourself");
               SetPlayerHealth(playerid, 100);
         }
         else
         {
              new pname[MAX_PLAYER_NAME], string[64];
              GetPlayerName(targetid, pname, sizeof(pname));            
              format(string, sizeof(string), "You have healed %s", pname);
              SetPlayerHealth(targetid, 100);
              SendClientMessage(playerid, -1, string);
         }
         return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)