Added clientsided networking API support for menu's

master
AlmTech 5 years ago
parent 79af991250
commit b044b1d81e
  1. 4
      gamemode/engine/core/server/sv_player_init.lua
  2. 17
      gamemode/engine/derma/lib/cl_network.lua
  3. 7
      gamemode/engine/derma/menus/menu_character.lua
  4. 3
      gamemode/engine/lib/server/sv_networking.lua
  5. 1
      gamemode/init.lua

@ -31,6 +31,10 @@ function GM:PlayerSpawn( ply )
if( !ply.isloaded ) then
ply:Spectate( OBS_MODE_FIXED )
else
if( !ply:Alive()) then
ply:UnSpectate()
ply:Spawn()
end
setUpPlayer( ply )
end

@ -0,0 +1,17 @@
-- __ _ _______ _ __
-- / / /\ | | |__ __| | | \ \
-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \
-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > >
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / /
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/
local net = {}
function net.RunNetworkedFunc( func, args )
net.Start( "quantum_menu_button_net" ) -- used for menu buttons etc
net.WriteString( func ) -- don't worry! it's very secure :D
net.WriteTable( args )
net.SendToServer()
end
return net

@ -7,6 +7,8 @@
local menu = {}
local net = include( "../lib/cl_network.lua" )
function menu.open( dt )
local sw, sh = ScrW(), ScrH()
if( !f ) then
@ -24,10 +26,7 @@ function menu.open( dt )
b:SetText( "Create Char" )
b:SizeToContents()
b.DoClick = function()
net.Start( "quantum_menu_button_net" )
net.WriteString( "createchar" )
net.WriteTable( { name = txt:GetValue() } )
net.SendToServer()
net.RunNetworkedFunc( "createChar", { name = txt:GetValue() } )
end
end
end

@ -59,6 +59,7 @@ local funcs = {
local netfuncs = {
createChar = function( pl, args )
print("ping pong")
Quantum.Server.Char.Load( pl, 1, args )
end
}
@ -66,6 +67,8 @@ local netfuncs = {
local function runNetFunc( pl, func, args )
if( funcs[func] ) then
netfuncs[func]( pl, args )
else
Quantum.Error( tostring(pl) .. " tried to run a non existant networked function! func: '" .. tostring( func ) .. "'" )
end
end

@ -65,6 +65,7 @@ if SERVER then
local function addAllDermaMenus()
local fol = GM.FolderName .. "/gamemode/engine/derma/"
AddCSLuaFile( fol .. "cl_menu.lua" )
AddCSLuaFile( fol .. "lib/cl_network.lua" )
local libfol = GM.FolderName .. "/gamemode/engine/derma/menus/"
local menuFiles = file.Find( libfol .. "menu_*.lua", "LUA" )

Loading…
Cancel
Save