Author Topic: Restricting ulx groups to join a server  (Read 1282 times)

0 Members and 1 Guest are viewing this topic.

Offline Shu | Pexie

  • Newbie
  • *
  • Posts: 10
  • Karma: 0
  • Polyglot guy here!
Restricting ulx groups to join a server
« on: August 02, 2018, 10:49:30 PM »
Is there a way to restrict ulx groups to join a server? I'm pretty sure it's impossible doing with just ulx itself and probably it requires some code knowledge, but i was wondering how it could work...

I saw some servers asking the clients the moment they try to join for a password (not the server password), a special code to allow that specific user to join the server, otherwise it would appear to the same user something like "bad password", restricting to join. I searched on google and even here, but didn't find anything about it...


Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Restricting ulx groups to join a server
« Reply #1 on: August 03, 2018, 06:48:22 AM »
The problem with doing it using ULX groups (or groups in gmod in general) is that to have it restrict players before they join you need to use the PlayerAuthed hook.

That's fine and all.. except this occurs before the player is authed by ULX. The only information you have with this hook is the player's steamid64.

Ohh.. come to think of it.. you could do this pretty easily. Below is pseudocode to get you started...


1. Catch the join event in the PLayerAuthed hook.
2. Convert the 64bit steam id to a normal steam id.
3. Iterate through the ULib.ucl.users table to see if that steam id has an entry.
4. If they do... compare their group (from their entry in the table) against a list of groups you want to allow into your server.


I'm nowhere near my main PC (and won't be for another week) or I'd write this for you, but I can't. :(

If you can't get this yourself, or no one else takes it on, I'll work it out when I get back. That sounds like a useful plugin to release to the ULX community.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Restricting ulx groups to join a server
« Reply #2 on: August 03, 2018, 07:12:06 AM »
MrPresident - Why couldn't he just use ULX reserved slots?

Shu | Pexie -
It's called reserved slots, and ulx has it. It's probably one of the first features we wrote into it, after straight admin commands like kick/ban.
They do indeed join server for a few moments if they don't have access, and that could be annoying, but it works. (They'd be kicked after join)

See the descriptions of rslots and rslotsmode here.
https://github.com/TeamUlysses/ulx/blob/b7adea4fed9d3b582dabc3db5d198cbda899b2a7/lua/ulx/data.lua#L125
It can all be controlled through XGUI, and console.

Basically, you'd want rslots set to number of max players, rslotsMode 2, and ensure "ulx reservedslots" permission is granted to any group below admin you want for access. (admin and inheritance above get by default)

We used to have password - but I'm pretty sure we got rid of it.

In theory, you could password protect your server and maintain a list of people to share with, but then you'd have to worry about bad actors sharing the password.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Restricting ulx groups to join a server
« Reply #3 on: August 03, 2018, 04:10:22 PM »
He could, but the problem with allowing them to join is they get all the downloads first. This can be annoying for players and taxing on a server. The best way to do whitelisting is through the authed hook so it'll boot them before they join.

Offline Shu | Pexie

  • Newbie
  • *
  • Posts: 10
  • Karma: 0
  • Polyglot guy here!
Re: Restricting ulx groups to join a server
« Reply #4 on: August 09, 2018, 08:46:27 AM »
I was checking how i could make this code and then i saw the CheckPassword hook and i was wondering if using that would solve my problem too...

Also do you guys know the difference between the strings "svPassword" and "clPassword"?