-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.lua
74 lines (62 loc) · 1.89 KB
/
server.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
local defaultSettings = {
["crouchbug"] = true,
["fastfire"] = true,
["fastmove"] = true,
["fastsprint"] = true,
["quickstand"] = true
}
local AUTO_CBUG_WEAPONS = {
[23] = true,
[24] = true
}
local function sendSetting(value)
if value == nil then
value = get("autoreload")
end
triggerClientEvent(getElementsByType("player"), "onClientSettingChange", resourceRoot, value)
setGlitchEnabled("quickreload", value)
end
local function toggleAutoCbug(value)
for weaponID, _ in pairs(AUTO_CBUG_WEAPONS) do
local time = value and 0 or getOriginalWeaponProperty(weaponID, "pro", "anim_breakout_time")
for _, skill in ipairs({ "poor", "std", "pro" }) do
setWeaponProperty(weaponID, skill, "anim_breakout_time", time)
end
end
end
addEventHandler("onResourceStart", resourceRoot, function()
for glitch, isEnabled in pairs(defaultSettings) do
setGlitchEnabled(glitch, isEnabled)
end
setTimer(sendSetting, 200, 1)
toggleAutoCbug(get("autocbug"))
end)
addEventHandler("onResourceStop", resourceRoot, function()
setGlitchEnabled("quickreload", false)
for glitch, _ in pairs(defaultSettings) do
setGlitchEnabled(glitch, false)
end
end)
addEventHandler("onSettingChange", root, function(setting, _, value)
-- Exit if the resource is not the same as this resource.
local resourceSetting = setting:sub(2, 5)
local resourceName = getResourceName(resource)
if resourceSetting ~= resourceName then
return false
end
value = fromJSON(value)
setting = setting:gsub("*"..resourceName..".", "")
if value == "true" then
value = true
elseif value == "false" then
value = false
end
if setting == "autoreload" then
sendSetting(value)
return true
end
if setting == "autocbug" then
toggleAutoCbug(value)
return true
end
end)