Bug fixes & character stuff

master
AlmTech 5 years ago
parent 3ef6fa6c8d
commit 0d05cb1dfc
  1. 20
      gamemode/engine/derma/menus/menu_character.lua
  2. 6
      gamemode/engine/lib/server/sv_character.lua
  3. 6
      gamemode/engine/lib/server/sv_networking.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

@ -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

@ -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
}

Loading…
Cancel
Save