AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   [ANY] Map Slots Locker (https://forums.alliedmods.net/showthread.php?t=335924)

Dragokas 01-14-2022 13:47

[ANY] Map Slots Locker
 
1 Attachment(s)
Author: Dragokas (idea by rin-ale).

Description:
  • Prevents to join the server via temporarily locking the slots down to 1 on specified maps.
  • Specially designed to "walkaround/bypass" L4D custom maps "missing stringtable" crash*, happened when somebody join the map in the middle-game.
    * Also known in crash logs as:
    Quote:

    Host_Error: Overflow error writing string table baseline Scenes
  • You can use this plugin for developer purposes as well by locking the server via admin commands (slots aren't unlocked automatically in such case on map change).

Map list is stored here (add new map names to lock the slots on them):
  • data/maplocker_list.txt

Specific:
  • Only transitioned players are allowed to start playing that specific maps. Other players can no longer join the server until the map finishes.
  • Slots are hooked in a way preventing other plugins to change the value until map finishes.
  • You can find more information about the crash in the topic: https://github.com/ValveSoftware/Sou...es/issues/3451 | https://forums.alliedmods.net/showthread.php?t=305123
  • Bugged map names could be found in crash logs. See example in above topics.
  • At the moment list contains 23 L4D1 maps.
  • Please, report map names with a such bug to populate the list.

TODO
  • There are more TODOs, intended for security improvements... not listed here for safe.

Settings (ConVars):
cfg/sourcemod/sm_maplocker.cfg:
PHP Code:

// Enable this plugin? (1 - Yes, 0 - No)
sm_maplocker_enable "1" 

Commands: ("z" flag)
PHP Code:

// Lock the map
sm_maplock

// Unlock the map
sm_mapunlock 

Installation
- Unpack and copy everything to addons/sourcemod/
ChangeLog:
Spoiler


Donate
Donates are very appreciated and welcomed for further inspiration, make me happy, and make next updates came out more often:
- Patreon (Paypal)
- BitCoin
- Ю.Money

Dragokas 01-28-2022 11:43

Re: [ANY] Map Slots Locker
 
Updated.

Quote:

1.1 (28-Jan-2022)
- Added more map names to the list.

Dragokas 02-21-2022 14:19

Re: [ANY] Map Slots Locker
 
Updated.

Quote:

1.2 (21-Feb-2022)
- Added more map names to the list. Now: 16 L4D1 maps.

Dragokas 05-12-2022 04:10

Re: [ANY] Map Slots Locker
 
Updated.

Quote:

1.3 (12-May-2022)
- Added more map names to the list. Now: 23 L4D1 maps.

cravenge 05-12-2022 11:12

Re: [ANY] Map Slots Locker
 
After some digging around, I think setting "sv_maxplayers" to 1 may not be a good idea at all since not only the slots are limited but also the global MaxClients variable of the game is changed as well and most internal functions rely on the UTIL_* ones that seek the value of this variable which in turn would cause some strange oddities.

Maybe blocking mid-game connections through OnClientConnect (SM) / OnClientPreConnect (ConnectHook extension) would be a better solution?

Dragokas 05-12-2022 13:13

Re: [ANY] Map Slots Locker
 
2 Attachment(s)
Whaaaat? What is your test environment?

PHP Code:

public Action CmdMapLock(int clientint args)
{
    
PrintToChatAll("MaxClients (before) = %i"MaxClients);
    
LockSlots();
    
g_bSlotsLockedForce true;
    
CPrintToChat(client"%t""slots_lock");
    
PrintToChatAll("MaxClients (after) = %i"MaxClients);
    return 
Plugin_Handled;
}

public 
Action CmdMapUnlock(int clientint args)
{
    
PrintToChatAll("MaxClients (before) = %i"MaxClients);
    
UnlockSlots();
    
g_bSlotsLockedForce false;
    
CPrintToChat(client"%t""slots_unlock");
    
PrintToChatAll("MaxClients (after) = %i"MaxClients);
    return 
Plugin_Handled;



Dragokas 05-12-2022 15:07

Re: [ANY] Map Slots Locker
 
But it is good to have opportunity to send some meaningful message to client instead of just locking.
However, OnClientConnect may be too late. Need testing, which is not the easy part.
Need concrete map, 2 people, and also bug is not always reproduced.

cravenge 05-12-2022 20:27

Re: [ANY] Map Slots Locker
 
Quote:

Originally Posted by Dragokas (Post 2779243)
Whaaaat? What is your test environment?

PHP Code:

public Action CmdMapLock(int clientint args)
{
    
PrintToChatAll("MaxClients (before) = %i"MaxClients);
    
LockSlots();
    
g_bSlotsLockedForce true;
    
CPrintToChat(client"%t""slots_lock");
    
PrintToChatAll("MaxClients (after) = %i"MaxClients);
    return 
Plugin_Handled;
}

public 
Action CmdMapUnlock(int clientint args)
{
    
PrintToChatAll("MaxClients (before) = %i"MaxClients);
    
UnlockSlots();
    
g_bSlotsLockedForce false;
    
CPrintToChat(client"%t""slots_unlock");
    
PrintToChatAll("MaxClients (after) = %i"MaxClients);
    return 
Plugin_Handled;



i don't mean SM's but rather the game's. I remember fiddling with UTIL_PlayerByIndex before.

Whenever the maximum amount of available slots is changed, it's also reflected in that function. If "sv_maxplayers" is set to 1, it will only verify the first client as a valid player and invalidate everyone else. For SourceTV enabled servers, only the SourceTV bot will be verified.

cravenge 11-24-2022 20:11

Re: [ANY] Map Slots Locker
 
Update on my findings, saving the Steam IDs of clients who played in the previous map before it transitions to the faulty one and blocking newcomers with the use of OnClientPreConnect forward from ConnectHook extension seems to suffice as a bugless temporary fix for now since ConnectClient function runs before WriteBaselines.

Dragokas 11-25-2022 18:00

Re: [ANY] Map Slots Locker
 
Thank you. If that works, it must be a genius temporarily solution.


All times are GMT -4. The time now is 14:46.

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