aboutsummaryrefslogtreecommitdiff
path: root/gamemode/shared/prayersystem/prayers/ninelives.lua
blob: 4c7a13a6036b3e37bfb43ed72320b1fbdc73a37e (plain)
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
--[[
    An example item
]]
local item = {}

--Required, a name, all item names must be unique
item.Name = "Nine Lives"

--Optional, a tooltip to display when hovered over
item.Tooltip = "A prayer to the rouge god to prevent fall dammage for the next 9 falls that you would have taken dammage, or for 5 minutes, whichever comes first."

--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_ninelives")
    net.Receive("art_prayer_ninelives",function(ln,ply)
        if ply:HasPrayer("Nine Lives") then
            prayedplayers[ply] = 9
            timer.Simple(60 * 5,function()
                prayedplayers[ply] = nil
            end)
        end
    end)
end

if CLIENT then
    local lastprayer = CurTime()
    prayer.Pray = function(self)
        if CurTime() > lastprayer + 0 then
            net.Start("art_prayer_ninelives")
            net.SendToServer()
            lastprayer = CurTime()
        end
    end

    hook.Add("")
end

hook.Add( "EntityTakeDamage" , "artery_ninelives" , function(ent,info)
    if info:GetDamageType() ==  DMG_FALL and prayedplayers[ent] ~= nil and prayedplayers[ent] > 0 then
        info:SetDamage(0)
    end
end)

--Optional. Something run once when this item is drawn in a backpack
function prayer.DoOnPanel(dimagebutton)
    dimagebutton:SetImage( "prayericons/ninelives.png")
end


ART.RegisterPrayer(item)