Help with permissions
#1

- Hello.

I need just one thing. So i have a (example) /kick command. I made that only administrator on level 1 and higher can use it. Now I made my "Supporter" system and i wanna add something like this:
- "If that player is admin or is supporter you allow him to use command"

For administrator:
PHP Code:
if(PlayerInfo[playerid][pAdministrator
For Supporter:
PHP Code:
if(PlayerInfo[playerid][pSupporter
Thank you for help!
Reply
#2

if(PlayerInfo[playerid][pAdministrator]||PlayerInfo[playerid][pSupporter]){
//code inside here.
}

or

if(!PlayerInfo[playerid][pAdministrator]&&!PlayerInfo[playerid][pSupporter]) return 0;
//Code after that

either one would work.
Reply
#3

PHP Code:
if(PlayerInfo[playerid][pAdministrator] < || PlayerInfo[playerid][pSupporter] < 1) return SendClientMessage(playerid,-1,"{F81414}Greska:{FFFFFF} Nemate dozvolu za tu komandu"); 
Nope... Still gives me erros when I call command with supporter level ?
- Picture: http://prntscr.com/6fki7m
Reply
#4

You should check if his Administrator "AND" Supporter level is below 1 by using && instead of ||, right now you're checking with "OR" ( || ).
Reply
#5

Nope. I really want "OR" so. He doesn't have to be supporter if is he admin to use command . LOL.
- So i need something like that. Admin - Or - Supporter
Reply
#6

You're not doing what I wrote tho. My example still stands. Don't add less than or greater than signs, and whether its OR or AND doesn't really matter. AND is however the best solution for more clean code since it usually ends up equaling less lines and such.
Reply
#7

pawn Code:
if(PlayerInfo[playerid][pAdministrator] >= 1 || PlayerInfo[playerid][pSupporter] >= 1)
{
    // Code.
}
else
{
    SendClientMessage(.....................You're not Admin or Supporter.
}
Reply
#8

@HY you have just done the same thing just on other way
Reply
#9

Quote:
Originally Posted by HY
View Post
pawn Code:
if(PlayerInfo[playerid][pAdministrator] >= 1 || PlayerInfo[playerid][pSupporter] >= 1)
{
    // Code.
}
else
{
    SendClientMessage(.....................You're not Admin or Supporter.
}
This also works, but again, the greater signs are kinda unnecessary, they don't do anything.

pawn Code:
if(PlayerInfo[playerid][pAdministrator]|| PlayerInfo[playerid][pSupporter])
{
    // Code.
}
else
{
    SendClientMessage(.....................You're not Admin or Supporter.
}
Gives same result.

pawn Code:
if(!PlayerInfo[playerid][pAdministrator]&&!PlayerInfo[playerid][pSupporter]) return SendClientMessage(.....................You're not Admin or Supporter.
 // Code.
Is the way to go if you want it to be less lines.
Reply
#10

Well your code checks if his admin level is below 0, if it is, it sends the message.
And if your supporter level is below 0, it sends the message aswell.
So that means you want to only be able to use the command if you're both an administrator and a supporter?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)