PDA

View Full Version : [L4D] Reserved slots with no wasted slots


strontiumdog
01-22-2009, 02:16
We have been using this at TheVille for quite some time and it works on all 17 of our Source engine servers. This particular one is for L4D.
I thought I would post it here.
Hopefully it will help some out until VALVe release the SDK and the devs can get a proper reserved slots plugin written.

This plugin does not require extra hidden slots.

When the command "reservedslot 1" is sent to the game server, a slot is opened, by kicking a player.
The plugin automatically closes the slot after a period of time (default 45 seconds) which is usually enough time for the reserved slot player to get into the game.

Players with RESERVATION and CUSTOM1 permissions are immune from kicking.

Players with RESERVATION can occupy an opened slot.

To send the command, you usually need to send it by RCON. As a result, I have also enclosed a small PHP utility (written by a user on the BeetlesMod forums from where the idea was taken) which will send the command to the game server.
If you wish to use this, then place all three files on a web server with PHP. Edit the IP address and Rcon password in the 'reserve.php' file.
It's not a great system and we haven't used it ourselves for a while, but it will do if you need to open slots via a web page.

We no longer use the above PHP program as we now have a proprietary in-game system (http://i56.photobucket.com/albums/g190/johnnyalpha/stage3.jpg) that is based on PHPBB permissions and can be operated directly via the Valve in-game browser.

Also includes an Admin menu item under Server Commands from which admins can manually open and close the slot.

Installation
Copy l4d_reservedslots.smx to addons/sourcemod/plugins
If required, edit and copy the three PHP files to a web server. Make sure you enter the IP, RCON password and the max number of clients in the 'reserve.php' file.
Configuration
sm_reservedslot_time 45.0
default 40.0 seconds
Determines how long the slot stays open

sm_reserve_kicktype 0
0 = Highest Ping
1 = Highest Time
2 = Random
3 = Lowest Time


Credits
The plugin is based on AlliedModders existing reserved slot plugin.


Notes
You can test the script works by using HLSW to open the slot by typing 'reservedslot 1' in the Rcon section. The slot will only open if the server is full.


Changelog
v1.0.105 - Release

v1.0.106 - Added kick by lowest time on server

v1.0.107 - Fixed small bug in cvar

v1.0.108 - Wasn't kicking lowest time clients....

v1.0.109 - ...but does now

djromero
01-22-2009, 12:59
I have something like this in my custom (and private) admin mod, but let me tell you that it works sometimes, why?? because l4d servers become full very quickly .... there's always someone trying to connect to a game in progress.

As soon as my plugin kicks a player, someone else will try to connect ... and another one after that one .... so the reserved slot will always be occupied by people "trying" to connect to our server.

The best way for a connecting player to beat them is to setup the "auto-retry" option on the server browser.

36169

So the best way to go is to use your plugin and this method to connect to the server.

Dark-Reaper
01-22-2009, 15:26
It's a useful plugin, but for the moment I do like this :

I launch my game, press F12, put the auto-retry function on. Go back to Windows with HLSW opened, kick a player, and if I'm lucky, I'll be the next player who try to connect after the kick.

Sometimes I'm not... :|



EDIT :

Tried your plugin and it rocks, could you make it kick the less spend time player on the server ?

Darin
01-22-2009, 18:08
Yeah that would be good. Make it kick the last person who joined the server.

strontiumdog
01-22-2009, 21:37
Yup.
Will update it.

Big Myke
01-22-2009, 22:43
How do I give " ADM_RESERVATION" to a player?

strontiumdog
01-22-2009, 23:13
Letter 'a'

http://wiki.alliedmods.net/Adding_Admins_(SourceMod (http://wiki.alliedmods.net/Adding_Admins_%28SourceMod))

e.g. in admin_simple.ini

"STEAM_0:1:12345678" "a"

Big Myke
01-22-2009, 23:37
Ohhh duh, thanks haha. I was confused for some reason.

Big Myke
01-23-2009, 11:08
I cannot set it to kick randomly. this is what i get. It stays at number 2 which kicks randomly and its the max integer.

10:06:34 "sm_reserve_kicktype" = "2.000000" ( def. "0" ) min. 0.000000 max. 2.000000
- How to select a client to kick (if appropriate)

DevilsReject
01-23-2009, 22:22
this is not working i get this error
StatusPHPError: Connection timed out (110)

strontiumdog
01-23-2009, 23:02
Test the actual plugin is working first. In HLSW, type
'reservedslot 1' and see if it opens a slot (or if not full, will tell you in console)

That error comes from the PHP part of the plugin (which is not mine).
Try extending the time out - change the 30s timeout in line 15 to 60s.
Also check you have the right rcon password entered in reserve.php....

Big Myke
01-23-2009, 23:12
Is there a reason why I cannot choose to kick randomly? The max integer for the cvar is 2.0.

strontiumdog
01-24-2009, 00:45
Random is 2.
So if you set it to 2, it should kick randomly...

I'll take a look at it tonight and see if there is a bug.

DevilsReject
01-24-2009, 01:09
ok if i am not connected to the server, how can i kick someone if the php section times out?

Big Myke
01-24-2009, 12:23
I'm sorry, I mean I'd like to kick the lowest time, which is 3 and I cannot choose 3 because the max number is 2 as you can see.

strontiumdog
01-24-2009, 16:08
@Myke: Fixed the bug. Re-download and try again.

@DevilsReject: Are there any ports blocked on the web server? Is your web server hosted? The timeout might be happening because the web server is unable to send the rcon command to open the reservedslot on the game server.

Big Myke
01-24-2009, 21:17
Thanks for the update, I tested it out and the cvar is set to 3 yet it still kicks randomly. If it doens't kick randomly, it sure doesn't kick the lowest time played person.

Dark-Reaper
01-25-2009, 08:50
Thanks for the update, I tested it out and the cvar is set to 3 yet it still kicks randomly. If it doens't kick randomly, it sure doesn't kick the lowest time played person.

Same for me, it doesn't kick the lowest time spent player on the server... :|

Big Myke
01-25-2009, 12:55
I hate to break it to you but it still doens't kikc the lowest played person on my team. even after the patch. I'm not kidding. Dark-Reaper, let me know if it works for you nwo after the update.

Dark-Reaper
01-25-2009, 12:59
I hate to break it to you but it still doens't kikc the lowest played person on my team. even after the patch. I'm not kidding. Dark-Reaper, let me know if it works for you nwo after the update.


No, it seems to kick randomly even if I put the variable on 3. :|

strontiumdog
01-26-2009, 01:37
OK.
I changed the whole method of kicking by least time on the server.

Should work now.

santaclaus
01-26-2009, 09:54
OK.
I changed the whole method of kicking by least time on the server.

Should work now.

Does that mean that we don't need that cvar anymore ?

sm_reserve_kicktype 0
0 = Highest Ping
1 = Highest Time
2 = Random
3 = Lowest Time

strontiumdog
01-26-2009, 10:29
No.
The other methods still work, so you need the cvar.

Technical explanation.
The old method of kicking by least time on the server involved checking everyone's time on the server and finding the shortest one and kicking them (except people with custom1 and reservation of course). The detection method was not reliable.

So I decided to implement a LIFO - last in first out.
This is an ADT array where your client number gets stored in the array. If you leave, the client number is removed. If you are the last one in, you will be the first to go....

Hope this makes sense
:D

I might suggest to the devs to add this to the normal SM reserved slot plugin.

Darin
01-26-2009, 17:54
It is not working properly, when I set it to the lowest time. And I type reserved slot 1 in HLSW it kicks the player with the least time, but when it enters into L4D another player connects before me. It won't keep the slot open...

sm_reservedslot_time 30.0
sm_reserve_kicktype 3

This is what I have set in the sourcemod.cfg file

Big Myke
01-26-2009, 19:30
It is not working properly, when I set it to the lowest time. And I type reserved slot 1 in HLSW it kicks the player with the least time, but when it enters into L4D another player connects before me. It won't keep the slot open...

sm_reservedslot_time 30.0
sm_reserve_kicktype 3

This is what I have set in the sourcemod.cfg file



I have the same problem ='(

strontiumdog
01-26-2009, 20:56
http://forums.alliedmods.net/showpost.php?p=748170&postcount=2

Set up autojoin BEFORE you open the slot.
You should connect immediately a person gets kicked.

Darin
01-26-2009, 22:10
Ahh, it's too bad that HLSW doesn't have an auto join option. I can just use it in L4D I guess :).

