Author Topic: CheckPassword hook for reserve slots  (Read 8935 times)

0 Members and 2 Guests are viewing this topic.

Offline Eccid

  • Full Member
  • ***
  • Posts: 115
  • Karma: 11
  • Hey, come on... We just met...
    • Terror Abound! Steam Group
CheckPassword hook for reserve slots
« on: July 19, 2013, 07:57:06 AM »
Last night my server was full, and because of the way ulx handles the slots (i use mode 2) people would join in, and then be kicked; which was a problem. It was hard to join on reserve slots because when someone was joining without access, they still took up the slot until they got in and got kicked, and if they need to download the map or resources from the server they could be using the slot for a while. I tried a bunch of different ways to do this this morning and failed miserably. Do you think you guys could add this funtionality? It would be great if they were just blocked before entering. Here's the last attempt I made, maybe you guys can fix what I did wrong. It's the slots.lua file.

(For use with mode 2 of reserve slots)
After much deliberation, my issue was solved. If you want people to be blocked from joining your server if they don't have access to the reserve slots, replace your slots.lua with this one.
« Last Edit: October 12, 2013, 12:05:21 PM by Eccid »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: CheckPassword hook for reserve slots
« Reply #1 on: July 19, 2013, 03:16:47 PM »
I'm pretty sure players will still take up map/model/whatever file download slots before Lua ever sees them.
Even if you get your code working, they'd most likely be kicked before having the chance to enter a password.

I don't think this function actually starts 'before' the Lua engine, like the Source sv_password hardcoded checks do.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Eccid

  • Full Member
  • ***
  • Posts: 115
  • Karma: 11
  • Hey, come on... We just met...
    • Terror Abound! Steam Group
Re: CheckPassword hook for reserve slots
« Reply #2 on: July 19, 2013, 03:29:52 PM »
It works like gatekeeper, it blocks them from joining when returned false.

