From 1c1e58ac9861c026761f48e215cf80c5be19ad19 Mon Sep 17 00:00:00 2001 From: LostTrackpad Date: Wed, 7 Aug 2024 16:37:07 +0700 Subject: [PATCH] Allow replay system to actually work (idiot move) --- .../entities/entities/tt_cp/shared.lua | 2 +- .../beatrun/gamemode/sh/Checkpoints.lua | 37 +++++++++---------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/beatrun/gamemodes/beatrun/entities/entities/tt_cp/shared.lua b/beatrun/gamemodes/beatrun/entities/entities/tt_cp/shared.lua index d65bb30..8bd5d91 100644 --- a/beatrun/gamemodes/beatrun/entities/entities/tt_cp/shared.lua +++ b/beatrun/gamemodes/beatrun/entities/entities/tt_cp/shared.lua @@ -44,7 +44,7 @@ function ENT:StartTouch(ent) ent:SetNW2Int("CPNum", ent:GetNW2Int("CPNum", 1) + 1) if ent:GetNW2Int("CPNum", 1) > table.Count(Checkpoints) then - -- ReplayStop(ent) + ReplayStop(ent) FinishCourse(ent) else ent.CPSavePos = ent:GetPos() diff --git a/beatrun/gamemodes/beatrun/gamemode/sh/Checkpoints.lua b/beatrun/gamemodes/beatrun/gamemode/sh/Checkpoints.lua index 7879cf8..a12073e 100644 --- a/beatrun/gamemodes/beatrun/gamemode/sh/Checkpoints.lua +++ b/beatrun/gamemodes/beatrun/gamemode/sh/Checkpoints.lua @@ -134,7 +134,7 @@ if CLIENT then LocalPlayer():EmitSound("A_TT_Finish_Positive.wav") SaveCheckpointTime() - -- SaveReplayData() + SaveReplayData() else timetext = "+" .. string.FormattedTime(math.abs(timestr), "%02i:%02i:%02i") timecolor = color_negative @@ -169,7 +169,7 @@ local finishcolor = Color(45, 45, 175, 100) function FinishCourse(ply) ply:ScreenFade(SCREENFADE.IN, finishcolor, 0, 4) - -- ply:SetLaggedMovementValue(0.1) + ply:SetLaggedMovementValue(0.1) ply:DrawViewModel(false) net.Start("Checkpoint_Finish") @@ -178,7 +178,7 @@ function FinishCourse(ply) ply:SetNW2Int("CPNum", -1) timer.Simple(4, function() - -- ply:SetLaggedMovementValue(1) + ply:SetLaggedMovementValue(1) ply:DrawViewModel(true) end) end @@ -354,23 +354,20 @@ function LoadCheckpointTime() return times or nil end --- function SaveReplayData() --- local replay = util.Compress(util.TableToJSON(LocalPlayer().ReplayTicks)) --- local dir = "beatrun/replays/" .. game.GetMap() .. "/" - --- if not replay then return end - --- file.CreateDir(dir) --- file.Write(dir .. Course_ID .. ".txt", replay) --- end - --- function LoadReplayData() --- local dir = "beatrun/replays/" .. game.GetMap() .. "/" --- local replay = file.Read(dir .. Course_ID .. ".txt") --- replay = replay and util.JSONToTable(util.Decompress(replay)) - --- return replay or nil --- end +function SaveReplayData() + PrintTable(LocalPlayer().ReplayTicks) + local replay = util.Compress(util.TableToJSON(LocalPlayer().ReplayTicks)) + local dir = "beatrun/replays/" .. game.GetMap() .. "/" + if not replay then return end + file.CreateDir(dir) + file.Write(dir .. Course_ID .. ".txt", replay) +end +function LoadReplayData() + local dir = "beatrun/replays/" .. game.GetMap() .. "/" + local replay = file.Read(dir .. Course_ID .. ".txt") + replay = replay and util.JSONToTable(util.Decompress(replay)) + return replay or nil +end function StartCourse(spawntime) local faststartmult = LocalPlayer():GetInfoNum("Beatrun_FastStart", 0) > 0 and 0.5 or 1