SA-MP Forums Archive
Help with permissions - 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: Help with permissions (/showthread.php?tid=567191)



Help with permissions - NoDi522 - 11.03.2015

- 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!


Re: Help with permissions - oliverrud - 11.03.2015

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.


Re: Help with permissions - NoDi522 - 11.03.2015

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


Re: Help with permissions - CalvinC - 11.03.2015

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


Re: Help with permissions - NoDi522 - 11.03.2015

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


Re: Help with permissions - oliverrud - 11.03.2015

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.


Re: Help with permissions - HY - 11.03.2015

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



Re: Help with permissions - NoDi522 - 11.03.2015

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


Re: Help with permissions - oliverrud - 11.03.2015

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.


Re: Help with permissions - CalvinC - 11.03.2015

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?