Command problem!
#1

I have problem in this command! When i am admin lvl 6 or 5,4,3,2 i am not allowed to use this command but i am admin lol

When i set my level to 0 or 1 i can use it! What is the problem! This command must be allowed only the use admin level 2 to 6! How to fix that

Код:
CMD:aheal(playerid, params[])
{
       f(PlayerInfo[playerid][Level] >= 2) return SCM(playerid,0xFF8284FF,"[ERROR]: You are not allowed to use this command!");
		SetPlayerHealth(playerid, 100);
        return 1;
}
Reply
#2

Quote:
Originally Posted by Hunud
Посмотреть сообщение
I have problem in this command! When i am admin lvl 6 or 5,4,3,2 i am not allowed to use this command but i am admin lol

When i set my level to 0 or 1 i can use it! What is the problem! This command must be allowed only the use admin level 2 to 6! How to fix that

Код:
CMD:aheal(playerid, params[])
{
       f(PlayerInfo[playerid][Level] >= 2) return SCM(playerid,0xFF8284FF,"[ERROR]: You are not allowed to use this command!");
		SetPlayerHealth(playerid, 100);
        return 1;
}
Change if to
pawn Код:
if(PlayerInfo[playerid][Level] <= 1) return SCM(playerid,0xFF8284FF,"[ERROR]: You are not allowed to use this command!");
Quote:

<= 1

means if they are 1 or lower that one


You were basically doing this

Quote:

>= 2

This means, if they are level 2 or above, they will get the error message
Reply
#3

... It's mathematic.. If a > or = to b then ..
PHP код:
CMD:aheal(playeridparams[])
{
       if(
PlayerInfo[playerid][Level] <= 2) return SCM(playerid,0xFF8284FF,"[ERROR]: You are not allowed to use this command!");
        
SetPlayerHealth(playerid100);
        return 
1;

Reply
#4

In addition to what the others said, i suggest you to format your code a littlebit more, because it is easier to read:
PHP код:
CMD:aheal(playeridparams[])
{
    if(
PlayerInfo[playerid][Level] < 2)
    {
        return 
SCM(playerid,0xFF8284FF,"[ERROR]: You are not allowed to use this command!");
    }
    
//ELSE
    
SetPlayerHealth(playerid100);
    return 
1;

Reply
#5

Ok thanks
Reply
#6

Quote:
Originally Posted by [Bios]Marcel
Посмотреть сообщение
In addition to what the others said, i suggest you to format your code a littlebit more, because it is easier to read:
PHP код:
CMD:aheal(playeridparams[])
{
    if(
PlayerInfo[playerid][Level] < 2)
    {
        return 
SCM(playerid,0xFF8284FF,"[ERROR]: You are not allowed to use this command!");
    }
    
//ELSE
    
SetPlayerHealth(playerid100);
    return 
1;

That's right, you can simply do:
PHP код:
CMD:aheal(playeridparams[])
{
    if(
PlayerInfo[playerid][Level] < 2
         return 
SCM(playerid,0xFF8284FF,"[ERROR]: You are not allowed to use this command!"); 
    
//ELSE
    
SetPlayerHealth(playerid100);
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)