From 3c704e7ee048d079e451f44250f469797b96ae56 Mon Sep 17 00:00:00 2001 From: AlmTech Date: Thu, 3 Oct 2019 16:44:43 +0200 Subject: [PATCH] Networking stuff for menus and caching --- gamemode/engine/derma/cl_menu.lua | 2 +- gamemode/engine/lib/server/sv_openmenu.lua | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 gamemode/engine/lib/server/sv_openmenu.lua diff --git a/gamemode/engine/derma/cl_menu.lua b/gamemode/engine/derma/cl_menu.lua index b980005..d9b2968 100644 --- a/gamemode/engine/derma/cl_menu.lua +++ b/gamemode/engine/derma/cl_menu.lua @@ -14,7 +14,7 @@ local libs = { Quantum.Client.Menu.GetAPI = function( lib ) return include( libs[lib] ) end net.Receive( "quantum_menu_net", function( len, pl ) - local dt = net.ReadTable() + local dt = net.ReadTable() -- TO DO: merge datatable with cached ( if same id/type ) local menu = include( GAMEMODE.FolderName .. "/gamemode/engine/derma/menus/menu_" .. dt.id .. ".lua" ) menu.open( dt ) end) \ No newline at end of file diff --git a/gamemode/engine/lib/server/sv_openmenu.lua b/gamemode/engine/lib/server/sv_openmenu.lua new file mode 100644 index 0000000..34b17b0 --- /dev/null +++ b/gamemode/engine/lib/server/sv_openmenu.lua @@ -0,0 +1,21 @@ +-- __ _ _______ _ __ +-- / / /\ | | |__ __| | | \ \ +-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \ +-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > > +-- \ \ / ____ \| | | | | | | | __/ (__| | | | / / +-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/ + + +local menus = { + character = function( pl ) + Quantum.Net.OpenMenu( pl, "character", Quantum.Server.Char.GetPlayerChars( pl ) ) + end +} + +function Quantum.Server.OpenMenu( pl, menu ) + if( menus[menu] ) then + menus[menu]( pl ) + else + Quantum.Error( "Tried to open a non-exsistent menu for " .. tostring(pl) .. "." ) + end +end \ No newline at end of file