-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclient.lua
More file actions
343 lines (297 loc) · 18 KB
/
client.lua
File metadata and controls
343 lines (297 loc) · 18 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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
--[[
██╗ ██╗ ██╗██████╗ ██████╗ ██████╗ █████╗ ██╗ ██╗███████╗
██║ ╚██╗██╔╝██╔══██╗ ██╔══██╗██╔══██╗██╔══██╗██║ ██╔╝██╔════╝
██║ ╚███╔╝ ██████╔╝█████╗██████╔╝██████╔╝███████║█████╔╝ █████╗
██║ ██╔██╗ ██╔══██╗╚════╝██╔══██╗██╔══██╗██╔══██║██╔═██╗ ██╔══╝
███████╗██╔╝ ██╗██║ ██║ ██████╔╝██║ ██║██║ ██║██║ ██╗███████╗
╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝
██████╗ ██╗███████╗██╗ ██╗ ███████╗██╗ ██╗███████╗
██╔══██╗██║██╔════╝██║ ██╔╝ ██╔════╝╚██╗ ██╔╝██╔════╝
██║ ██║██║███████╗█████╔╝ ███████╗ ╚████╔╝ ███████╗
██║ ██║██║╚════██║██╔═██╗ ╚════██║ ╚██╔╝ ╚════██║
██████╔╝██║███████║██║ ██╗ ███████║ ██║ ███████║
╚═════╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚══════╝ ╚═╝ ╚══════╝
🐺 LXR Brake Disk Heat System — Client
Heated Wheel / Brake Disc Visual Effect for Cars & Vehicles
═══════════════════════════════════════════════════════════════════════════════
SERVER INFORMATION
═══════════════════════════════════════════════════════════════════════════════
Server: The Land of Wolves 🐺
Developer: iBoss21 / The Lux Empire
Website: https://www.wolves.land
Discord: https://discord.gg/CrKcWdfd3A
Store: https://theluxempire.tebex.io
═══════════════════════════════════════════════════════════════════════════════
© 2026 iBoss21 / The Lux Empire | wolves.land | All Rights Reserved
]]
-- ═══════════════════════════════════════════════════════════════════════════════
-- 🐺 FRAMEWORK BRIDGE
-- ═══════════════════════════════════════════════════════════════════════════════
local Framework = nil
local FrameworkName = 'standalone'
local function InitFramework()
if Config.Framework ~= 'auto' then
FrameworkName = Config.Framework
else
-- Auto-detect: priority → LXR-Core → QB-Core → Standalone
if GetResourceState('lxr-core') == 'started' then
FrameworkName = 'lxr-core'
elseif GetResourceState('qb-core') == 'started' then
FrameworkName = 'qb-core'
else
FrameworkName = 'standalone'
end
end
if FrameworkName == 'lxr-core' then
Framework = exports['lxr-core']:GetCoreObject()
elseif FrameworkName == 'qb-core' then
Framework = exports['qb-core']:GetCoreObject()
end
if Config.Debug then
print(('[lxr-brakedisk] Framework detected: %s'):format(FrameworkName))
end
end
-- ═══════════════════════════════════════════════════════════════════════════════
-- 🐺 NOTIFICATION HELPER
-- ═══════════════════════════════════════════════════════════════════════════════
local function Notify(msg)
if FrameworkName == 'lxr-core' and Framework then
Framework.Functions.Notify(msg, 'inform')
elseif FrameworkName == 'qb-core' and Framework then
Framework.Functions.Notify(msg, 'primary', 4000)
else
-- Standalone fallback: use the game chat
TriggerEvent('chat:addMessage', { color = { 255, 255, 255 }, multiline = true, args = { 'System', msg } })
end
end
-- ═══════════════════════════════════════════════════════════════════════════════
-- 🐺 LOCALE HELPER
-- ═══════════════════════════════════════════════════════════════════════════════
local function L(key)
local lang = Config.Locale[Config.Lang] or Config.Locale['en']
return lang[key] or key
end
-- ═══════════════════════════════════════════════════════════════════════════════
-- 🐺 STATE
-- ═══════════════════════════════════════════════════════════════════════════════
local heat_front = 0.0
local heat_rear = 0.0
local glow_front = 0
local glow_rear = 0
local enabled = Config.General.defaultEnabled and 1 or 0
local rearvehicles = {}
local frontvehicles = {}
local players_string
-- ═══════════════════════════════════════════════════════════════════════════════
-- 🐺 TOGGLE COMMAND
-- ═══════════════════════════════════════════════════════════════════════════════
TriggerEvent('chat:addSuggestion', '/' .. Config.General.command,
'Toggle heated disc effect on/off.', {})
RegisterCommand(Config.General.command, function()
if enabled == 1 then
enabled = 0
Notify(L('effect_off'))
else
enabled = 1
Notify(L('effect_on'))
end
end)
-- ═══════════════════════════════════════════════════════════════════════════════
-- 🐺 NEARBY PLAYER UTILITY
-- ═══════════════════════════════════════════════════════════════════════════════
local function GetClosestPlayers()
local players1 = GetActivePlayers()
local plyCoords = GetEntityCoords(PlayerPedId(), 0)
players_string = '-'
local calculating = '-'
CreateThread(function()
for i in pairs(players1) do
local playercoords = GetEntityCoords(GetPlayerPed(players1[i]))
if GetDistanceBetweenCoords(
plyCoords.x, plyCoords.y, plyCoords.z,
playercoords.x, playercoords.y, playercoords.z, 1
) < Config.General.broadcastRadius then
calculating = calculating .. GetPlayerServerId(players1[i]) .. '-'
end
end
players_string = calculating
end)
end
-- ═══════════════════════════════════════════════════════════════════════════════
-- 🐺 HEAT ACCUMULATION LOOP
-- ═══════════════════════════════════════════════════════════════════════════════
CreateThread(function()
while true do
Wait(10)
local ped = PlayerPedId()
local vehicle = GetVehiclePedIsIn(ped, false)
local cfg = Config.General
local ctrl = Config.Controls
-- Only accumulate heat when the local player is the driver
if vehicle ~= 0 and GetPedInVehicleSeat(vehicle, -1) == ped then
-- Handbrake while moving — heats rear wheels
if GetVehicleHandbrake(vehicle) and GetEntitySpeed(vehicle) > cfg.speedThreshold then
Wait(5)
if heat_rear < cfg.heatMax then
heat_rear = heat_rear + cfg.heatIncrement
end
end
-- Forward motion + braking — heats both axles
if GetEntitySpeed(vehicle) > cfg.speedThreshold
and GetVehicleCurrentGear(vehicle) ~= 0 then
if IsControlPressed(ctrl.inputGroup, ctrl.brake) then
if heat_rear < cfg.heatMax then heat_rear = heat_rear + cfg.heatIncrement end
if heat_front < cfg.heatMax then heat_front = heat_front + cfg.heatIncrement end
end
end
-- Reversing + accelerate — heats both axles
if GetEntitySpeed(vehicle) > cfg.speedThreshold
and GetVehicleCurrentGear(vehicle) == 0 then
if IsControlPressed(ctrl.inputGroup, ctrl.reverse) then
if heat_rear < cfg.heatMax then heat_rear = heat_rear + cfg.heatIncrement end
if heat_front < cfg.heatMax then heat_front = heat_front + cfg.heatIncrement end
end
end
else
-- Not driving — reset immediately
glow_rear = 0
glow_front = 0
heat_rear = 0.0
heat_front = 0.0
end
-- ── Rear glow state management ───────────────────────────────────────
if glow_rear == 0 then
if heat_rear > cfg.heatGlowThresh then
GetClosestPlayers()
while players_string == '-' do Wait(100) end
glow_rear = 1
TriggerServerEvent('lxr-brakedisk:add_rear',
VehToNet(GetVehiclePedIsIn(ped, false)), players_string)
end
else
if heat_rear < cfg.heatGlowThresh then
glow_rear = 0
TriggerServerEvent('lxr-brakedisk:rem_rear',
VehToNet(GetVehiclePedIsIn(ped, false)))
end
end
-- ── Front glow state management ──────────────────────────────────────
if glow_front == 0 then
if heat_front > cfg.heatGlowThresh then
GetClosestPlayers()
while players_string == '-' do Wait(100) end
glow_front = 1
TriggerServerEvent('lxr-brakedisk:add_front',
VehToNet(GetVehiclePedIsIn(ped, false)), players_string)
end
else
if heat_front < cfg.heatGlowThresh then
glow_front = 0
TriggerServerEvent('lxr-brakedisk:rem_front',
VehToNet(GetVehiclePedIsIn(ped, false)))
end
end
-- ── Passive cooling ───────────────────────────────────────────────────
if heat_rear > 1 then heat_rear = heat_rear - cfg.heatDecrement end
if heat_front > 1 then heat_front = heat_front - cfg.heatDecrement end
end
end)
-- ═══════════════════════════════════════════════════════════════════════════════
-- 🐺 NETWORK EVENTS — receive glow updates from server
-- ═══════════════════════════════════════════════════════════════════════════════
RegisterNetEvent('lxr-brakedisk:add_rear')
AddEventHandler('lxr-brakedisk:add_rear', function(vehicle, players)
if enabled == 1 then
if players:find('%-' .. tostring(GetPlayerServerId(PlayerId())) .. '%-') then
table.insert(rearvehicles, NetToVeh(vehicle))
end
end
end)
RegisterNetEvent('lxr-brakedisk:add_front')
AddEventHandler('lxr-brakedisk:add_front', function(vehicle, players)
if enabled == 1 then
if players:find('%-' .. tostring(GetPlayerServerId(PlayerId())) .. '%-') then
table.insert(frontvehicles, NetToVeh(vehicle))
end
end
end)
RegisterNetEvent('lxr-brakedisk:rem_rear')
AddEventHandler('lxr-brakedisk:rem_rear', function(vehicle)
for i in pairs(rearvehicles) do
if rearvehicles[i] == NetToVeh(vehicle) then
table.remove(rearvehicles, i)
break
end
end
end)
RegisterNetEvent('lxr-brakedisk:rem_front')
AddEventHandler('lxr-brakedisk:rem_front', function(vehicle)
for i in pairs(frontvehicles) do
if frontvehicles[i] == NetToVeh(vehicle) then
table.remove(frontvehicles, i)
break
end
end
end)
-- ═══════════════════════════════════════════════════════════════════════════════
-- 🐺 PARTICLE RENDER — REAR WHEELS
-- ═══════════════════════════════════════════════════════════════════════════════
CreateThread(function()
while true do
Wait(1)
local ptcl = Config.Particles
for IR in pairs(rearvehicles) do
if IsVehicleSeatFree(rearvehicles[IR], -1) then
table.remove(rearvehicles, IR)
else
for _, bone in ipairs(ptcl.rearBones) do
UseParticleFxAsset(ptcl.asset)
local fx = StartParticleFxLoopedOnEntityBone(
ptcl.name, rearvehicles[IR],
ptcl.offsetX, ptcl.offsetY, ptcl.offsetZ,
ptcl.rotX, ptcl.rotY, ptcl.rotZ,
GetEntityBoneIndexByName(rearvehicles[IR], bone),
ptcl.scale, 0.0, 0.0, 0.0
)
StopParticleFxLooped(fx, 1)
end
end
end
end
end)
-- ═══════════════════════════════════════════════════════════════════════════════
-- 🐺 PARTICLE RENDER — FRONT WHEELS
-- ═══════════════════════════════════════════════════════════════════════════════
CreateThread(function()
while true do
Wait(1)
local ptcl = Config.Particles
for IF in pairs(frontvehicles) do
if IsVehicleSeatFree(frontvehicles[IF], -1) then
table.remove(frontvehicles, IF)
else
for _, bone in ipairs(ptcl.frontBones) do
UseParticleFxAsset(ptcl.asset)
local fx = StartParticleFxLoopedOnEntityBone(
ptcl.name, frontvehicles[IF],
ptcl.offsetX, ptcl.offsetY, ptcl.offsetZ,
ptcl.rotX, ptcl.rotY, ptcl.rotZ,
GetEntityBoneIndexByName(frontvehicles[IF], bone),
ptcl.scale, 0.0, 0.0, 0.0
)
StopParticleFxLooped(fx, 1)
end
end
end
end
end)
-- ═══════════════════════════════════════════════════════════════════════════════
-- 🐺 STARTUP BOOT
-- ═══════════════════════════════════════════════════════════════════════════════
AddEventHandler('onClientResourceStart', function(resourceName)
if resourceName ~= GetCurrentResourceName() then return end
InitFramework()
if Config.Debug then
print(('[lxr-brakedisk] Client loaded | Framework: %s'):format(FrameworkName))
end
end)