aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lua/zones.lua10
-rw-r--r--zone_example.lua12
2 files changed, 19 insertions, 3 deletions
diff --git a/lua/zones.lua b/lua/zones.lua
index 80aaa91..ac0c9dd 100644
--- a/lua/zones.lua
+++ b/lua/zones.lua
@@ -1,5 +1,5 @@
-local version = 1.1 -- Older versions will not run if a newer version is used in another script.
+local version = 1.11 -- Older versions will not run if a newer version is used in another script.
--[[
ZONES - by Bobbleheadbob
WARNING: If you edit any of these files, make them use a different namespace. Multiple scripts may depend on this library so modifying it can break other scripts.
@@ -16,8 +16,9 @@ local version = 1.1 -- Older versions will not run if a newer version is used in
Since multiple scripts might use the zones system, don't assume that every zone is related to your script.
To register a zone class, use zones.RegisterClass(class, color); use a unique string like "Scriptname Room".
When a zone class is registered, admins can use the tool to create new ones.
- When a new zone is created, the "OnZoneCreated" hook is called serverside. See the hook below for documentation.
- When a player edits a zone's properties, the "ShowZoneOptions" hook is called clientside. See the hook below.
+ When a new zone is created, the "OnZoneCreated" hook is called serverside. See the example file for documentation.
+ When a zone is loaded into the game, the "OnZoneLoaded" hook is called serverside. See the example file for documentation.
+ When a player edits a zone's properties, the "ShowZoneOptions" hook is called clientside. See the example file for documentation.
Use zones.FindByClass() to find all zones which are of a given class.
Use ply:GetCurrentZone() to find the zone that a player is standing in.
@@ -53,6 +54,7 @@ zones.version = version
zones.Classes = zones.Classes or {}
zones.List = zones.List or {}
+
//Common interface functions:
-- Registers a zone class which can then be created using weapon_zone_designator
@@ -149,6 +151,8 @@ if SERVER then
if not v.bounds then
zones.CalcBounds(v)
end
+
+ hook.Run("OnZoneLoaded",v,v.class,k)
end
end
diff --git a/zone_example.lua b/zone_example.lua
index 737c706..c2540ca 100644
--- a/zone_example.lua
+++ b/zone_example.lua
@@ -144,5 +144,17 @@ end)
zone.onlyIfShes = "5'3\""
end
end)
+
+ -- Example of the OnZoneLoaded hook.
+ -- This hook is called as a zone is loaded into the game, typically on map startup. Only called serverside.
+ -- Arguments are:
+ -- zone - The full zone table of the zone we are editing.
+ -- class - The class of the zone.
+ -- zoneID - The ID of the zone.
+ hook.Add("OnZoneLoaded","hookname_unique",function(zone,class,zoneID)
+ if class == "Baby Got Back" then --always check class.
+ zone.owner = Entity(1)
+ end
+ end)
]]