• Print

Author Topic: ULib.getUsers help  (Read 5111 times)

0 Members and 1 Guest are viewing this topic.

Offline BlueNova

  • Full Member
  • ***
  • Posts: 113
  • Karma: 13
  • The most powerful force in the universe.
ULib.getUsers help
« on: January 26, 2017, 11:05:42 pm »
Mainly I am having some issues within getting ULib.getUsers to target the correct user groups. The likely hood of myself doing it wrong is pretty high. I searched the forum for anything regarding it and didn't really find anything of use.

Now what I'm trying to do is trying to get it to target multiple user groups. After a few tries I quickly learned that doing this:
Code: [Select]
local players = ULib.getUsers( "%moderator", "%admin", "%superadmin" )doesn't necessarily work.

I'm not getting any real answers in console of what I'm doing is wrong so that's kind of disappointing that I don't really know where to start.

I know the format of ULib.getUsers being the

function ULib.getUsers( target, enable_keywords, ply )

thing. Just looking for some pointers on how to use this more correctly. K Thanks

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: ULib.getUsers help
« Reply #1 on: January 27, 2017, 07:14:21 am »
When it says target, I assume it means a target string a la ULib targeting. So instead of a list of parameters like you're passing, you would use a comma-separated list.

You would also need to set the second parameter, enable_keywords, to true for ULib targeting to be enabled. So, an example would be:

Code: Lua
  1. -- Gets all users below admin
  2. local belowAdmin = ULib.getUsers("!%admin", true)
  3. -- Gets all users in the admin group **ONLY**
  4. local admins = ULib.getUsers("#admin", true)
  5. -- Gets all of owner, moderator, admin
  6. local staff = ULib.getUsers("#owner, #moderator, #admin", true)
  7. -- Gets everyone but the current user
  8. local everyoneButMe = ULib.getUsers("!^", true)
  9. -- Gets everyone but the given player (serverside?, untested)
  10. local everyoneButUser = ULib.getUsers("!^", true, player.GetAll()[1])

Note how the targets are comma-separated inside the string, not passed as separate parameters. ULib handles this itself.
« Last Edit: January 27, 2017, 07:16:06 am by Bytewave »
bw81@ulysses-forums ~ % whoami
Homepage

Offline BlueNova

  • Full Member
  • ***
  • Posts: 113
  • Karma: 13
  • The most powerful force in the universe.
Re: ULib.getUsers help
« Reply #2 on: January 27, 2017, 12:54:58 pm »
Ah I see.

I tried to pass off each group as it's own parameter, ok. Thanks.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: ULib.getUsers help
« Reply #3 on: January 28, 2017, 04:20:31 pm »
Don't forget about the docs, which can normally help out immensely -- http://ulyssesmod.net/docs/files/lua/ulib/shared/player-lua.html#getUsers

Quote from: docs
target   A string of what you’d like to target.  Accepts a comma separated list.
Experiencing God's grace one day at a time.

Offline BlueNova

  • Full Member
  • ***
  • Posts: 113
  • Karma: 13
  • The most powerful force in the universe.
Re: ULib.getUsers help
« Reply #4 on: January 28, 2017, 04:25:58 pm »
I initially used the docs and just didn't understand it up front. I guess I was just tired. Nonetheless it works now

  • Print