Ulysses

General => Developers Corner => Topic started by: Eccid on July 19, 2013, 07:57:06 AM

Title: CheckPassword hook for reserve slots
Post by: Eccid 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 (http://pastebin.com/DAD33j5h).
Title: Re: CheckPassword hook for reserve slots
Post by: JamminR 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.
Title: Re: CheckPassword hook for reserve slots
Post by: Eccid 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
Title: Re: CheckPassword hook for reserve slots
Post by: JamminR 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.
Title: Re: CheckPassword hook for reserve slots
Post by: LostAlien on July 20, 2013, 11:35:29 AM
CheckPassword hook is run at the same time as gatekeeper's hook is
Title: Re: CheckPassword hook for reserve slots
Post by: Megiddo 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).
Title: Re: CheckPassword hook for reserve slots
Post by: JamminR 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.

Title: Re: CheckPassword hook for reserve slots
Post by: Eccid 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 (http://pastebin.com/DAD33j5h)

Update: It must have been a fluke because donators have been joining on reserve just fine. Should I move this to a different section?
Title: Re: CheckPassword hook for reserve slots
Post by: Storm 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?
Title: Re: CheckPassword hook for reserve slots
Post by: Eccid 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. (http://pastebin.com/DAD33j5h)
Title: Re: CheckPassword hook for reserve slots
Post by: Storm on September 14, 2013, 12:02:45 PM
Thanks! I'll try it!
Title: Re: CheckPassword hook for reserve slots
Post by: iSnipeu 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
Title: Re: CheckPassword hook for reserve slots
Post by: Eccid 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.
Title: Re: CheckPassword hook for reserve slots
Post by: iSnipeu 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.
Title: Re: CheckPassword hook for reserve slots
Post by: Storm 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.
Title: Re: CheckPassword hook for reserve slots
Post by: Storm on October 05, 2013, 03:07:02 AM
Has anyone got this to work?
Title: Re: CheckPassword hook for reserve slots
Post by: Eccid on October 11, 2013, 09:23:51 PM
It says in the opening post that it works. Been working fine for me.
Title: Re: CheckPassword hook for reserve slots
Post by: Storm on October 12, 2013, 06:33:13 AM
I am still getting minute and a half hang up times. Should this revised slots.lua eliminate all hang up or just shorten it?
Title: Re: CheckPassword hook for reserve slots
Post by: Eccid on October 12, 2013, 12:04:45 PM
I am still getting minute and a half hang up times. Should this revised slots.lua eliminate all hang up or just shorten it?
I don't know what you mean by hang up times, but looking at your past post you said you're using mode 1. This addon is really only used for mode 2, or at least, that's what I made it work for. I didn't change how anything else works, howver, but you issue may be resolved by just replacing this with the default module from ulx.
Title: Re: CheckPassword hook for reserve slots
Post by: Storm on October 12, 2013, 02:18:30 PM
Sry but by default module do you mean the original slots.lua? That is the module i am trying to fix. When I try to join one of my servers, I have to wait up to 4 minutes for a player to load in and THEN get kicked. I just want it to kick him when he first tries to join. So I need to use mode 2 for this to work?
Title: Re: CheckPassword hook for reserve slots
Post by: Eccid on October 12, 2013, 05:33:22 PM
Yeah, I meant the original slots.lua. If you want your server to work with what I wrote, you need to use mode 2. You can feel free to modify it to work with different modes, I just prefer mode 2, so that's what I made it for.
Title: Re: CheckPassword hook for reserve slots
Post by: Storm on October 14, 2013, 08:10:00 AM
Ok thanks! I will use mode 2 also so that this will work. In your lua, you have that at mode 0 so I just need to change that to 2 right?
Title: Re: CheckPassword hook for reserve slots
Post by: Eccid on October 15, 2013, 07:09:52 AM
Ok thanks! I will use mode 2 also so that this will work. In your lua, you have that at mode 0 so I just need to change that to 2 right?

You don't have to change anything in my script to make it work for mode 2, you only need to change your settings.
Title: Re: CheckPassword hook for reserve slots
Post by: Storm on October 18, 2013, 04:35:14 AM
I'm afraid this still doesn't work for me. I replaced the original slots lua with this one and changed nothing with it. I put my mode at 2 in ulx on my servers. That's all I did. Still, players load for up to 4 minutes before they are kicked and admins have to sit and wait to use the reserved slot.
Title: Re: CheckPassword hook for reserve slots
Post by: Eccid on October 18, 2013, 10:51:16 AM
I'm afraid this still doesn't work for me. I replaced the original slots lua with this one and changed nothing with it. I put my mode at 2 in ulx on my servers. That's all I did. Still, players load for up to 4 minutes before they are kicked and admins have to sit and wait to use the reserved slot.

Not sure what to tell you then, it's been working just fine for me. Just make sure the files are in the right place and that you restart your server after you've added it.
Title: Re: CheckPassword hook for reserve slots
Post by: Storm on October 22, 2013, 06:09:01 AM
Just to make sure. I simply replace the original slot.lua with this one right? You say make sure the files are in the right place but this is the only file, right?
Title: Re: CheckPassword hook for reserve slots
Post by: Eccid on November 02, 2013, 09:42:47 AM
Just to make sure. I simply replace the original slot.lua with this one right? You say make sure the files are in the right place but this is the only file, right?

Correct