From 3907207dc98cd0e1e59d6e3079e6b37308e2581f Mon Sep 17 00:00:00 2001 From: LostTrackpad Date: Thu, 6 Jun 2024 19:09:37 +0700 Subject: [PATCH] Hopefully fix FOV changing --- .../gamemode/player_class/player_beatrun.lua | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua b/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua index 5687aa4..dc54e13 100644 --- a/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua +++ b/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua @@ -9,6 +9,11 @@ if CLIENT then CreateConVar("cl_playerbodygroups", "0", {FCVAR_ARCHIVE, FCVAR_USERINFO, FCVAR_DONTRECORD}, "The bodygroups to use, if the model has any") local lframeswepclass = lframeswepclass or "" + local fovdelaytoggle = false +end + +if SERVER then + util.AddNetworkString("Beatrun_ClientFOVChange") end local PLAYER = {} @@ -565,10 +570,27 @@ hook.Add("PlayerSwitchWeapon", "BeatrunSwitchFOVFix", function(ply) end) cvars.AddChangeCallback("Beatrun_FOV", function(convar, oldval, newval) - -- Fixes live FOV changes. I'm not kidding. - if CLIENT then + -- Live FOV change in SP, needs work for MP + if CLIENT and game.SinglePlayer() then LocalPlayer():SetFOV(newval) + elseif CLIENT then + FOVModifierBlock = true + timer.Create("beatrunfovdelay", 0.16, 1, function() + FOVModifierBlock = false + if !FOVModifierBlock then + net.Start("Beatrun_ClientFOVChange") + net.WriteInt(newval, 16) + net.SendToServer() + FOVModifierBlock = true + end + end) end end) +if SERVER then + net.Receive("Beatrun_ClientFOVChange", function(len, ply) + ply:SetFOV((net.ReadInt(16))) + end) +end + player_manager.RegisterClass("player_beatrun", PLAYER, "player_default")