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
|
do return end
--[[
An example prayer
]]
local prayer = {}
--Required, a name, all item names must be unique
prayer.Name = "Thick Skin"
--Optional, a tooltip to display when hovered over
prayer.Tooltip = "A prayer to the warrior god to grant you 20% resistance to all dammage"
--Required Returns the data needed to rebuild this item, should only contain the minimum data nessessary since this gets sent over the network
prayer.Serialize = function(self)
print("Trying to serailize!")
return ""
end
--Required, Rebuilds the item from data created in Serialize, if the item is different from the "main" copy of the item, it should retun a tabl.Copy(self), with the appropriate fields set.
prayer.DeSerialize = function(self,string)
print("Trying to deserialize!")
return self
end
--Optional, when the player clicks this item, a menu will show up, if the menu item is clicked, the function is ran. This is all run client side, so if you want it to do something server side, you'll need to use the net library. Remember that items are in the shared domain, so you can define what it does in the same file!
local prayedplayers = {}
if SERVER then
util.AddNetworkString("art_prayer_thickskin")
net.Receive("art_prayer_thickskin",function(ln,ply)
if ply:HasItem("Thick Skin") then
prayedplayers[ply] = true
timer.Simple(120,function()
prayedplayers[ply] = nil
end)
end
end)
end
local lastprayer = CurTime()
prayer.Pray = function(self)
if SERVER then return end
if CurTime() > lastprayer + 0 then
net.Start("art_prayer_thickskin")
net.SendToServer()
lastprayer = CurTime()
end
end
hook.Add( "EntityTakeDamage" , "artery_thickskin" , function(ent,info)
if prayedplayers[ent] then
info:SetDamage(info:GetDamage()*0.8)
end
end)
--Optional. Something run once when this item is drawn in a backpack
function prayer.DoOnPanel(dimagebutton)
dimagebutton:SetImage( "prayericons/thickskin.png")
end
ART.RegisterPrayer(prayer)
|