http://gmodwiki.net/Lua/Hooks/Base/CheckPassword

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: CheckPassword hook for reserve slots
« Reply #3 on: July 19, 2013, 03:50:42 PM »
Eccid, I read that wiki before posting.
It's an sv_password "emulator".
Gatekeeper runs before Lua does. (its some type of server hard coded dll or exe)
The Sv_password runs before lua does. (It's part of the source server hard code gmod is built on)
That command, which is part of G-lua, will only run after lua has started.
Which, unless Gm13 changed things (and some of my dev friends here will correct me and I'll gladly accept I'm incorrect), Lua starts right before the player spawns.
Meaning, people will still be able to connect to your server, start downloads, fill a slot for a while, before Lua starts and checks with that hook.

It's still a cool idea, but, won't protect you from the same reason you don't like the fact they connect/get kicked.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline LostAlien

  • Newbie
  • *
  • Posts: 3
  • Karma: -3
Re: CheckPassword hook for reserve slots
« Reply #4 on: July 20, 2013, 11:35:29 AM »
CheckPassword hook is run at the same time as gatekeeper's hook is

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6213
  • Karma: 394
  • Project Lead
Re: CheckPassword hook for reserve slots
« Reply #5 on: July 20, 2013, 12:40:48 PM »
The best solution to this is to set the extra slots to be invisible and instruct your VIPs how to join in those cases (through console).
Experiencing God's grace one day at a time.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: CheckPassword hook for reserve slots
« Reply #6 on: July 20, 2013, 04:27:07 PM »
CheckPassword hook is run at the same time as gatekeeper's hook is
The Lua hook is, yes, and is server-side.
The actual gatekeeper code is binary, running before the server connection allows client to start doing stuff.
With gatekeeper, player connects, gatekeeper binary intercepts - checks against lua controlled server side script "can player connect?" and then does whatever (allows/drops mid stream), allowing player to start downloading resources or connecting if the binary gets 'yes' response.
With PlayerCheckPassword, I'm pretty sure there is no interception, other than the split second before the player object has fully initialized on the server.

I might be wrong, but, I think all it does is, after the player has joined server, downloaded resources, synced snapshot, it then checks to see if they're allowed.
After the fact it's too late of what he'd want.

"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Eccid

  • Full Member
  • ***
  • Posts: 115
  • Karma: 11
  • Hey, come on... We just met...
    • Terror Abound! Steam Group
Re: CheckPassword hook for reserve slots
« Reply #7 on: July 21, 2013, 09:03:34 AM »
Ok, I got it working, for the most part. The hook apparently gets the users 64bit steam id, so I had to convert it before it would work, and apparently the built in gmod one doesn't work right. It now blocks anyone from joining who doesn't have access to reserve as soon as they click the join server button. The only issue is that it only allows for admins to join on reserve and not donators as well. You can see in what I posted, I added allowed_groups and get the same result, admins can join but not donators. So, any further help would be appreciated.

Pastebin

Update: It must have been a fluke because donators have been joining on reserve just fine. Should I move this to a different section?
« Last Edit: July 24, 2013, 11:53:40 AM by Eccid »

Offline Storm

  • Full Member
  • ***
  • Posts: 220
  • Karma: 4
Re: CheckPassword hook for reserve slots
« Reply #8 on: August 24, 2013, 04:32:13 AM »
This problem has been an issue for me too. Do I just add the bit of code at the end of the slots.lua that you did or is there something else I need to do?
« Last Edit: August 24, 2013, 09:42:03 AM by Storm »

Offline Eccid

  • Full Member
  • ***
  • Posts: 115
  • Karma: 11
  • Hey, come on... We just met...
    • Terror Abound! Steam Group
Re: CheckPassword hook for reserve slots
« Reply #9 on: September 14, 2013, 10:06:11 AM »
This problem has been an issue for me too. Do I just add the bit of code at the end of the slots.lua that you did or is there something else I need to do?

Sorry it took so long to respond, I haven't been on the ulysses site in a bit. Replace your slots.lua with this one.

Offline Storm

  • Full Member
  • ***
  • Posts: 220
  • Karma: 4
Re: CheckPassword hook for reserve slots
« Reply #10 on: September 14, 2013, 12:02:45 PM »
Thanks! I'll try it!

Offline iSnipeu

  • Jr. Member
  • **
  • Posts: 83
  • Karma: 12
Re: CheckPassword hook for reserve slots
« Reply #11 on: September 15, 2013, 01:49:08 AM »
You don't need the "tosteamid" function as garry has made a function that does that already. http://wiki.garrysmod.com/page/util/SteamIDFrom64

Offline Eccid

  • Full Member
  • ***
  • Posts: 115
  • Karma: 11
  • Hey, come on... We just met...
    • Terror Abound! Steam Group
Re: CheckPassword hook for reserve slots
« Reply #12 on: September 15, 2013, 07:32:16 PM »
You don't need the "tosteamid" function as garry has made a function that does that already. http://wiki.garrysmod.com/page/util/SteamIDFrom64

I used that first, and it wouldn't work, and I found that snippet looking for an alternate. There's a chance it just wasn't working in whatever version of gmod I made this on. Either way, it works, so I'm not changing it :P Feel free to change it how you wish.

Offline iSnipeu

  • Jr. Member
  • **
  • Posts: 83
  • Karma: 12
Re: CheckPassword hook for reserve slots
« Reply #13 on: September 16, 2013, 12:39:09 AM »
I used that first, and it wouldn't work, and I found that snippet looking for an alternate. There's a chance it just wasn't working in whatever version of gmod I made this on. Either way, it works, so I'm not changing it :P Feel free to change it how you wish.

Yeah it was broken for awhile, but got fixed in May.

Offline Storm

  • Full Member
  • ***
  • Posts: 220
  • Karma: 4
Re: CheckPassword hook for reserve slots
« Reply #14 on: September 16, 2013, 02:40:34 PM »
I installed this, uninstall it, reinstalled it. My settings are 1- admins fill slots, # of reserved slots - 1,  reserved slots enabled 1. What happened after i installed it both times is my reserved slots no longer worked at all. Could anyone suggest what I am doing wrong? I have made no other changes whatsoever to reserved slots. I have a ttt server.