Skip to content

Commit

Permalink
Add round start timer
Browse files Browse the repository at this point in the history
  • Loading branch information
jlillis committed Jul 18, 2024
1 parent c598e6f commit 0f4edc3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [gamemodes]/[deathmatch]/deathmatch/client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ local function stopGamemodeRound(winner, draw, aborted)
toggleAllControls(true, true, false)
end
-- begin fading out the screen
fadeCamera(false, CAMERA_LOAD_DELAY/1000)
fadeCamera(false, ROUND_START_DELAY/1000)
-- show end screen and scoreboard
_hud.endScreen:update(winner, draw, aborted)
_hud.endScreen:setVisible(true)
Expand Down
7 changes: 6 additions & 1 deletion [gamemodes]/[deathmatch]/deathmatch/server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,19 @@ local function startGamemodeMap(mapResource)
end
end
-- schedule round to begin
setTimer(beginRound, CAMERA_LOAD_DELAY, 1)
_startTimer = exports.missiontimer:createMissionTimer(ROUND_START_DELAY, true, "Next round begins in %s seconds", 0.5, 20, true, "default-bold", 1)
addEventHandler("onMissionTimerElapsed", _startTimer, beginRound)
end
addEventHandler("onGamemodeMapStart", root, startGamemodeMap)

--
-- stopGamemodeMap: cleans up a gamemode map
--
local function stopGamemodeMap(mapResource)
-- kill start timer, if it exists
if isElement(_startTimer) then
destroyElement(_startTimer)
end
-- end the round
endRound(false, false, true)
-- update game state
Expand Down
4 changes: 3 additions & 1 deletion [gamemodes]/[deathmatch]/deathmatch/server/round.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
-- beginRound: begins the round
--
function beginRound()
-- destroy start timer
destroyElement(_startTimer)
-- start round timer
if _timeLimit > 0 then
_missionTimer = exports.missiontimer:createMissionTimer(_timeLimit, true, true, 0.5, 20, true, "default-bold", 1)
_missionTimer = exports.missiontimer:createMissionTimer(_timeLimit, true, "%m:%s", 0.5, 20, true, "default-bold", 1)
addEventHandler("onMissionTimerElapsed", _missionTimer, onTimeElapsed)
end
-- attach player wasted handler
Expand Down
2 changes: 1 addition & 1 deletion [gamemodes]/[deathmatch]/deathmatch/shared/shared.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CAMERA_LOAD_DELAY = 5000 -- delay used at beginning and end of round (ms)
ROUND_START_DELAY = 5000 -- delay used at beginning and end of round (ms)

--
-- enum: creates a c-style enum
Expand Down

0 comments on commit 0f4edc3

Please sign in to comment.