master
AlmTech 5 years ago
parent 1a9b325174
commit 2d25c23b1e
  1. 36
      gamemode/engine/core/server/sv_player_spawning.lua
  2. 36
      gamemode/engine/derma/menus/menu_character.lua
  3. 3
      gamemode/engine/lib/server/sv_networking.lua
  4. 2
      gamemode/settings/sh_settings.lua
  5. 2
      gamemode/settings/sv_settings.lua

@ -9,27 +9,33 @@ hook.Add( "PlayerDeath", "Quantum_Player_SaveDeathPos", function( pl )
pl.deathpos = pl:GetPos() pl.deathpos = pl:GetPos()
end) end)
hook.Add( "PlayerSpawn", "Quantum_Player_Respawn", function( pl ) local function getNearestSpawn( pl )
if( pl.isloaded && pl.deathpos ) then local spawnposdist = {}
local spawnposdist = {} for id, spawnpoint in pairs( Quantum.Server.Settings.SpawnLocations[ game.GetMap() ] ) do
for id, spawnpoint in pairs( Quantum.Server.Settings.SpawnLocations[ game.GetMap() ] ) do spawnposdist[id] = { dist = spawnpoint.pos:Distance( pl.deathpos ), spawnpos = spawnpoint.pos, angle = spawnpoint.ang }
spawnposdist[id] = { dist = spawnpoint.pos:Distance( pl.deathpos ), spawnpos = spawnpoint.pos, angle = spawnpoint.ang } end
end
local maxdist, spawnpos, spawnangle local maxdist, spawnpos, spawnangle
for id, spawn in pairs( spawnposdist ) do -- Loop through everything and pick the nearest spawnpoint for id, spawn in pairs( spawnposdist ) do -- Loop through everything and pick the nearest spawnpoint
if( maxdist ~= nil ) then if( maxdist ~= nil ) then
if( maxdist >= spawn.dist ) then if( maxdist >= spawn.dist ) then
maxdist = spawn.dist
spawnpos = spawn.spawnpos
spawnangle = spawn.angle
end
else
maxdist = spawn.dist maxdist = spawn.dist
spawnpos = spawn.spawnpos spawnpos = spawn.spawnpos
spawnangle = spawn.angle spawnangle = spawn.angle
end end
else
maxdist = spawn.dist
spawnpos = spawn.spawnpos
spawnangle = spawn.angle
end end
end
return spawnpos, spawnangle
end
hook.Add( "PlayerSpawn", "Quantum_Player_Respawn", function( pl )
if( pl.isloaded && pl.deathpos ) then
local spawnpos, spawnangle = getNearestSpawn( pl )
Quantum.Debug( "Respawning player at nearest spawnpoint." ) Quantum.Debug( "Respawning player at nearest spawnpoint." )
pl:SetPos( spawnpos ) pl:SetPos( spawnpos )

@ -466,24 +466,26 @@ function menu.open( dt )
p.mdl:SetLookAt( eyepos ) p.mdl:SetLookAt( eyepos )
end end
-- create char button if( table.Count( dt.cont ) < Quantum.CharacterLimit ) then
local cr = vgui.Create( "DButton", p ) -- create char button
cr:SetText("Create New Character") local cr = vgui.Create( "DButton", p )
cr:SetFont( "q_button" ) cr:SetText("Create New Character")
cr:SetTextColor( Color( 0, 0, 0, 255 ) ) cr:SetFont( "q_button" )
cr:SizeToContents() cr:SetTextColor( Color( 0, 0, 0, 255 ) )
cr.w, cr.h = cr:GetSize() cr:SizeToContents()
cr:SetPos( clist.x + ( clist.w/2 - cr.w/2 ), clist.y + ( ( clist.h - cr.h ) - padding*2 ) ) cr.w, cr.h = cr:GetSize()
cr.Paint = function( self ) cr:SetPos( clist.x + ( clist.w/2 - cr.w/2 ), clist.y + ( ( clist.h - cr.h ) - padding*2 ) )
theme.sharpbutton( self ) cr.Paint = function( self )
end theme.sharpbutton( self )
cr.DoClick = function() end
surface.PlaySound( "UI/buttonclick.wav" ) cr.DoClick = function()
p:SetVisible( false ) surface.PlaySound( "UI/buttonclick.wav" )
local crPage = pages.charCreate( f ) p:SetVisible( false )
end local crPage = pages.charCreate( f )
end
cr.OnCursorEntered = function() surface.PlaySound( "UI/buttonrollover.wav" ) end cr.OnCursorEntered = function() surface.PlaySound( "UI/buttonrollover.wav" ) end
end
if( selectedChar ) then if( selectedChar ) then
-- Delete char button -- Delete char button

@ -64,11 +64,10 @@ local netfuncs = {
if( #args.name > 16 ) then if( #args.name > 16 ) then
Quantum.Debug( "Player " .. tostring( pl ) .. " character name too long. Unable to create." ) Quantum.Debug( "Player " .. tostring( pl ) .. " character name too long. Unable to create." )
return return
elseif( pl.charcount + 1 > Quantum.Server.Settings.CharacterLimit ) then -- character limit elseif( pl.charcount + 1 > Quantum.CharacterLimit ) then -- character limit
Quantum.Debug( "Player " .. tostring( pl ) .. " tried to exceed their character limit." ) Quantum.Debug( "Player " .. tostring( pl ) .. " tried to exceed their character limit." )
return return
end end
print(pl.charcount + 1)
Quantum.Server.Char.Load( pl, pl.charcount + 1, args ) Quantum.Server.Char.Load( pl, pl.charcount + 1, args )
end, end,
enterWorldChar = function( pl, args ) enterWorldChar = function( pl, args )

@ -5,6 +5,8 @@
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / / -- \ \ / ____ \| | | | | | | | __/ (__| | | | / /
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/ -- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/
Quantum.CharacterLimit = 5
Quantum.Models = { Quantum.Models = {
NPC = {}, NPC = {},
Player = { Player = {

@ -7,8 +7,6 @@
Quantum.Server.Settings = {} Quantum.Server.Settings = {}
Quantum.Server.Settings.CharacterLimit = 5
Quantum.Server.Settings.VoiceChatRange = 400 Quantum.Server.Settings.VoiceChatRange = 400
Quantum.Server.Settings.MaxHealth = 100 Quantum.Server.Settings.MaxHealth = 100

Loading…
Cancel
Save