From 6a005a393d48db41f890b3672b29b1ffa344d0f5 Mon Sep 17 00:00:00 2001 From: CSchulz Date: Tue, 18 Nov 2014 11:31:51 +0100 Subject: [PATCH 1/3] Added time con vars --- gamemode/init.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gamemode/init.lua b/gamemode/init.lua index 2d1798b..064f6b1 100644 --- a/gamemode/init.lua +++ b/gamemode/init.lua @@ -42,6 +42,8 @@ resource.AddFile("materials/melonbomber/skull_license.txt") GM.MapScale = CreateConVar("mb_map_scale", 20, bit.bor(FCVAR_NOTIFY), "Size of map squared per player (default 20)" ) GM.MapMaxArea = CreateConVar("mb_map_maxarea", 500, bit.bor(FCVAR_NOTIFY), "Max area of map squared" ) +GM.PrepTime = CreateConVar("mb_time_prep", 5, bit.bor(0), "Time to wait before round starts (default 5)" ) +GM.EndTime = CreateConVar("mb_time_end", 10, bit.bor(0), "Time to show player table (default 10)" ) function GM:Initialize() self.DeathRagdolls = {} @@ -158,4 +160,4 @@ end function GM:ShowHelp(ply) net.Start("mb_openhelpmenu") net.Send(ply) -end \ No newline at end of file +end From db464bd92c1b92cee26f8beb0a4ee62ebb299fb0 Mon Sep 17 00:00:00 2001 From: CSchulz Date: Tue, 18 Nov 2014 12:39:11 +0100 Subject: [PATCH 2/3] First implementation --- gamemode/cl_hud.lua | 2 +- gamemode/cl_rounds.lua | 1 + gamemode/init.lua | 4 ++-- gamemode/sv_player.lua | 3 +++ gamemode/sv_rounds.lua | 5 +++-- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/gamemode/cl_hud.lua b/gamemode/cl_hud.lua index 622e1bb..b92fab4 100644 --- a/gamemode/cl_hud.lua +++ b/gamemode/cl_hud.lua @@ -321,7 +321,7 @@ end function GM:DrawRoundTimer() if self:GetGameState() == 1 then - local time = math.ceil(5 - self:GetStateRunningTime()) + local time = math.ceil(GetGlobalInt( "mb_time_prep" ) - self:GetStateRunningTime()) if time > 0 then draw.ShadowText(time, "RobotoHUD-40", ScrW() / 2, ScrH() / 3, color_white, 1, 1) end diff --git a/gamemode/cl_rounds.lua b/gamemode/cl_rounds.lua index d449f60..47d8fa9 100644 --- a/gamemode/cl_rounds.lua +++ b/gamemode/cl_rounds.lua @@ -18,6 +18,7 @@ end net.Receive("gamestate", function (len) GAMEMODE.GameState = net.ReadUInt(32) GAMEMODE.StateStart = net.ReadDouble() + print("cl gamestate", GAMEMODE.GameState) if GAMEMODE.GameState == 0 then diff --git a/gamemode/init.lua b/gamemode/init.lua index 064f6b1..5637ae5 100644 --- a/gamemode/init.lua +++ b/gamemode/init.lua @@ -42,8 +42,8 @@ resource.AddFile("materials/melonbomber/skull_license.txt") GM.MapScale = CreateConVar("mb_map_scale", 20, bit.bor(FCVAR_NOTIFY), "Size of map squared per player (default 20)" ) GM.MapMaxArea = CreateConVar("mb_map_maxarea", 500, bit.bor(FCVAR_NOTIFY), "Max area of map squared" ) -GM.PrepTime = CreateConVar("mb_time_prep", 5, bit.bor(0), "Time to wait before round starts (default 5)" ) -GM.EndTime = CreateConVar("mb_time_end", 10, bit.bor(0), "Time to show player table (default 10)" ) +GM.PrepTime = CreateConVar("mb_time_prep", 5, bit.bor(FCVAR_REPLICATED), "Time to wait before round starts (default 5)" ) +GM.EndTime = CreateConVar("mb_time_end", 10, bit.bor(FCVAR_REPLICATED), "Time to show scoreboard at the end (default 10)" ) function GM:Initialize() self.DeathRagdolls = {} diff --git a/gamemode/sv_player.lua b/gamemode/sv_player.lua index 43200d7..ca03873 100644 --- a/gamemode/sv_player.lua +++ b/gamemode/sv_player.lua @@ -7,6 +7,9 @@ function GM:PlayerInitialSpawn(ply) ply:SetMoney(10000) ply:SetTeam(2) + + -- ConVar replication doesn't work with gmod currently + SetGlobalInt("mb_time_prep", GetConVarNumber("mb_time_prep")) if self:GetGameState() != 0 then timer.Simple(0, function () diff --git a/gamemode/sv_rounds.lua b/gamemode/sv_rounds.lua index eb4e11d..07d8560 100644 --- a/gamemode/sv_rounds.lua +++ b/gamemode/sv_rounds.lua @@ -38,6 +38,7 @@ function GM:GetPlayingPlayers() end function GM:SetGameState(state) + print("gamestate", state) self.GameState = state self.StateStart = CurTime() net.Start("gamestate") @@ -177,13 +178,13 @@ function GM:RoundsThink() self:SetupRound() end elseif self:GetGameState() == 1 then - if self:GetStateRunningTime() > 5 then + if self:GetStateRunningTime() > self.PrepTime:GetInt() then self:StartRound() end elseif self:GetGameState() == 2 then self:CheckForVictory() elseif self:GetGameState() == 3 then - if self:GetStateRunningTime() > 10 then + if self:GetStateRunningTime() > self.EndTime:GetInt() then self:SetupRound() end end From 487814169c61ae372a069b2b1bb972858803d8c0 Mon Sep 17 00:00:00 2001 From: CSchulz Date: Tue, 18 Nov 2014 17:08:10 +0100 Subject: [PATCH 3/3] Removed debug prints --- gamemode/cl_rounds.lua | 2 -- gamemode/sv_rounds.lua | 1 - 2 files changed, 3 deletions(-) diff --git a/gamemode/cl_rounds.lua b/gamemode/cl_rounds.lua index 47d8fa9..2f8e2fd 100644 --- a/gamemode/cl_rounds.lua +++ b/gamemode/cl_rounds.lua @@ -18,8 +18,6 @@ end net.Receive("gamestate", function (len) GAMEMODE.GameState = net.ReadUInt(32) GAMEMODE.StateStart = net.ReadDouble() - print("cl gamestate", GAMEMODE.GameState) - if GAMEMODE.GameState == 0 then GAMEMODE:ScoreboardHide() diff --git a/gamemode/sv_rounds.lua b/gamemode/sv_rounds.lua index 07d8560..a8b4556 100644 --- a/gamemode/sv_rounds.lua +++ b/gamemode/sv_rounds.lua @@ -38,7 +38,6 @@ function GM:GetPlayingPlayers() end function GM:SetGameState(state) - print("gamestate", state) self.GameState = state self.StateStart = CurTime() net.Start("gamestate")