-
Notifications
You must be signed in to change notification settings - Fork 44
/
snippets
202 lines (158 loc) · 6.54 KB
/
snippets
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
CREDITS: SNIPE OP GAMING AND FJAMZOO
--SOME SNIPPETS TO GO INTO PS-BUFFS/CLIENT LUA------------------------------------------------------------------------------------------------------------------------------------------------------------------
HEALTH AND ARMOR----
--- Method to add health buff to player
--- @param time - Time in ms the health buff will be active
--- @param value - The amount of HP the player will gain over time
local hasHealthBuffActive = false
local function AddHealthBuff(time, value)
AddBuff("super-health", time)
if not hasHealthBuffActive then
hasHealthBuffActive = true
CreateThread(function()
while HasBuff("super-health") do
Wait(5000)
if GetEntityHealth(PlayerPedId()) < 200 then
SetEntityHealth(PlayerPedId(), GetEntityHealth(PlayerPedId()) + value)
end
end
hasHealthBuffActive = false
end)
end
end exports('AddHealthBuff', AddHealthBuff)
--- Method to add armor buff to player
--- @param time - Time in ms the health buff will be active
--- @param value - The amount of Armor the player will gain over time
local hasArmorBuffActive = false
local function AddArmorBuff(time, value)
AddBuff("super-armor", time)
if not hasArmorBuffActive then
hasArmorBuffActive = true
CreateThread(function()
while HasBuff("super-armor") do
Wait(5000)
if GetPedArmour(PlayerPedId()) < 100 then
SetPedArmour(PlayerPedId(), GetPedArmour(PlayerPedId()) + value)
end
end
hasArmorBuffActive = false
end)
end
end exports('AddArmorBuff', AddArmorBuff)
RegisterCommand("stambuff", function()
AddHealthBuff(50000, math.random(1,5))
Wait(1000)
AddArmorBuff(50000, math.random(1,5))
end)
exports["ps-buffs"]:AddHealthBuff(time in ms, buff amoount)
exports["ps-buffs"]:AddArmorBuff(time in ms, buff amoount)
STAMINA BUFF--
--- Method to add stamina buff to player
--- @param time - Time in ms the health buff will be active
--- @param value - The amount of speed boost the player will recieve
local hasStaminaBuffActive = false
local function StaminaBuffEffect(time, value)
AddBuff("stamina", time)
if not hasStaminaBuffActive then
hasStaminaBuffActive = true
CreateThread(function()
SetRunSprintMultiplierForPlayer(PlayerId(), value)
while exports['ps-buffs']:HasBuff("stamina") do
Wait(500)
SetPlayerStamina(PlayerId(), GetPlayerStamina(PlayerId()) + math.random(1,10))
end
SetRunSprintMultiplierForPlayer(PlayerId(), 1.0)
hasStaminaBuffActive = false
end)
end
end exports('StaminaBuffEffect', StaminaBuffEffect)
exports["ps-buffs"]:StaminaBuffEffect(time in ms, buff amoount)
Stamina buff with values like time and buff amount
SWIMMING BUFF
--- Method to add swimming buff to player
--- @param time - Time in ms the health buff will be active
--- @param value - The amount of swimming speed boost the player will recieve
local hasSwimmingBuffActive = false
local function SwimmingBuffEffect(time, value)
AddBuff("swimming", time)
if not hasSwimmingBuffActive then
hasSwimmingBuffActive = true
CreateThread(function()
SetSwimMultiplierForPlayer(PlayerId(), value)
while exports['ps-buffs']:HasBuff("swimming") do
Wait(500)
SetPlayerStamina(PlayerId(), GetPlayerStamina(PlayerId()) + math.random(1,10))
end
SetSwimMultiplierForPlayer(PlayerId(), 1.0)
hasSwimmingBuffActive = false
end)
end
end exports('SwimmingBuffEffect', SwimmingBuffEffect)
exports["ps-buffs"]:SwimmingBuffEffect(time in ms, buff ammount)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Hunger and Thirst Buff!!
Notes. You need to replace the following snippets in core. Do not ADD
If you add this block of code instead of replacing, you will get error In server console with hungerRate is nil or thirstRate is nil!
--------------qb-core/client/loops.lua---------------------------------------------------------------------------
CreateThread(function()
while true do
local sleep = 0
if LocalPlayer.state.isLoggedIn then
sleep = (1000 * 60) * QBCore.Config.UpdateInterval
local hungerRate = 0
local thirstRate = 0
if exports["ps-buffs"]:HasBuff("super-hunger") then hungerRate = QBCore.Config.Player.HungerRate/2 else hungerRate = QBCore.Config.Player.HungerRate end
if exports["ps-buffs"]:HasBuff("super-thirst") then thirstRate = QBCore.Config.Player.ThirstRate/2 else thirstRate = QBCore.Config.Player.ThirstRate end
TriggerServerEvent('QBCore:UpdatePlayer', hungerRate, thirstRate)
end
Wait(sleep)
end
end)
--
--
--
--
--
--
--
qb-core/server/events.lua - Replace the event with this new event--------------------------------------------------------
RegisterNetEvent('QBCore:UpdatePlayer', function(hungerRate, thirstRate)
print('Updating Player', hungerRate, thirstRate)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
if not Player then return end
local newHunger = Player.PlayerData.metadata['hunger'] - hungerRate
local newThirst = Player.PlayerData.metadata['thirst'] - thirstRate
if newHunger <= 0 then
newHunger = 0
end
if newThirst <= 0 then
newThirst = 0
end
Player.Functions.SetMetaData('thirst', newThirst)
Player.Functions.SetMetaData('hunger', newHunger)
TriggerClientEvent('hud:client:UpdateNeeds', src, newHunger, newThirst)
Player.Functions.Save()
end)
--
--
--
--
--
--
--
Replace this in qb-core/client/events.lua---------------------------------------------------------------------------------------------
RegisterNetEvent('QBCore:Player:UpdatePlayerData', function()
local hungerRate = 0
local thirstRate = 0
if exports["ps-buffs"]:HasBuff("super-hunger") then hungerRate = QBCore.Config.Player.HungerRate/2 else hungerRate = QBCore.Config.Player.HungerRate end
if exports["ps-buffs"]:HasBuff("super-thirst") then thirstRate = QBCore.Config.Player.ThirstRate/2 else thirstRate = QBCore.Config.Player.ThirstRate end
TriggerServerEvent('QBCore:UpdatePlayer', hungerRate, thirstRate)
end)
--
--
--
--
--
--
--