parent
c389ecb518
commit
de7d562b47
@ -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 |
Loading…
Reference in new issue