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 )
--ply.isloaded = true -- REMOVE THIS WHEN MYSQL DB IS ADDED
-- load in all of the players characters and stuff from the MySQL DB
end
local function setUpPlayer( ply )
@ -31,10 +31,7 @@ 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

@ -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.WriteString( func ) -- don't worry! it's very secure :D
net.WriteTable( args )
net.SendToServer()
end
return net
return snm

@ -19,12 +19,16 @@ function menu.open( dt )
local txt = vgui.Create( "DTextEntry", f )
txt:SetText( "Enter name here" )
txt:SizeToContents()
txt:SetPos( 100, 100 )
txt:SetSize( 250, 25 )
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 )
b:SetText( "Create Char" )
b:SizeToContents()
local bW, bH = b:GetSize()
b:SetPos( sw/2 - bW/2, txtY - bH )
b.DoClick = function()
net.RunNetworkedFunc( "createChar", { name = txt:GetValue() } )
end

Loading…
Cancel
Save