SA-MP Forums Archive
Can we compact this in one line? - 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: Can we compact this in one line? (/showthread.php?tid=580190)



Delete - gurmani11 - 03.07.2015

Delete


Re: Can we compact this in one line? - rymax99 - 03.07.2015

I'm guessing you'd just be able to use 'if(adminlvl != 0)' or 'if(adminlvl > 0)'. Not really going to be able to tell you much more given you didn't explain how your script admin levels work, or what exactly you're trying to accomplish.


Re: Can we compact this in one line? - SloProKiller - 03.07.2015

If this is supposed to check if the player isn't admin, then you could just do
Код:
if(admlvl == 0)
or
Код:
if(!admlvl)
But as rymax said you should have provided some sort of description of what you're trying to achieve.


Delete - gurmani11 - 03.07.2015

Delete


Re: Can we compact this in one line? - Gammix - 03.07.2015

The best method is:
pawn Код:
if(admlvl < 1)
Checks if the admin level is smaller than 1.

There are many other methods as well such like you can also use <= because its more easily readable:
pawn Код:
if(admlvl <= 0)
Checks if the admin level is smaller than or equal to 0.


Re: Can we compact this in one line? - rymax99 - 03.07.2015

Still don't quite understand what you're trying to achive. Copying the entire command here would probably be helpful to get a full understanding.


Re: Can we compact this in one line? - gurmani11 - 03.07.2015

Delete


Re: Can we compact this in one line? - SloProKiller - 03.07.2015

Код:
if (admlvl < 1 || (admlvl > 4 && admlvl != 1337)) return SendClientMessageEx(playerid, COLOR_RED,"- >>Error<< - Valid Admin Levels: 1-4 and 1337!");



Re: Can we compact this in one line? - cosbraa - 03.07.2015

Код:
if(admlvl < 1)
have you no experience with less than / greater than if statements?

this if statement checks if players admin level is less than 1, which means they're not admin.