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

Added PropHunt and per gamemode config support #28

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
24 changes: 12 additions & 12 deletions lua/autorun/mapvote.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@ MapVoteConfigDefault = {
}
--Default Config

hook.Add( "Initialize", "MapVoteConfigSetup", function()
if not file.Exists( "mapvote", "DATA") then
file.CreateDir( "mapvote" )
hook.Add("Initialize", "MapVoteConfigSetup", function()
if not file.Exists("mapvote", "DATA") then
file.CreateDir("mapvote")
end
if not file.Exists( "mapvote/config.txt", "DATA" ) then
file.Write( "mapvote/config.txt", util.TableToJSON( MapVoteConfigDefault ) )
if not file.Exists("mapvote/config.txt", "DATA") then
file.Write("mapvote/config.txt", util.TableToJSON(MapVoteConfigDefault))
end
end )
end)

function MapVote.HasExtraVotePower(ply)
-- Example that gives admins more voting power
--[[
-- Example that gives admins more voting power
--[[
if ply:IsAdmin() then
return true
end
return true
end
]]

return false
return false
end


Expand All @@ -51,4 +51,4 @@ if SERVER then
include("mapvote/rtv.lua")
else
include("mapvote/cl_mapvote.lua")
end
end
85 changes: 56 additions & 29 deletions lua/autorun/server/sv_autovote.lua
Original file line number Diff line number Diff line change
@@ -1,41 +1,68 @@
hook.Add( "Initialize", "AutoTTTMapVote", function()
if GAMEMODE_NAME == "terrortown" then
hook.Add("Initialize", "AutoTTTMapVote", function()
if GAMEMODE_NAME == "terrortown" then
function CheckForMapSwitch()
-- Check for mapswitch
local rounds_left = math.max(0, GetGlobalInt("ttt_rounds_left", 6) - 1)
SetGlobalInt("ttt_rounds_left", rounds_left)
local time_left = math.max(0, (GetConVar("ttt_time_limit_minutes"):GetInt() * 60) - CurTime())
local switchmap = false
local nextmap = string.upper(game.GetMapNext())
-- Check for mapswitch
local rounds_left = math.max(0, GetGlobalInt("ttt_rounds_left", 6) - 1)
SetGlobalInt("ttt_rounds_left", rounds_left)

local time_left = math.max(0, (GetConVar("ttt_time_limit_minutes"):GetInt() * 60) - CurTime())
local switchmap = false
local nextmap = string.upper(game.GetMapNext())

if rounds_left <= 0 then
LANG.Msg("limit_round", {mapname = nextmap})
switchmap = true
LANG.Msg("limit_round", {mapname = nextmap})
switchmap = true
elseif time_left <= 0 then
LANG.Msg("limit_time", {mapname = nextmap})
switchmap = true
LANG.Msg("limit_time", {mapname = nextmap})
switchmap = true
end
if switchmap then
timer.Stop("end2prep")
MapVote.Start(nil, nil, nil, nil)
end
end
end

if GAMEMODE_NAME == "deathrun" then
function RTV.Start()
MapVote.Start(nil, nil, nil, nil)
end
end

if GAMEMODE_NAME == "zombiesurvival" then
hook.Add("LoadNextMap", "MAPVOTEZS_LOADMAP", function()
MapVote.Start(nil, nil, nil, nil)
return true
end )
end
end

if GAMEMODE_NAME == "prop_hunt" then
function CheckForMapSwitch()
-- Check for mapswitch
local rounds_left = math.max(0, GetGlobalInt("ph_rounds_left", 6) - 1)
SetGlobalInt("ph_rounds_left", rounds_left)

local time_left = math.max(0, (GetConVar("ph_time_limit_minutes"):GetInt() * 60) - CurTime())
local switchmap = false
local nextmap = string.upper(game.GetMapNext())

if rounds_left <= 0 then
LANG.Msg("limit_round", {mapname = nextmap})
switchmap = true
elseif time_left <= 0 then
LANG.Msg("limit_time", {mapname = nextmap})
switchmap = true
end
if switchmap then
timer.Stop("end2prep")
MapVote.Start(nil, nil, nil, nil)
end
end
end

end )
if GAMEMODE_NAME == "murder" then
function GAMEMODE:ChangeMap()
MapVote.Start(nil, nil, nil, nil)
end
end

if GAMEMODE_NAME == "deathrun" then
function RTV.Start()
MapVote.Start(nil, nil, nil, nil)
end
end

if GAMEMODE_NAME == "zombiesurvival" then
hook.Add("LoadNextMap", "MAPVOTEZS_LOADMAP", function()
MapVote.Start(nil, nil, nil, nil)
return true
end)
end
end)
Loading