|
|
@ -33,6 +33,7 @@ end |
|
|
|
|
|
|
|
|
|
|
|
if SERVER then |
|
|
|
if SERVER then |
|
|
|
Quantum.Server.Station = {} |
|
|
|
Quantum.Server.Station = {} |
|
|
|
|
|
|
|
Quantum.Server.StationsPos = {} |
|
|
|
|
|
|
|
|
|
|
|
function Quantum.Server.Station.Spawn( stationid, pos, ang ) -- internal function |
|
|
|
function Quantum.Server.Station.Spawn( stationid, pos, ang ) -- internal function |
|
|
|
local ent = ents.Create( "q_crafting_station" ) |
|
|
|
local ent = ents.Create( "q_crafting_station" ) |
|
|
@ -45,6 +46,14 @@ if SERVER then |
|
|
|
local function floorVectorString( vec ) |
|
|
|
local function floorVectorString( vec ) |
|
|
|
return tostring(math.floor( vec.x )) .. ", " .. tostring(math.floor( vec.y )) .. ", " .. tostring(math.floor( vec.z )) |
|
|
|
return tostring(math.floor( vec.x )) .. ", " .. tostring(math.floor( vec.y )) .. ", " .. tostring(math.floor( vec.z )) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function Quantum.Server.Station.Register( stationid, vec, angle ) |
|
|
|
|
|
|
|
Quantum.Server.StationsPos[#Quantum.Server.StationsPos + 1] = { |
|
|
|
|
|
|
|
id = stationid, |
|
|
|
|
|
|
|
pos = vec, |
|
|
|
|
|
|
|
ang = angle |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
function Quantum.Server.Station.Create( id, tbl ) |
|
|
|
function Quantum.Server.Station.Create( id, tbl ) |
|
|
|
local stationTbl = Quantum.Station.Get( id ) |
|
|
|
local stationTbl = Quantum.Station.Get( id ) |
|
|
@ -54,6 +63,12 @@ if SERVER then |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function Quantum.Server.Station.SpawnAllRegistered() |
|
|
|
|
|
|
|
for i, station in pairs( Quantum.Server.StationsPos ) do |
|
|
|
|
|
|
|
Quantum.Server.Station.Create( station.id, { pos = station.pos, ang = station.ang } ) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
function Quantum.Server.Station.Remove( station ) |
|
|
|
function Quantum.Server.Station.Remove( station ) |
|
|
|
if( IsValid( station ) ) then |
|
|
|
if( IsValid( station ) ) then |
|
|
|
station:Remove() |
|
|
|
station:Remove() |
|
|
@ -68,6 +83,19 @@ if SERVER then |
|
|
|
|
|
|
|
|
|
|
|
Quantum.Server.Station.RemoveAll() -- remove all stations on lua refresh |
|
|
|
Quantum.Server.Station.RemoveAll() -- remove all stations on lua refresh |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( Quantum.Server.StationsSpawned ) then |
|
|
|
|
|
|
|
Quantum.Server.Station.SpawnAllRegistered() -- and create new ones |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hook.Add( "PlayerInitialSpawn", "Quantum_Init_Stations_Load", function() |
|
|
|
|
|
|
|
Quantum.Debug( "Spawning registered crafting stations..." ) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( #player.GetAll() == 1 ) then -- spawn the stations when the first player joins |
|
|
|
|
|
|
|
Quantum.Server.Station.SpawnAllRegistered() |
|
|
|
|
|
|
|
Quantum.Server.StationsSpawned = true |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
|
|
hook.Add( "KeyRelease", "Quantum_Station_KeyRelease", function( pl, key ) |
|
|
|
hook.Add( "KeyRelease", "Quantum_Station_KeyRelease", function( pl, key ) |
|
|
|
if( pl.isloaded ) then |
|
|
|
if( pl.isloaded ) then |
|
|
|
if( key == IN_USE ) then |
|
|
|
if( key == IN_USE ) then |
|
|
|