diff --git a/gamemode/engine/core/server/sv_player_init.lua b/gamemode/engine/core/server/sv_player_init.lua index 771b678..fcd20d8 100644 --- a/gamemode/engine/core/server/sv_player_init.lua +++ b/gamemode/engine/core/server/sv_player_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 diff --git a/gamemode/engine/derma/lib/cl_network.lua b/gamemode/engine/derma/lib/cl_network.lua new file mode 100644 index 0000000..e1d5165 --- /dev/null +++ b/gamemode/engine/derma/lib/cl_network.lua @@ -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 \ No newline at end of file diff --git a/gamemode/engine/derma/menus/menu_character.lua b/gamemode/engine/derma/menus/menu_character.lua index a195c5c..8da0a05 100644 --- a/gamemode/engine/derma/menus/menu_character.lua +++ b/gamemode/engine/derma/menus/menu_character.lua @@ -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 diff --git a/gamemode/engine/lib/server/sv_networking.lua b/gamemode/engine/lib/server/sv_networking.lua index c6882e0..cc25200 100644 --- a/gamemode/engine/lib/server/sv_networking.lua +++ b/gamemode/engine/lib/server/sv_networking.lua @@ -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 diff --git a/gamemode/init.lua b/gamemode/init.lua index 343b80c..b344213 100644 --- a/gamemode/init.lua +++ b/gamemode/init.lua @@ -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" )