Raised This Month: $51 Target: $400
 12% 

[L4D & L4D2] Enforce Gametypes [v1.4 (26-Jun-2023)]


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Mystik Spiral
Senior Member
Join Date: Oct 2020
Location: Orlando, FL
Plugin ID:
8448
Plugin Version:
1.4
Plugin Category:
Server Management
Plugin Game:
Left 4 Dead
Plugin Dependencies:
    Servers with this Plugin:
    21 
    Plugin Description:
    Reject connections for non-allowed game types
    Old 04-25-2023 , 21:15   [L4D & L4D2] Enforce Gametypes [v1.4 (26-Jun-2023)]
    Reply With Quote #1

    .
    Enforce Gametypes (l4d_enforce_gametypes) by Mystik Spiral


    Objective:
    • Prevent client using mm_dedicated_force_servers to override sv_gametypes on server.
    • Reject client connection if mp_gamemode set by lobby reservation is not included in sv_gametypes.

    Description and options:

    My server has sv_gametypes set to "coop,realism,nightmaredifficulty", but I was seeing other active game modes, like "versus", "survival", and "scavenge". I discovered that clients were setting mm_dedicated_force_servers to my server IP address and port, then connecting from lobby. When a client sets mm_dedicated_force_servers (in the client console), it overrides the value for sv_gametypes in the server and allows connections for any mp_gamemode. This simple plugin checks the value of mp_gamemode (set during lobby reservation) and compares it to the values in sv_gametypes... if there is no match the client connection is rejected.

    Please be aware this will block all mutations that are not listed in sv_gametypes, even if the base gamemode for the mutation is listed.

    This plugin does not have any configurable console variables, though it does read the values for the Valve console variables sv_gametypes and mp_gamemode.

    Please ensure these two Valve console variables are explicitly set in the server.cfg file the way you want them:

    sv_hibernate_when_empty
    sb_all_bot_game (sb_all_bot_team for L4D1)


    Notes:

    This plugin does not kick clients, it starts before that and rejects connection to the server for non-matching gamemodes.



    If sv_gametypes is not set in your server.cfg file, it should default to:
    coop, realism, survival, versus, scavenge, dash, holdout, shootzones

    I do not plan to add any new features, but if you find any bugs, please let me know and I will do my best to correct them.


    Credits:

    Mika Misori: mp_gamemode may be set in server.cfg
    Ja-Forces: map names are different in L4D1/2 for same campaign

    Want to contribute code enhancements?
    Create a pull request using this GitHub repository: https://github.com/Mystik-Spiral/l4d_enforce_gametypes

    Plugin discussion: https://forums.alliedmods.net/showthread.php?t=342570


    Changelog:

    Code:
    26-Jun-2023 v1.4
    - Fixed compatibility issue with L4D1
    
    19-Jun-2023 v1.3
    - Fixed issue if mp_gamemode was defined in server.cfg
    
    08-May-2023 v1.2
    - Reject connections if changelevel is already in progress to reset the mp_gamemode.
    
    02-May-2023 v1.1
    - On reject, changelevel to set an allowed mp_gamemode (uses first entry in sv_gametypes).
    
    25-Apr-2023 v1.0
    - Initial release.

    Installation:

    Place the l4d_enforce_gametypes.smx file in the SourceMod "plugins" directory.
    .
    Attached Files
    File Type: sp Get Plugin or Get Source (l4d_enforce_gametypes.sp - 282 views - 8.6 KB)

    Last edited by Mystik Spiral; 01-05-2024 at 19:02. Reason: New version
    Mystik Spiral is offline
    apples1949
    Junior Member
    Join Date: Apr 2021
    Old 04-26-2023 , 00:23   Re: [L4D & L4D2] Enforce Gametypes [v1.0 (25-Apr-2023)]
    Reply With Quote #2

    try this ?
    apples1949 is offline
    Mystik Spiral
    Senior Member
    Join Date: Oct 2020
    Location: Orlando, FL
    Old 04-26-2023 , 08:56   Re: [L4D & L4D2] Enforce Gametypes [v1.0 (25-Apr-2023)]
    Reply With Quote #3

    Thank you @apples1949! That plugin by you/fantasylidong is definitely more elaborate but it seems to have the same goal. Different approaches for sure as that code does not even look at sv_gametypes. Mine simply does not allow the player to connect to the server if mp_gamemode is not in sv_gametypes.

    Last edited by Mystik Spiral; 04-28-2023 at 11:02.
    Mystik Spiral is offline
    tRololo312312
    Senior Member
    Join Date: Apr 2015
    Old 04-28-2023 , 14:27   Re: [L4D & L4D2] Enforce Gametypes [v1.0 (25-Apr-2023)]
    Reply With Quote #4

    "coop" and "realism" etc are base gamemodes, meaning any mutation using those as a base will pass gametypes check like intended. So seeing gunbrain is normal since its a coop mutation and doesnt require "mm_dedicated_force_servers" cvar to get in.
    tRololo312312 is offline
    Mystik Spiral
    Senior Member
    Join Date: Oct 2020
    Location: Orlando, FL
    Old 04-28-2023 , 21:35   Re: [L4D & L4D2] Enforce Gametypes [v1.0 (25-Apr-2023)]
    Reply With Quote #5

    Quote:
    Originally Posted by tRololo312312 View Post
    "coop" and "realism" etc are base gamemodes, meaning any mutation using those as a base will pass gametypes check like intended. So seeing gunbrain is normal since its a coop mutation and doesnt require "mm_dedicated_force_servers" cvar to get in.
    Thank you for that clarification. I changed my example from gunbrain to versus/survival/scavenge, as those game modes were also showing up on my server. This plugin will block all mutations unless they are added to sv_gametypes, even mutations where the base gamemode is in sv_gametypes. That is the behavior I want, but I will add a note about this in the description to make it clear. -done

    Last edited by Mystik Spiral; 04-28-2023 at 21:56.
    Mystik Spiral is offline
    Mi.Cura
    Veteran Member
    Join Date: Dec 2016
    Location: Brazil
    Old 04-29-2023 , 12:15   Re: [L4D & L4D2] Enforce Gametypes [v1.0 (25-Apr-2023)]
    Reply With Quote #6

    Thank´s for share this...
    __________________
    Mi.Cura | Modded Servers | L4D2
    https://steamcommunity.com/groups/micuramodzombie
    Mi.Cura is offline
    Mystik Spiral
    Senior Member
    Join Date: Oct 2020
    Location: Orlando, FL
    Old 05-03-2023 , 07:02   Re: [L4D & L4D2] Enforce Gametypes [v1.1 (03-May-2023)]
    Reply With Quote #7

    Released version 1.1.

    Set mp_gamemode to the first value in sv_gametypes after lobby connection is rejected. Leaving mp_gamemode from rejected lobby connections had no effect on new lobby connections, but it could cause problems with direct (non-lobby) connections.

    Last edited by Mystik Spiral; 05-03-2023 at 07:06.
    Mystik Spiral is offline
    Mystik Spiral
    Senior Member
    Join Date: Oct 2020
    Location: Orlando, FL
    Old 05-18-2023 , 19:56   Re: [L4D & L4D2] Enforce Gametypes [v1.2 (18-May-2023)]
    Reply With Quote #8

    Released version 1.2.

    - Reject connections if changelevel is already in progress to reset the mp_gamemode.

    Last edited by Mystik Spiral; 06-01-2023 at 20:26.
    Mystik Spiral is offline
    Mika Misori
    Senior Member
    Join Date: Sep 2022
    Old 06-18-2023 , 17:10   Re: [L4D & L4D2] Enforce Gametypes [v1.2 (18-May-2023)]
    Reply With Quote #9

    Quote:
    Originally Posted by Mystik Spiral View Post
    Released version 1.2.

    - Reject connections if changelevel is already in progress to reset the mp_gamemode.
    Installed your plugin, but I can still connect to my server with a game mode different from those specified in the config.

    For example, the server config:
    sv_gametypes realism
    sm_cvar mp_gamemode realism

    I write the server address with this config and your plugin in mm_dedicated_force_servers, then create a lobby with survival mode and run the game. I end up on my server, which loads the map in survival mode, but the players appear in an empty saferoom as in a coop campaign and if you look at the TAB, the game mode is realism.

    What am I doing wrong?
    Server on linux with the latest SourceMod and Left 4 DHooks Direct. No errors in the logs, the plugin loads successfully.
    Mika Misori is offline
    Mystik Spiral
    Senior Member
    Join Date: Oct 2020
    Location: Orlando, FL
    Old 06-18-2023 , 22:36   Re: [L4D & L4D2] Enforce Gametypes [v1.2 (18-May-2023)]
    Reply With Quote #10

    Quote:
    Originally Posted by Mika Misori View Post
    For example, the server config:
    sv_gametypes realism
    sm_cvar mp_gamemode realism
    I did not test with only a single value for sv_gametypes (oversight on my part). I suspect an issue with ExplodeString when the string does not have a delimiter (,). I will run some tests and post back.
    Mystik Spiral is offline
    Reply



    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 15:17.


    Powered by vBulletin®
    Copyright ©2000 - 2024, vBulletin Solutions, Inc.
    Theme made by Freecode