Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add method to set min and max player count for maps #51

Merged
merged 1 commit into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading