From 4038ae0a5cd2335d6af52d6baafb6fbc70d74e21 Mon Sep 17 00:00:00 2001 From: Redox Date: Fri, 26 Jul 2024 05:22:45 +0200 Subject: [PATCH] Dont use umsg anymore, use OnScreenSizeChanged hook (#3107) --- .../lib/egplib/usefulfunctions.lua | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/lua/entities/gmod_wire_egp/lib/egplib/usefulfunctions.lua b/lua/entities/gmod_wire_egp/lib/egplib/usefulfunctions.lua index 54d7965ecd..5e847b44c4 100644 --- a/lua/entities/gmod_wire_egp/lib/egplib/usefulfunctions.lua +++ b/lua/entities/gmod_wire_egp/lib/egplib/usefulfunctions.lua @@ -245,23 +245,19 @@ end -- Saving Screen width and height -if (CLIENT) then - usermessage.Hook("EGP_ScrWH_Request",function(um) - RunConsoleCommand("EGP_ScrWH",ScrW(),ScrH()) - end) +if CLIENT then + hook.Add( "InitPostEntity", "EGP_ScrWH_Init", function() + RunConsoleCommand("EGP_ScrWH", ScrW(), ScrH()) + end ) + + hook.Add( "OnScreenSizeChanged", "EGP_ScrWH_Update", function( _, _, newW, newH ) + RunConsoleCommand("EGP_ScrWH", newW, newH) + end ) else - hook.Add("PlayerInitialSpawn","EGP_ScrHW_Request",function(ply) - timer.Simple(1,function() - if (ply and ply:IsValid() and ply:IsPlayer()) then - umsg.Start("EGP_ScrWH_Request",ply) umsg.End() - end - end) - end) - EGP.ScrHW = WireLib.RegisterPlayerTable() - concommand.Add("EGP_ScrWH",function(ply,cmd,args) - if (args and tonumber(args[1]) and tonumber(args[2])) then + concommand.Add("EGP_ScrWH", function(ply, cmd, args) + if args and tonumber(args[1]) and tonumber(args[2]) then EGP.ScrHW[ply] = { tonumber(args[1]), tonumber(args[2]) } end end)