Thanks!

strontiumdog
01-26-2009, 22:23
You could make the delay longer. It would keep kicking people until you managed to get in.

ProdigyXP
01-27-2009, 12:31
this is not working i get this error
StatusPHPError: Connection timed out (110)

I'm getting the exact same error. I think it has something to do with my free host blocking the port perhaps. Does anyone know of a free host that this actually works with? I love the idea rather than having my admins running 3rd party programs that give out the rcon password.

Dark-Reaper
01-28-2009, 12:04
Ahh, it's too bad that HLSW doesn't have an auto join option. I can just use it in L4D I guess :).

Thanks!

There is an auto-join option. :|

Dark-Reaper
01-29-2009, 08:10
Guy I'm so sorry but your plugin definitly doesn't kick the lowest spend time player on the server, the thing that you've done with the ID Number I don't know what, was wrong, there is an example of why :

http://www.noelshack.com/uploads/Plugin080742.jpg (http://www.noelshack.com/)

Big Myke
01-29-2009, 13:32
is this dev even testing his own work before stating that it works? I'm with you dark, does this pluggin even kick the highest pinger? haha Does it even kick the lowest pinger? or the MOST time played person. for all i know - it only kicks randomly and let alone its tricky to use your own reserved slot. I thought reserved slots are only reserved to those with the reserve admin level?

