setlevel
#1

hello guys this cmd when i type /setlevel it demote me to level 0 before i type id and level

PHP код:
CMD:setlevel(playerid,params[])
{
  if(
PlayerInfo[playerid][pAdmin] >= 5)
  {
  new 
target,level,string[134];
  if(
sscanf(params,"ud",target,level)) SendClientMessage(playerid,-1,"USAGE: /setlevel [playerid] [0 - 5]");
  if(
level || level 5) return SendClientMessage(playeridCOLOR_RED"Max Admin Level [5]");
  if(!
IsPlayerConnected(target)) return SendClientMessage(playerid,-1,"**Player is not connected");
  
PlayerInfo[target][pAdmin] = level;
  
format(string,sizeof(string),"Administrator %s Has setted your Admin Level To %d",pName(playerid),level);
  
SendClientMessage(target,-1,string);
  
format(string,sizeof(string),"You have setted %s Level To %d",pName(target),level);
  
SendClientMessage(playerid,-1,string);
  }
  else
  {
  
SendClientMessage(playerid,0xFF0000FF,"Only Level +5 can use this command");
  }
  return 
1;
  } 
Reply
#2

Try this

PHP код:
CMD:setlevel(playerid,params[]) 

      if(
PlayerInfo[playerid][pAdmin] >= 5
      { 
         new 
target,level,string[134]; 
          if(
sscanf(params,"ui",target,level)) return SendClientMessage(playerid,-1,"USAGE: /setlevel [playerid] [0 - 5]"); // You were not returning after the sscanf check
          
if(level || level 5) return SendClientMessage(playeridCOLOR_RED"Max Admin Level [5]"); 
          if(!
IsPlayerConnected(target)) return SendClientMessage(playerid,-1,"**Player is not connected"); 
          
PlayerInfo[target][pAdmin] = level
         
format(string,sizeof(string),"Administrator %s Has setted your Admin Level To %d",pName(playerid),level); 
        
SendClientMessage(target,-1,string); 
        
format(string,sizeof(string),"You have setted %s Level To %d",pName(target),level); 
        
SendClientMessage(playerid,-1,string); 
        return 
1;
    } 
    else return 
SendClientMessage(playerid,0xFF0000FF,"Only Level +5 can use this command"); 

Reply
#3

Quote:

return SendClientMessage(playerid,-1,"**Player is not connected");

Why did you set the color as -1?
Reply
#4

Quote:
Originally Posted by justjamie
Посмотреть сообщение
Why did you set the color as -1?
-1 is white.

You weren't returning the message after the sscanf check, you were only sending it.
So it would continue if you don't enter anything (Because target and level are both 0, so target is connected if your ID is 0, and level is >= 0)
Reply
#5

Quote:
Originally Posted by justjamie
Посмотреть сообщение
Why did you set the color as -1?
Lol?
Reply
#6

Quote:
Originally Posted by oMa37
Посмотреть сообщение
Try this

PHP код:
// bunch of code 
Please explain what you did instead of just supplying code. In the interest of both the OP and the others reading the thread. Cross-checking every line to see what has changed is not fun.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)