Fixed the SNM api

master
AlmTech 5 years ago
parent 483580c00a
commit 925e603610
  1. 5
      gamemode/engine/core/server/sv_player_init.lua
  2. 6
      gamemode/engine/derma/lib/cl_network.lua
  3. 8
      gamemode/engine/derma/menus/menu_character.lua

@ -11,7 +11,7 @@ local ply = FindMetaTable( "Player" )
function GM:PlayerInitialSpawn( ply ) function GM:PlayerInitialSpawn( ply )
--ply.isloaded = true -- REMOVE THIS WHEN MYSQL DB IS ADDED --ply.isloaded = true -- REMOVE THIS WHEN MYSQL DB IS ADDED
-- load in all of the players characters and stuff from the MySQL DB
end end
local function setUpPlayer( ply ) local function setUpPlayer( ply )
@ -31,10 +31,7 @@ function GM:PlayerSpawn( ply )
if( !ply.isloaded ) then if( !ply.isloaded ) then
ply:Spectate( OBS_MODE_FIXED ) ply:Spectate( OBS_MODE_FIXED )
else else
if( !ply:Alive()) then
ply:UnSpectate() ply:UnSpectate()
ply:Spawn()
end
setUpPlayer( ply ) setUpPlayer( ply )
end end

@ -5,13 +5,13 @@
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / / -- \ \ / ____ \| | | | | | | | __/ (__| | | | / /
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/ -- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/
local net = {} local snm = {} -- Safe. Networked. Message
function net.RunNetworkedFunc( func, args ) function snm.RunNetworkedFunc( func, args )
net.Start( "quantum_menu_button_net" ) -- used for menu buttons etc net.Start( "quantum_menu_button_net" ) -- used for menu buttons etc
net.WriteString( func ) -- don't worry! it's very secure :D net.WriteString( func ) -- don't worry! it's very secure :D
net.WriteTable( args ) net.WriteTable( args )
net.SendToServer() net.SendToServer()
end end
return net return snm

@ -19,12 +19,16 @@ function menu.open( dt )
local txt = vgui.Create( "DTextEntry", f ) local txt = vgui.Create( "DTextEntry", f )
txt:SetText( "Enter name here" ) txt:SetText( "Enter name here" )
txt:SizeToContents() txt:SetSize( 250, 25 )
txt:SetPos( 100, 100 ) local txtW, txtH = txt:GetSize()
txt:SetPos( sw/2 - txtW/2, sh/2 - txtH/2 )
local txtX, txtY = txt:GetPos()
local b = vgui.Create( "DButton", f ) local b = vgui.Create( "DButton", f )
b:SetText( "Create Char" ) b:SetText( "Create Char" )
b:SizeToContents() b:SizeToContents()
local bW, bH = b:GetSize()
b:SetPos( sw/2 - bW/2, txtY - bH )
b.DoClick = function() b.DoClick = function()
net.RunNetworkedFunc( "createChar", { name = txt:GetValue() } ) net.RunNetworkedFunc( "createChar", { name = txt:GetValue() } )
end end

Loading…
Cancel
Save