-
Notifications
You must be signed in to change notification settings - Fork 2
/
client.lua
35 lines (32 loc) · 1.05 KB
/
client.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
addEventHandler("onClientResourceStart", resourceRoot,
function()
triggerServerEvent(resource.name .. ":getSettings", resourceRoot)
end
)
function onDamage(_, damage)
if damage >= 22 and damage <= 34 then
cancelEvent()
end
end
function onSettingsChange(setting, value)
if type(setting) == "table" then
for setting, value in pairs(setting) do
updateSetting(setting, value)
end
else
updateSetting(setting, value)
end
end
addEvent(resource.name .. ":setSettings", true)
addEvent(resource.name .. ":setSetting", true)
addEventHandler(resource.name .. ":setSettings", resourceRoot, onSettingsChange)
addEventHandler(resource.name .. ":setSetting", resourceRoot, onSettingsChange)
function updateSetting(setting, value)
if setting == "canceldamage" then
if value == "true" then
addEventHandler("onClientPlayerDamage", root, onDamage)
else
removeEventHandler("onClientPlayerDamage", root, onDamage)
end
end
end