This repository was archived by the owner on Apr 23, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig.lua
More file actions
221 lines (193 loc) · 6.97 KB
/
Copy pathconfig.lua
File metadata and controls
221 lines (193 loc) · 6.97 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
-- Config
Config = {}
-- Enables /statusRoll for testing / setup of the StatMaxImpactOnStatusRoll / StatusPointToRollAgainst
Config.Debug = false
-- Use effects - would not recommend for a high latency db connection
Config.UseEffects = true
-- Seconds between status ticks - be mindful of this value when setting up tickDecay on status types
Config.TickTime = 5
-- Both used for ease of use below
local statMidpoint = 100000 / 2
-- The max impact that the difficulty can have on a status roll
Config.StatMaxImpactOnStatusRoll = 100000 / 3
-- The value that status rolls must be rolled against to be considered a pass
Config.StatusPointToRollAgainst = 100000 / 3 - 200
-- A function to kill a player randomly within the next 0.001-10s
local function kill(source)
local ped = GetPlayerPed(source)
if ped ~= 0 and GetEntityHealth(ped) ~= 0 and not GetPlayerInvincible(source) then
CreateThread(function()
local roll = math.random(1, 10000)
Wait(roll)
TriggerClientEvent('esx:killPlayer', source)
end)
end
end
-- Status types
Config.Status = {}
Config.Status.dexterity = {
defaultAmount = 0,
availableToClient = false,
tickDecay = 0,
onTick = nil
}
Config.Status.intelligence = {
defaultAmount = 0,
availableToClient = false,
tickDecay = 0,
onTick = nil
}
Config.Status.luck = {
defaultAmount = 0,
availableToClient = false,
tickDecay = 0,
onTick = nil
}
Config.Status.strength = {
defaultAmount = 0,
availableToClient = false,
tickDecay = 0,
onTick = nil
}
Config.Status.gathering = {
defaultAmount = 0,
availableToClient = false,
tickDecay = 0,
onTick = nil
}
Config.Status.hunger = {
defaultAmount = 100000,
availableToClient = true,
tickDecay = 50,
onTick = function(source, identifier, value)
if value == 0 then -- If no hunger, kill
kill(source)
end
end
}
Config.Status.thirst = {
defaultAmount = 100000,
availableToClient = true,
tickDecay = 80,
onTick = function(source, identifier, value)
if value == 0 then -- If no thirst, kill
kill(source)
end
end
}
Config.Status.stress = {
defaultAmount = 0,
availableToClient = true,
tickDecay = 150,
onTick = function(source, identifier, value)
local vehicle = GetVehiclePedIsIn(GetPlayerPed(source), false)
if vehicle then
local speed = GetEntitySpeed(vehicle)
if speed >= 89.4 then -- at 200 mph add More stress
alterStatus(identifier, 'stress', 1200)
value = bindValue(value + 1200)
elseif speed >= 67.1 then -- at 150 mph add more stress
alterStatus(identifier, 'stress', 1000)
value = bindValue(value + 1000)
elseif speed >= 44.7 then -- at 100 mph begin adding stress
alterStatus(identifier, 'stress', 800)
value = bindValue(value + 800)
end
end
if value == 100000 then -- If fully stressed, kill
kill(source)
end
end
}
Config.Status.caffeine = {
defaultAmount = 0,
availableToClient = true,
tickDecay = 3000,
onTick = function(source, identifier, value)
if value == 100000 then -- Full caffeine should kill
kill(source)
TriggerClientEvent('pc-needs:client:SetCaffeineEffect', source, true)
elseif value > 0 then -- Any caffeine should have a slightly boosted stamina regen speed
TriggerClientEvent('pc-needs:client:SetCaffeineEffect', source, true)
else -- No caffeine should have a normal stamina regen speed
TriggerClientEvent('pc-needs:client:SetCaffeineEffect', source, false)
end
end
}
local outburstEmotes = {'stumble', 'idledrunk', 'idledrunk2', 'idledrunk3'}
Config.Status.alcohol = {
defaultAmount = 0,
availableToClient = true,
tickDecay = 1000,
onTick = function(source, identifier, value)
if value == 100000 then -- Full alcohol should kill
kill(source)
TriggerClientEvent('pc-needs:client:SetDrunkEffect', source, true)
elseif value >= 100000 / 3 then -- 33.33% alcohol should impose random drunk animations and screen effect
TriggerClientEvent('pc-needs:client:SetDrunkEffect', source, true)
local outburstRoll = math.random(1, 100)
if outburstRoll > 95 then
local outburstEmote = outburstEmotes[math.random(1,4)]
TriggerClientEvent('pc-needs:client:SetDrunkOutburst', source, outburstEmote)
end
else -- No alcohol should mean no screen effect
TriggerClientEvent('pc-needs:client:SetDrunkEffect', source, false)
end
end
}
Config.Status.acid = {
defaultAmount = 0,
availableToClient = true,
tickDecay = 2000,
onTick = function(source, identifier, value)
if value > 0 then -- Any acid should give screen effect
TriggerClientEvent('pc-needs:client:SetAcidEffect', source, true)
else -- No acid should have no screen effect
TriggerClientEvent('pc-needs:client:SetAcidEffect', source, false)
end
end
}
Config.Status.thc = {
defaultAmount = 0,
availableToClient = true,
tickDecay = 2500,
onTick = function(source, identifier, value)
if value >= statMidpoint then -- Half thc should have screen effect
TriggerClientEvent('pc-needs:client:SetWeedEffect', source, true)
else -- Less than half thc should not have screen effect
TriggerClientEvent('pc-needs:client:SetWeedEffect', source, false)
end
end
}
Config.Status.oxy = {
defaultAmount = 0,
availableToClient = true,
tickDecay = 1500,
onTick = function(source, identifier, value)
if value == 100000 then -- Full oxy should kill
kill(source)
TriggerClientEvent('pc-needs:client:SetOxyEffect', source, true, true)
elseif value > 30000 then -- Oxy above 30% should give screen effect
TriggerClientEvent('pc-needs:client:SetOxyEffect', source, true, true)
elseif value > 20000 then -- Oxy above 20% give healing effect
TriggerClientEvent('pc-needs:client:SetOxyEffect', source, true, false)
else -- No oxy should give no healing
TriggerClientEvent('pc-needs:client:SetOxyEffect', source, false, false)
end
end
}
Config.Status.meth = {
defaultAmount = 0,
availableToClient = true,
tickDecay = 2000,
onTick = function(source, identifier, value)
if value == 100000 then -- Full meth should kill
kill(source)
TriggerClientEvent('pc-needs:client:SetMethEffect', source, true)
elseif value > 0 then -- Any meth should have a screen effect
TriggerClientEvent('pc-needs:client:SetMethEffect', source, true)
else -- No meth should do nothing
TriggerClientEvent('pc-needs:client:SetMethEffect', source, false)
end
end
}