• Print

Author Topic: Replacement Function from ASSMod?  (Read 6954 times)

0 Members and 1 Guest are viewing this topic.

Offline rocky123xo

  • Newbie
  • *
  • Posts: 19
  • Karma: 1
Replacement Function from ASSMod?
« on: April 14, 2015, 10:46:02 pm »
I'll keep this brief.
In ASSMod, you could call the function
GetLevel < 3
for example, which would get all groups that were below 3 (vip, admin, and superadmin)
I used this to give the physgun to all VIP's.
What feature does ULX offer that I can do the same?

Will IsVIP() work?
I am very new to ULX, thank you for your help.

Offline Stickly Man!

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 1270
  • Karma: 164
  • What even IS software anymore?
    • XGUI
Re: Replacement Function from ASSMod?
« Reply #1 on: April 15, 2015, 08:26:29 am »
Assuming you're writing code specific for ULX/ULib, you can use ply:CheckGroup. So, you could say:
Code: Lua
  1. if ply:CheckGroup("admin") then
This would return true for any players in the admin group, or any group that inherits from admin (superadmin, etc.)

Alternately, if you don't want your code to rely on ULib, you should use the standard Garry's Mod ply:GetUserGroup() and then compare if it is equal to the groups you want:
Code: Lua
  1. if ply:GetUserGroup() == "admin" or ply:GetUserGroup() == "superadmin" then
Join our Team Ulysses community discord! https://discord.gg/gR4Uye6

Offline rocky123xo

  • Newbie
  • *
  • Posts: 19
  • Karma: 1
Re: Replacement Function from ASSMod?
« Reply #2 on: April 15, 2015, 12:11:04 pm »
I forget that ULib uses inheritance. I'll give that a shot. Thank you.

Offline rocky123xo

  • Newbie
  • *
  • Posts: 19
  • Karma: 1
Re: Replacement Function from ASSMod?
« Reply #3 on: April 15, 2015, 08:28:25 pm »
I forgot to ask. If I do CheckGroup("vip"). which Admin inherits from, will that include Superadmin? Since Superadmin doesn't inherit VIP, but inherits admin?

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Replacement Function from ASSMod?
« Reply #4 on: April 15, 2015, 08:56:09 pm »
It will include anything along the inheritance tree, no matter how many levels deep.
Experiencing God's grace one day at a time.

Offline rocky123xo

  • Newbie
  • *
  • Posts: 19
  • Karma: 1
Re: Replacement Function from ASSMod?
« Reply #5 on: April 15, 2015, 09:27:24 pm »
Awesome. No wonder everyone loves ULX, it's much better than the rest :P

Offline rocky123xo

  • Newbie
  • *
  • Posts: 19
  • Karma: 1
Re: Replacement Function from ASSMod?
« Reply #6 on: April 15, 2015, 11:25:31 pm »
So now, if I do:
"if !Player:CheckGroup("vip") then"
This is the same as saying:
If the player is not VIP or any group that inherits from VIP (admin, superadmin, etc)

Correct? Sorry if that is confusing.

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Replacement Function from ASSMod?
« Reply #7 on: April 16, 2015, 06:16:15 am »
So now, if I do:
"if !Player:CheckGroup("vip") then"
This is the same as saying:
If the player is not VIP or any group that inherits from VIP (admin, superadmin, etc)

Correct? Sorry if that is confusing.

Yes. This would return true for all groups below vip. vip and above will return false.
bw81@ulysses-forums ~ % whoami
Homepage

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: Replacement Function from ASSMod?
« Reply #8 on: April 16, 2015, 09:30:24 am »
So now, if I do:
"if !Player:CheckGroup("vip") then"
This is the same as saying:
If the player is not VIP or any group that inherits from VIP (admin, superadmin, etc)

Correct? Sorry if that is confusing.

That will work, but if you'll allow me to play Devil's Advocate here:
Try not to use ! to mean 'not'. It's an operator that Garry added to lua and is not standard.
Instead us: if not Player:CheckGroup( "vip" ) then

Offline rocky123xo

  • Newbie
  • *
  • Posts: 19
  • Karma: 1
Re: Replacement Function from ASSMod?
« Reply #9 on: April 16, 2015, 10:18:09 am »
Awesome, I really appreciate all the help given to a noob like me.

Offline rocky123xo

  • Newbie
  • *
  • Posts: 19
  • Karma: 1
Re: Replacement Function from ASSMod?
« Reply #10 on: April 17, 2015, 12:03:58 am »
Last question, promise. If I do:
Player:CheckGroup()
Will that just return their group, like "vip" or "admin"?

If not, what function can I call to retrieve their group name?

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: Replacement Function from ASSMod?
« Reply #11 on: April 17, 2015, 12:32:41 am »
Last question, promise. If I do:
Player:CheckGroup()
Will that just return their group, like "vip" or "admin"?

If not, what function can I call to retrieve their group name?

Player:GetUserGroup() works like that.
« Last Edit: April 17, 2015, 12:34:27 am by Decicus »
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline rocky123xo

  • Newbie
  • *
  • Posts: 19
  • Karma: 1
Re: Replacement Function from ASSMod?
« Reply #12 on: April 24, 2015, 08:08:22 pm »
I have this:
if (!Player:CheckGroup("moderator")) then

But it doesn't seem to work for anyone other than Moderator (Admin, Superadmin, and the like that inherit from Moderator)
Did I do something wrong?

Offline rocky123xo

  • Newbie
  • *
  • Posts: 19
  • Karma: 1
Re: Replacement Function from ASSMod?
« Reply #13 on: April 24, 2015, 08:13:45 pm »
Yes, I did. Nevermind!

  • Print