From 0d05cb1dfcfa889cede2c894f4ce521d30f1f13d Mon Sep 17 00:00:00 2001 From: AlmTech Date: Sun, 27 Oct 2019 22:19:51 +0100 Subject: [PATCH] Bug fixes & character stuff --- .../engine/derma/menus/menu_character.lua | 20 ++++++++++++++++--- gamemode/engine/lib/server/sv_character.lua | 6 ++++-- gamemode/engine/lib/server/sv_networking.lua | 6 +++++- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/gamemode/engine/derma/menus/menu_character.lua b/gamemode/engine/derma/menus/menu_character.lua index c209268..98776b9 100644 --- a/gamemode/engine/derma/menus/menu_character.lua +++ b/gamemode/engine/derma/menus/menu_character.lua @@ -365,14 +365,11 @@ function menu.open( dt ) header.Paint = function( self, w, h ) end local chars = dt.cont -- set the char table - PrintTable( chars ) - print( table.Count( chars ) ) local cpanels = {} local selectedChar if( table.Count( chars ) >= 1 ) then - print( "CREATE p.mdl") -- Char model p.mdl = vgui.Create( "DModelPanel", p ) p.mdl:SetSize( 600 * resScale, 1000 * resScale ) @@ -403,6 +400,7 @@ function menu.open( dt ) for k, v in pairs( chars ) do count = count + 1 cpanels[count] = vgui.Create( "DButton", clist ) + cpanels[count].index = count cpanels[count].char = v -- give the panel it's character if( !selectedChar ) then selectedChar = cpanels[1] end -- select the first one @@ -489,6 +487,22 @@ function menu.open( dt ) end dl.OnCursorEntered = function() surface.PlaySound( "UI/buttonrollover.wav" ) end + + -- Enter world button -- + p.enter = vgui.Create( "DButton", p ) + p.enter:SetText( "Enter World" ) + p.enter:SetFont( "q_button2" ) + p.enter:SetTextColor( Color( 0, 0, 0, 255 ) ) + p.enter:SizeToContents() + p.enter.w, p.enter.h = p.enter:GetSize() + p.enter:SetPos( p.w/2 - p.enter.w/2, p.h*0.925 - p.enter.h/2 ) + p.enter.Paint = function( self ) theme.sharpbutton( self ) end + p.enter.DoClick = function() + surface.PlaySound( "UI/buttonclick.wav" ) + -- enter world -- + snm.RunNetworkedFunc( "enterWorldChar", {index = selectedChar.index} ) + end + p.enter.OnCursorEntered = function() surface.PlaySound( "UI/buttonrollover.wav" ) end end end end diff --git a/gamemode/engine/lib/server/sv_character.lua b/gamemode/engine/lib/server/sv_character.lua index ed52441..a1f67a9 100644 --- a/gamemode/engine/lib/server/sv_character.lua +++ b/gamemode/engine/lib/server/sv_character.lua @@ -59,19 +59,21 @@ function Quantum.Server.Char.GetCurrentCharacter( pl ) end local function setupCharacter( pl, char ) + pl:Respawn() pl:SetMaxHealth( char.maxhealth ) pl:SetHealth( char.health ) pl:SetModel( char.model ) end function Quantum.Server.Char.SetCurrentCharacter( pl, index ) - local id = pl:SteamID() .. ":" .. index + local id = pl:SteamID() .. ";" .. index if( Quantum.Server.Char.Players[ id ] ) then pl.character = Quantum.Server.Char.Players[ id ] + pl.charindex = index setupCharacter( pl, pl.character ) return pl.character else - Quantum.Error( "Unable to set " .. tostring(pl) .. " character. Character not found!" ) + Quantum.Error( "Unable to set " .. tostring(pl) .. " character (" .. id .. "). Character not found!" ) return nil end end diff --git a/gamemode/engine/lib/server/sv_networking.lua b/gamemode/engine/lib/server/sv_networking.lua index 8151707..56e4a0b 100644 --- a/gamemode/engine/lib/server/sv_networking.lua +++ b/gamemode/engine/lib/server/sv_networking.lua @@ -54,13 +54,17 @@ function Quantum.Net.OpenMenu( pl, type, dt ) end local funcs = { - ["createChar"] = true + ["createChar"] = true, + ["enterWorldChar"] = true } local netfuncs = { createChar = function( pl, args ) pl.charcount = Quantum.Server.Char.GetCharCount( pl ) Quantum.Server.Char.Load( pl, pl.charcount + 1, args ) + end, + enterWorldChar = function( pl, args ) + Quantum.Server.Char.SetCurrentCharacter( pl, args.index ) end }