From b2be16c4ce6fa75f1f09a7b38e5bbdbd034dcf6f Mon Sep 17 00:00:00 2001 From: Pierce Date: Sun, 9 Jun 2024 15:05:26 -0400 Subject: [PATCH] add method to set min and max player count for maps --- lua/mapvote/server/modules/map_vote.lua | 6 ++++++ lua/mapvote/shared/modules/config_schema.lua | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/lua/mapvote/server/modules/map_vote.lua b/lua/mapvote/server/modules/map_vote.lua index b5b6830..8d7bc3e 100644 --- a/lua/mapvote/server/modules/map_vote.lua +++ b/lua/mapvote/server/modules/map_vote.lua @@ -6,6 +6,12 @@ function MapVote.isMapAllowed( m ) if not conf.AllowCurrentMap and m == game.GetMap():lower() then return false end -- dont allow current map in vote + if conf.MapConfig and conf.MapConfig[m] then + local cfg = conf.MapConfig[m] + if cfg.MinPlayers and player.GetCount() < cfg.MinPlayers then return false end + if cfg.MaxPlayers and cfg.MaxPlayers ~= 0 and player.GetCount() > cfg.MaxPlayers then return false end + end + if conf.ExcludedMaps[m] then return false end -- dont allow excluded maps in vote if conf.IncludedMaps[m] then return true end -- skip prefix check if map is in included maps diff --git a/lua/mapvote/shared/modules/config_schema.lua b/lua/mapvote/shared/modules/config_schema.lua index 31453d3..42c3c87 100644 --- a/lua/mapvote/shared/modules/config_schema.lua +++ b/lua/mapvote/shared/modules/config_schema.lua @@ -15,8 +15,13 @@ local schema = SV.Object { RTVPlayerCount = SV.Int { min = 1 }, ExcludedMaps = SV.Map( SV.String(), SV.Bool() ), IncludedMaps = SV.Map( SV.String(), SV.Bool() ), + MapConfig = SV.Map( SV.String(), SV.Object( { + MinPlayers = SV.Int { min = 0 }:Optional(), + MaxPlayers = SV.Int { min = 0 }:Optional(), + } ) ):Optional(), PlyRTVCooldownSeconds = SV.Int { min = 1 }, MapIconURLs = SV.Map( SV.String(), SV.String() ):Optional(), + } local default = { @@ -35,6 +40,7 @@ local default = { SortMaps = false, PlyRTVCooldownSeconds = 120, MapIconURLs = {}, + MapConfig = {}, } MapVote.configSchema = schema