-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHooks.lua
103 lines (82 loc) · 2.9 KB
/
Hooks.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
-- When a brewing process has completed.
function OnBrewingCompleted(world, stand)
-- Brewer
return false
end
-- When a player picks up an item.
function OnCollectingPickup(player, pickup)
local item = pickup.GetItem(pickup)
local reward = jobs:dispatch(player:GetUUID(), "gatherer", item.m_ItemType)
if reward then
local amount = cPluginManager:CallPlugin("Coin", "Credit", player:GetUUID(), reward)
player:SendMessageSuccess("Gatherer reward: " .. amount)
end
return false
end
-- When a player or mob dies.
function OnKilled(victim, tdi, message)
-- ?
return false
end
-- When a player breaks a block reward them for it.
function OnPlayerBrokenBlock(player, bx, by, bz, bface, btype, bmeta)
local reward1 = jobs:dispatch(player:GetUUID(), "miner", btype)
local reward2 = jobs:dispatch(player:GetUUID(), "woodcutter", btype)
if reward1 then
local amount = cPluginManager:CallPlugin("Coin", "Credit", player:GetUUID(), reward1)
player:SendMessageSuccess("Miner reward: " .. amount)
end
if reward2 then
local amount = cPluginManager:CallPlugin("Coin", "Credit", player:GetUUID(), reward2)
player:SendMessageSuccess("Woodcutter reward: " .. amount)
end
return false
end
-- When a player leaves the game save the jobs to disk.
function OnPlayerDestroyed(player)
jobs:save()
return false
end
-- When a player has fished.
function OnPlayerFished(player, reward)
local _reward = 0.00
for i = 0, (reward:Size() - 1) do
local item = reward.Get(reward, i)
local r = jobs:dispatch(player:GetUUID(), "fisherman", item.m_ItemType)
if r then _reward = _reward + r end
end
if _reward > 0.00 then
local amount = cPluginManager:CallPlugin("Coin", "Credit", player:GetUUID(), _reward)
player:SendMessageSuccess("Fisherman reward: " .. amount)
end
return false
end
-- After a player has placed a block.
function OnPlayerPlacedBlock(player, bx, by, bz, btype, bmeta)
local reward = jobs:dispatch(player:GetUUID(), "builder", btype)
if reward then
local amount = cPluginManager:CallPlugin("Coin", "Credit", player:GetUUID(), reward)
player:SendMessageSuccess("Builder reward: " .. amount)
end
return false
end
-- After a player has used a block: chest, lever, button, etc.
function OnPlayerUsedBlock(player, bx, by, bz, bface, cx, cy, cz, btype, bmeta)
-- ?
return false
end
-- After a player has used an item hoe, place fluid, etc.
function OnPlayerUsedItem(player, bx, by, bz, bface, cx, cy, cz, btype, bmeta)
-- ?
return false
end
-- After a player has crafted an item.
function OnPostCrafting(player, grid, recipe)
local item = recipe:GetResult()
local reward = jobs:dispatch(player:GetUUID(), "crafter", item.m_ItemType)
if reward then
local amount = cPluginManager:CallPlugin("Coin", "Credit", player:GetUUID(), reward)
player:SendMessageSuccess("Crafter reward: " .. amount)
end
return false
end