Dark-Reaper
01-29-2009, 14:07
is this dev even testing his own work before stating that it works? I'm with you dark, does this pluggin even kick the highest pinger? haha Does it even kick the lowest pinger? or the MOST time played person. for all i know - it only kicks randomly and let alone its tricky to use your own reserved slot. I thought reserved slots are only reserved to those with the reserve admin level?

The plugin kicks randomly everytime, that's a bad thing, but it's not the worst, the worst is : My slot is everytime used by guys connecting, and connecting to a full server cause my game freeze, and I need to restart, could someone, a great guy, the best guy, the best guy in this world, could make a plugin that adds one slot, just one, a spectator slot, EVERYTIME avaible ?

strontiumdog
01-29-2009, 18:46
What can I say?
It works fine in our community, with its 18 servers. We have many, many people use it every day. The only issues we have had are with Internet Explorer...

I just thought I'd let the rest of the world enjoy it until VALVe released the SDK and allowed the SM devs to make a proper reserved slot plugin.

I asked bl4nk to move this in here.
I don't have time to rewrite something that I've already spent many hours on. And do I test the plugins....? Of course, every time. But there will also be bugs, every time.
When you get something that's free, and is worked on during the author's limited free time, you have to appreciate there will be problems. No-one gets paid to release their plugins here. We don't have teams and teams of people working on them.

If you want your own working L4D reserved slot plugin, I'd suggest you start with:
http://wiki.alliedmods.net/Introduction_to_SourcePawn

Icettiflow
01-30-2009, 16:04
*shrug* Sorry you got that impression from this thread Strontiumdog. I'm using the plugin, and it certainly works for my needs. Nice work.

AcidTester
02-03-2009, 12:46
The plugin kicks randomly everytime, that's a bad thing, but it's not the worst, the worst is : My slot is everytime used by guys connecting, and connecting to a full server cause my game freeze, and I need to restart, could someone, a great guy, the best guy, the best guy in this world, could make a plugin that adds one slot, just one, a spectator slot, EVERYTIME avaible ?

Agree with Dark-Reaper, plugin doesn't kick the lowest spend time player on the server, instead it kicks randomly and more, when sm_reserve_kicktype 3, my server hangs on and drops everybody when i reservedslot 1, so i need restart server manually.
Any ideas whats the prob?

strontiumdog
02-03-2009, 15:23
Lowest time kicking is apparently not working.
Set it to 1 or 2.

Maybe somewhere down the line, I'll get time to make up a work around...

protatoe
02-04-2009, 18:33
I'd like to point out that in addition to the "Intro to SourcePawn", these scripts that have been posted for our enjoyment are also an incredible source of knowledge. It took all of 5 minutes to figure out what chunk of code is responsible for going wrong. SelectKickClient(). I'm sure someone with a little bit more time then the author has can figure it out to work for their suitability.

santaclaus
02-05-2009, 17:18
if you're still willing to support it, it would be nice if the admin could choose the client to kick.

GL.

Zeusbba
04-14-2009, 19:57
Love to see this up and running with SDK coming out soon. Whats the chance of getting the in game browser setup too?

strontiumdog
04-14-2009, 22:35
Oh, it still works. In fact, I even got it working properly with the last in first out that was causing them so much grief.

It worked perfectly with all the other methods such as random/high ping/longest time. It was just getting it to work with the person who had the least time on the server, was the biggest problem.

If I get time, I may ask Bl4nk to move it back to new plugins and we'll see....

When VALVe fixed the in-game browser, it became a whole lot better.

DontWannaName
04-15-2009, 01:02
Good news :)

Zeusbba
04-15-2009, 10:51
Nice to hear, +Karma given. :wink:

Icettiflow
04-15-2009, 13:17
SD, it would be fantastic if you could continue supporting and updating this bad boy. :comply:

