diff --git a/gamemode/engine/lib/server/sv_property.lua b/gamemode/engine/lib/server/sv_property.lua new file mode 100644 index 0000000..44994ee --- /dev/null +++ b/gamemode/engine/lib/server/sv_property.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 \ No newline at end of file diff --git a/gamemode/engine/lib/server/sv_zone.lua b/gamemode/engine/lib/server/sv_zone.lua new file mode 100644 index 0000000..6e53483 --- /dev/null +++ b/gamemode/engine/lib/server/sv_zone.lua @@ -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 \ No newline at end of file diff --git a/gamemode/engine/vars/sv_vars.lua b/gamemode/engine/vars/sv_vars.lua index d5c920f..e5b9f95 100644 --- a/gamemode/engine/vars/sv_vars.lua +++ b/gamemode/engine/vars/sv_vars.lua @@ -7,4 +7,6 @@ Quantum.Server.DefaultNodeHealth = 10 -Quantum.Server.DefaultNodeRespawnTimer = 30 \ No newline at end of file +Quantum.Server.DefaultNodeRespawnTimer = 30 + +Quantum.Server.DefualtPropertyPrice = 5000 \ No newline at end of file