SA-MP Forums Archive
setlevel - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: setlevel (/showthread.php?tid=609257)



setlevel - Loinal - 10.06.2016

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;
  } 



Re: setlevel - oMa37 - 10.06.2016

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"); 




Re: setlevel - justjamie - 10.06.2016

Quote:

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

Why did you set the color as -1?


Re: setlevel - Stinged - 10.06.2016

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)


Re: setlevel - oMa37 - 10.06.2016

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


Re: setlevel - Vince - 10.06.2016

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.