How to make this work for RCON admins
#1

Im making a kick command,
If you have some dislikes about the command dont say it :P
I was wondering how to make it for RCON admins aswell as the admin level?
Id prefer it in the format im using if you could

pawn Код:
CMD:kick(playerid, params[])
{
    new id, reason;

  if (AccountInfo[playerid][AdminLevel] < 0) SendClientMessage(playerid, COLOR_RED, "Error ~ You are not an administrator with the required level");
  else if (sscanf(params, "uz", id, reason)) SendClientMessage(playerid, COLOR_RED, "Usage ~ /kick [PlayerID/PartOfName] [Reason]");
  else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOR_RED, "Error ~ Player not Connected");
  else if (AccountInfo[id][AdminLevel] > 5) SendClientMessage(playerid, COLOR_RED, "Error ~ You cannot kick the highest level admin");
  else
    {
      new string[128];
      new sendername[MAX_PLAYER_NAME];
      new targetname[MAX_PLAYER_NAME];

      GetPlayerName(playerid, sendername, sizeof sendername);
      GetPlayerName(playerid, targetname, sizeof targetname);

      format(string, sizeof string, "Administrator %s has kicked you from the server, Reason: %s", sendername, reason);
      SendClientMessage(id, COLOR_BLUE, string);

      format(string, sizeof string, "You have kicked player %s, Reason: %s", targetname, reason);
      SendClientMessage(playerid, COLOR_BLUE, string);

      Kick(playerid);
  }
    return 1;
}
Reply
#2

if(IsPlayerAdmin??
Reply
#3

You should use the || which means or, so the old code you have put in was:

Код:
else if (AccountInfo[id][AdminLevel] > 5) SendClientMessage(playerid, COLOR_RED, "Error ~ You cannot kick the highest level admin");
It should be changed to ( Also even though you said don't say anything about your code, I have to for the protection ):
Код:
else if (AccountInfo[id][AdminLevel] > 5 || IsPlayerAdmin(id)) SendClientMessage(playerid, COLOR_RED, "Error ~ You cannot kick the highest level admin");
About the paranethises words I've said, in math and so as PAWN the structures are still the same.


> - Left is greater than right
< - Left is less than right


So re-read your statement: If(ThePlayer'sAdminLevel is greater than 5). That will mean if the player is higher than the lead admin can't kick them. So that will lead other admins to kick the high level admin, change > to <

Reply
#4

Quote:
Originally Posted by Carlton
You should use the || which means or, so the old code you have put in was:

Код:
else if (AccountInfo[id][AdminLevel] > 5) SendClientMessage(playerid, COLOR_RED, "Error ~ You cannot kick the highest level admin");
It should be changed to ( Also even though you said don't say anything about your code, I have to for the protection ):
Код:
else if (AccountInfo[id][AdminLevel] > 5 || IsPlayerAdmin(id)) SendClientMessage(playerid, COLOR_RED, "Error ~ You cannot kick the highest level admin");
About the paranethises words I've said, in math and so as PAWN the structures are still the same.


> - Left is greater than right
< - Left is less than right


So re-read your statement: If(ThePlayer'sAdminLevel is greater than 5). That will mean if the player is higher than the lead admin can't kick them. So that will lead other admins to kick the high level admin, change > to <

Ok thanks
Reply
#5

Simple, use if(IsPlayerAdmin(playerid)).

Sorry if it has already been solved. But what is another person saying the correct code Good luck.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)