Zeusbba
04-17-2009, 11:49
Anyone using this, how are you admin ing it? Handing all my members rcon access isnt an option and the very unsure of that php utility :?

AtomicStryker
04-23-2009, 03:49
From what i see, this plugin detects gamemode/max players by reading the mapname (checking for "vs") .. how about reading mp_gamemode now that it exists?

Also, could you maybe implent a System so one can manually select the Kicked Player, maybe via sm_admin menu?


EDIT:
The first i managed by myself
Function by DDR Khat (https://forums.alliedmods.net/showpost.php?p=811559&postcount=164)

public OnMapStart()
{
new String:gmode[32];
GetConVarString(FindConVar("mp_gamemode"),gmode,sizeof(gmode));
if (strncmp(gmode,"versus",sizeof(gmode),false)==1)
{
g_MaxClients = 8
}
else
{
g_MaxClients = 4
}
}

Zeusbba
05-22-2009, 10:22
With the release of the SDK, any news on an automatic version of this where you dont need to push any buttons etc, just simply try and join the server?

Downtown1
05-22-2009, 14:44
With the release of the SDK, any news on an automatic version of this where you dont need to push any buttons etc, just simply try and join the server?

http://forums.alliedmods.net/showthread.php?t=91132

Zeusbba
05-22-2009, 18:18
http://forums.alliedmods.net/showthread.php?t=91132

I have yours running with readyup, just wondering if say, you run a VS that you want up 24/7 with max players and no return to lobby, if its full have the ability for clan members to simply try and connect and it would kick a non admin to open a slot.

Downtown1
05-22-2009, 18:26
I have yours running with readyup, just wondering if say, you run a VS that you want up 24/7 with max players and no return to lobby, if its full have the ability for clan members to simply try and connect and it would kick a non admin to open a slot.

If you use the normal reservedslots it should work I guess. Just set sv_visiblemaxplayers to a lower value then l4d_maxplayers.

KrankFL
06-03-2009, 12:38
Will there be an automated reserved slots plugin thats doesnt require us to type stuff? may as well just use the kick command to drop a random player by hand.

What I would like to see is that when an admin tries to connect to his server a client is automatically dropped and the admin is allowed into the server, thats all.

Also I'm not looking for a plugin or extension with extra stuff, just a simple working automated reserved slots plugin.

What would be the point of having extra reserved slots that are not useful whatsoever maybe only for spectating purposes, on my server admins play, I have a 5 vs 5 server, so if you would connect in that manner you would become a spectator and not being able to join the game because the max players per team is capped.

DJ Tsunami
06-03-2009, 12:49
So why not use the Reserved Slots plugin that comes with SourceMod? Or any of the other solutions posted on these forums.

KrankFL
06-03-2009, 12:51
So why not use the Reserved Slots plugin that comes with SourceMod? Or any of the other solutions posted on these forums.

Its not working, unfortunately, I don't know why, it is not kicking players automatically, no matter what settings I use.

What I have tried, setting admin reserve flags in simple admin ini and using these settings:
sm_reserve_type 1
sm_reserved_slots 2
sm_reserve_maxadmins 2
sm_reserve_kicktype 0

When I try to connect to my server through the connect command nothing happens, it just tells me it is full.

Icettiflow
06-07-2009, 15:14
So why not use the Reserved Slots plugin that comes with SourceMod? Or any of the other solutions posted on these forums.

This has never worked. Left 4 Dead is not the typical source game as i'm sure you're aware with regards of how players and bots are counted. The other reserved slots systems just. don't. work.

PeterFreimann
01-31-2010, 04:37
I get this error many times a minute:

Native "RemoveFromArray" reported: Invalid index 44 (count: 44)
L 01/31/2010 - 10:34:16: [SM] Displaying call stack trace for plugin "l4d_reservedslots.smx":
L 01/31/2010 - 10:34:16: [SM] [0] Line 139, /home/groups/alliedmodders/forums/files/2/4/5/7/3/36302.attach::OnClientDisconnect_Post()

strontiumdog
01-31-2010, 10:06
Try this version...

It gets rid of the arrays and when selecting a player for kicking by shortest time on the server, it looks at the length of time on the server.

PeterFreimann
02-06-2010, 08:48
Thx for this version. The error is gone, but now it has a much bigger error ;)

Kick Method: Lowest Time
Spectator Kicked: 3
Cannot open slot - not max clients (4)

It kicks no one and doesn't open a slot.
So no slot is beeing opend because my server runs 10 Players?