Networking keybinds & networked functions

master
AlmTech 5 years ago
parent 68c2cf2e0c
commit f8d4175754
  1. 21
      gamemode/engine/core/sh_player_binds.lua
  2. 2
      gamemode/engine/derma/cl_character.lua
  3. 16
      gamemode/engine/lib/server/sv_networking.lua

@ -0,0 +1,21 @@
-- __ _ _______ _ __
-- / / /\ | | |__ __| | | \ \
-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \
-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > >
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / /
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/
if SERVER then
local keyfuncs = {
[IN_USE] = function( pl )
pl:ChatPrint( "Use bind test" )
end
}
function GM:KeyRelease( ply, key )
if( keyfuncs[key] ) then keyfuncs[key]( pl ) end
end
end

@ -18,7 +18,7 @@ local function char_derma()
txt:SetPos( 100, 100 ) txt:SetPos( 100, 100 )
local b = vgui.Create( "DButton" ) local b = vgui.Create( "DButton" )
b:SetText( "Create char" ) b:SetText( "Create Char" )
b:SizeToContents() b:SizeToContents()
b.DoClick = function() b.DoClick = function()
net.Start( "quantum_menu_button_net" ) net.Start( "quantum_menu_button_net" )

@ -49,8 +49,24 @@ local function SendDatatableToClient( client, dt, type )
net.Send( client ) net.Send( client )
end end
local funcs = {
["createChar"] = true
}
local netfuncs = {
createChar = function( pl, args )
Quantum.Server.Char.Load( pl, 1, args )
end
}
local function runNetFunc( pl, func, args )
if( funcs[func] ) then
netfuncs[func]( pl, args )
end
end
net.Receive( "quantum_menu_button_net", function( len, pl ) net.Receive( "quantum_menu_button_net", function( len, pl )
local funcid = net.ReadString() local funcid = net.ReadString()
local args = net.ReadTable() local args = net.ReadTable()
runNetFunc( pl, funcid, args )
end) end)

Loading…
Cancel
Save