Skip to content

Commit aeb29f8

Browse files
committed
Added item hooks - see documentation. UNTESTED.
1 parent 5d947c0 commit aeb29f8

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

lua/sh_pointshop.lua

+12
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,18 @@ function PS:LoadItems()
8989

9090
-- item hooks
9191

92+
for prop, val in pairs(ITEM) do
93+
if type(val) == "function" then -- although this hooks every function, it doesn't matter because the non-hook functions will never get called
94+
hook.Add(prop, 'PS_Item_' .. ITEM.Name .. '_' .. prop, function(...)
95+
for _, ply in pairs(player.GetAll()) do
96+
if ply:PS_HasItemEquipped(ITEM.ID) then -- hooks are only called if the player has the item equipped
97+
ITEM[prop](ITEM, ply, unpack({...}))
98+
end
99+
end
100+
end)
101+
end
102+
end
103+
92104
self.Items[ITEM.ID] = ITEM
93105

94106
ITEM = nil

0 commit comments

Comments
 (0)