Checking if player is already admin or not
#1

So I have my setlevel command but how do I check if a player is already admin?

thats half of the code

Код:
CMD:setlevel(playerid, params[])
{
   if(pInfo[playerid][Admin] < 3)  return SendClientMessage(playerid, -1, "{C3C3C3}(INFO) You don't have the priviliges to use this command.");
   else
   {
	  new msg1[150], msg2[150], target, level,name[MAX_PLAYER_NAME];
	  if(target == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "{c3c3c3}(INFO) The player you are trying to set admin to is offline!");
	  if(sscanf(params, "ud", target, level))  return SendClientMessage(playerid, -1, "{C3C3C3}(INFO) /setlevel [ID] [LEVEL].");
	  else if(level > 3)  return SendClientMessage(playerid, -1, "{C3C3C3}(INFO) The admin levels are only between 0-3.");
	  else if(level < 0)  return SendClientMessage(playerid, -1, "{C3C3C3}(INFO) The admin levels are only between 0-3.");
	  else
	  {
edit: i mean same level*
Reply
#2

Код:
if(pInfo[target][Admin] == level)
{
     SendClientMessage(playerid, -1, "{C3C3C3} This player has already got the same level of admin as.");
     return 1;
}
This is to check if the player has the same level of admin as you typed.
Reply
#3

PHP код:
if(pInfo[target][Admin] >= 1) return SendClientMessage(playerid, -1"Player is already an admin"); 
Reply
#4

Quote:
Originally Posted by ISmokezU
Посмотреть сообщение
PHP код:
if(pInfo[target][Admin] >= 1) return SendClientMessage(playerid, -1"Player is already an admin"); 
He is trying to check if he has the same level, if he writes that in his code he will not be able to set players a higher level than 1 when they are already admin.
Reply
#5

Quote:
Originally Posted by edyun
Посмотреть сообщение
Код:
if(pInfo[target][Admin] == level)
{
     SendClientMessage(playerid, -1, "{C3C3C3} This player has already got the same level of admin as.");
     return 1;
}
This is to check if the player has the same level of admin as you typed.
nope, still the same.
Reply
#6

Just try to explain a bit better, what do you want to check?
Reply
#7

PHP код:

CMD
:setlevel(playeridparams[])
{
    new 
TargetPlayerlevelstr[128], new name[MAX_PLAYER_NAME];
    if(
pInfo[playerid][Admin] >= 3)
    {
        if(
sscanf(params"ui"TargetPlayerlevel)) return SendClientMessage(playerid, -1"{1E90FF}(Server):{dadada} /setlevel [id] [level]");
        if(!
IsPlayerConnected(TargetPlayer)) return SendClientMessage(playerid, -1"Player isn't connected.");
        if(
level 3) return SendClientMessage(playerid, -1"{C3C3C3}(INFO) The admin levels are only between 0-3.");
        if(
level 0) return SendClientMessage(playerid, -1"{C3C3C3}(INFO) The admin levels are only between 0-3.");
        if(
pInfo[playerid][Admin] == level) return SendClientMessage(playerid, -1"Player is already this admin level.");
           
format(strsizeof(str), "{1E90FF}(Server):{dadada} You have set %s's staff level to %d."GetPlayerName(TargetPlayernamesizeof(name));, level);
        
SendClientMessage(playerid, -1 str);
          
format(strsizeof(str), "{1E90FF}(Server):{dadada} Admin %s has set you staff level to %d."GetPlayerName(playeridnamesizeof(name));, level);
        
SendClientMessage(TargetPlayer, -1str);
        
pInfo[TargetPlayer][Admin] = level;
    }
    return 
1;

Untested but try that.

You were looking for this, though.
PHP код:
if(pInfo[playerid][Admin] == level) return SendClientMessage(playerid, -1"Player is already this admin level."); 
Reply
#8

Quote:
Originally Posted by aoky
Посмотреть сообщение
PHP код:

CMD
:setlevel(playeridparams[])
{
    new 
TargetPlayerlevelstr[128], new name[MAX_PLAYER_NAME];
    if(
pInfo[playerid][Admin] >= 3)
    {
        if(
sscanf(params"ui"TargetPlayerlevel)) return SendClientMessage(playerid, -1"{1E90FF}(Server):{dadada} /setlevel [id] [level]");
        if(!
IsPlayerConnected(TargetPlayer)) return SendClientMessage(playerid, -1"Player isn't connected.");
        if(
level 3) return SendClientMessage(playerid, -1"{C3C3C3}(INFO) The admin levels are only between 0-3.");
        if(
level 0) return SendClientMessage(playerid, -1"{C3C3C3}(INFO) The admin levels are only between 0-3.");
        if(
pInfo[playerid][Admin] == level) return SendClientMessage(playerid, -1"Player is already this admin level.");
           
format(strsizeof(str), "{1E90FF}(Server):{dadada} You have set %s's staff level to %d."GetPlayerName(TargetPlayernamesizeof(name));, level);
        
SendClientMessage(playerid, -1 str);
          
format(strsizeof(str), "{1E90FF}(Server):{dadada} Admin %s has set you staff level to %d."GetPlayerName(playeridnamesizeof(name));, level);
        
SendClientMessage(TargetPlayer, -1str);
        
pInfo[TargetPlayer][Admin] = level;
    }
    return 
1;

Untested but try that.

You were looking for this, though.
PHP код:
if(pInfo[playerid][Admin] == level) return SendClientMessage(playerid, -1"Player is already this admin level."); 
That's what I sent him aswell, but he is not trying to check if the "playerid" has admin but if the target I belive.
Reply
#9

Quote:
Originally Posted by edyun
Посмотреть сообщение
Just try to explain a bit better, what do you want to check?
For example if u are level 3 (or any other level) and i try to set the level that u already have it will say the player already has that level
Reply
#10

Quote:
Originally Posted by ISmokezU
Посмотреть сообщение
PHP код:
if(pInfo[target][Admin] >= 1) return SendClientMessage(playerid, -1"Player is already an admin"); 
if I understand what you want, then this condition should work.
Add this condition under the line with if(sscanf...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)