Began work on properties & zones

master
E. Almqvist 5 years ago
parent c389ecb518
commit de7d562b47
  1. 41
      gamemode/engine/lib/server/sv_property.lua
  2. 43
      gamemode/engine/lib/server/sv_zone.lua
  3. 4
      gamemode/engine/vars/sv_vars.lua

@ -0,0 +1,41 @@
-- __ _ _______ _ __
-- / / /\ | | |__ __| | | \ \
-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \
-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > >
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / /
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/
Quantum.Server.Property = {}
Quantum.Server.Property.Properties = {}
function Quantum.Server.Property.Register( propid, tbl )
if( Quantum.Server.Property.Properties[propid] == nil ) then
local prop = {
name = tbl.name || "Private Property",
id = propid,
owner = nil,
vec1 = tbl.vec1,
vec2 = tbl.vec2,
price = tbl.price || Quantum.Server.DefualtPropertyPrice
}
prop.zone = Quantum.Server.Zone.Register( propid .. "_zone", { -- register the zone for the property
name = prop.name,
vec1 = prop.vec1,
vec2 = prop.vec2
} )
Quantum.Server.Property.Properties[propid] = prop
return prop
else
Quantum.Error( "Property id '" .. propid .. "' already exists! Aborting..." )
end
end
function Quantum.Server.Property.Get( propid ) return Quantum.Server.Property.Properties[propid] end
-- player functions --
function Quantum.Server.Property.SetOwner( propid, charid )
Quantum.Server.Property.Properties[propid].owner = charid
end

@ -0,0 +1,43 @@
-- __ _ _______ _ __
-- / / /\ | | |__ __| | | \ \
-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \
-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > >
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / /
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/
Quantum.Server.Zone = {}
Quantum.Server.Zone.Zones = {} -- all zones are rectangles where they go from vec1 to vec2
function Quantum.Server.Zone.Register( zoneid, tbl )
if( Quantum.Server.Zone.Zones[zoneid] != nil ) then
local zone = {
name = tbl.name || "Unknown Zone",
id = zoneid,
vec1 = tbl.vec1,
vec2 = tbl.vec2
}
Quantum.Server.Zone.Zones[zoneid] = zone
return zone
else
Quantum.Error( "Zone id '" .. zoneid .. "' already exists! Aborting..." )
end
end
function Quantum.Server.Zone.Get( zoneid )
return Quantum.Server.Zone.Zones[zoneid]
end
function Quantum.Server.Zone.IsInZone( vec, zoneid, zone )
zone = zone || Quantum.Server.Zone.Get( zoneid )
return vec:WithinAABox( zone.vec1, zone.vec2 )
end
function Quantum.Server.Zone.GetCurrentZone( vec )
for i, zone in pairs( Quantum.Server.Zone.Zones ) do
if( Quantum.Server.Zone.IsInZone( vec, nil, zone ) ) then
return zone
end
end
end

@ -7,4 +7,6 @@
Quantum.Server.DefaultNodeHealth = 10 Quantum.Server.DefaultNodeHealth = 10
Quantum.Server.DefaultNodeRespawnTimer = 30 Quantum.Server.DefaultNodeRespawnTimer = 30
Quantum.Server.DefualtPropertyPrice = 5000
Loading…
Cancel
Save