Skip to content

Commit

Permalink
add method to set min and max player count for maps (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
plally authored Jun 9, 2024
1 parent 7428df7 commit 5a07ae9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lua/mapvote/server/modules/map_vote.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions lua/mapvote/shared/modules/config_schema.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -35,6 +40,7 @@ local default = {
SortMaps = false,
PlyRTVCooldownSeconds = 120,
MapIconURLs = {},
MapConfig = {},
}

MapVote.configSchema = schema
Expand Down

0 comments on commit 5a07ae9

Please sign in to comment.