diff --git a/gamemode/engine/lib/sh_node.lua b/gamemode/engine/lib/sh_node.lua index 5b1ec69..814c468 100644 --- a/gamemode/engine/lib/sh_node.lua +++ b/gamemode/engine/lib/sh_node.lua @@ -7,6 +7,7 @@ Quantum.Node = {} -- lib Quantum.Nodes = {} -- container for vars +Quantum.NodesLocations = {} function Quantum.Node.Create( nodeid, tbl ) local node = { @@ -65,15 +66,24 @@ if SERVER then end end + function Quantum.Node.RemoveAllPerma() + for k, node in pairs( ents.FindByClass("q_node") ) do + node:Remove() + end + end + function Quantum.Node.Register( nodeid, vec, ang1 ) - Quantum.Nodes[ #Quantum.Nodes + 1 ] = { id = nodeid, pos = vec, ang = ang1 } + Quantum.NodesLocations[ #Quantum.NodesLocations + 1 ] = { id = nodeid, pos = vec, ang = ang1 } end function Quantum.Node.SpawnAllRegistered() local nodeTbl - for k, v in pairs( Quantum.Nodes ) do + for k, v in pairs( Quantum.NodesLocations ) do nodeTbl = Quantum.Node.Get( v.id ) if( nodeTbl != nil ) then + Quantum.Debug( "----Node-Spawning-Info----" ) + PrintTable(v) + Quantum.Debug( "--------------------------" ) Quantum.Node.Spawn( v.id, v.pos, v.ang, nodeTbl.respawndelay, nodeTbl.probability ) else Quantum.Error( "Tried to spawn an invalid node ('" .. v.id .. "')!" ) @@ -89,6 +99,13 @@ if SERVER then end end) + hook.Add( "PlayerDisconnected", "Quantum_Nodes_RemoveOnNoPlayers", function() + Quantum.Debug( "Removing all nodes..." ) + if( #player.GetAll() - 1 <= 0 ) then + Quantum.Node.RemoveAllPerma() + end + end) + local function randomizeLootTable( tbl, prob ) local n = math.Rand( 0.00000000001, 1 ) Quantum.Debug( "Probability: " .. n .. " <= " .. prob ) diff --git a/gamemode/init.lua b/gamemode/init.lua index 80d6592..6c8d509 100644 --- a/gamemode/init.lua +++ b/gamemode/init.lua @@ -122,6 +122,7 @@ if SERVER then include( "settings/sh_recipes.lua" ) include( "settings/sv_crafting_stations_locations.lua" ) include( "settings/sh_nodes.lua" ) + include( "settings/sv_nodes_locations.lua" ) Quantum.Server.Station.UpdateAll() end diff --git a/gamemode/settings/sv_nodes_locations.lua b/gamemode/settings/sv_nodes_locations.lua new file mode 100644 index 0000000..ad74516 --- /dev/null +++ b/gamemode/settings/sv_nodes_locations.lua @@ -0,0 +1,10 @@ +-- __ _ _______ _ __ +-- / / /\ | | |__ __| | | \ \ +-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \ +-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > > +-- \ \ / ____ \| | | | | | | | __/ (__| | | | / / +-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/ + +Quantum.Node.Register( "stone", Vector( 14877.728515625, -916.02612304688, 768 ), Angle( 0, -139.03350830078, 0 ) ) + +