-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathclient.lua
More file actions
512 lines (386 loc) · 15.3 KB
/
client.lua
File metadata and controls
512 lines (386 loc) · 15.3 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
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
local vehicle = nil
local numgears = nil
local topspeedGTA = nil
local topspeedms = nil
local acc = nil
local hash = nil
local selectedgear = 0
local hbrake = nil
local manualon = false
local incar = false
local currspeedlimit = nil
local ready = false
local realistic = false
RegisterCommand("manual", function()
if vehicle == nil then
if manualon == false then
manualon = true
--TriggerEvent('chatMessage', '', {255, 255, 255}, '^7' .. 'Manual Mode ON' .. '^7.')
else
manualon = false
--TriggerEvent('chatMessage', '', {255, 255, 255}, '^7' .. 'Manual Mode OFF' .. '^7.')
end
end
end)
RegisterCommand("manualmode", function()
if vehicle == nil then
if manualon == false then
else
if realistic == true then
realistic = false
--TriggerEvent('chatMessage', '', {255, 255, 255}, '^7' .. 'Manual Mode SIMPLE' .. '^7.')
else
realistic = true
--TriggerEvent('chatMessage', '', {255, 255, 255}, '^7' .. 'Manual Mode REALISTIC' .. '^7.')
end
end
end
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(100)
local ped = PlayerPedId()
local newveh = GetVehiclePedIsIn(ped,false)
local class = GetVehicleClass(newveh)
if newveh == vehicle then
elseif newveh == 0 and vehicle ~= nil then
resetvehicle()
else
if GetPedInVehicleSeat(newveh,-1) == ped then
if class ~= 13 and class ~= 14 and class ~= 15 and class ~= 16 and class ~= 21 then
vehicle = newveh
hash = GetEntityModel(newveh)
if GetVehicleMod(vehicle,13) < 0 then
numgears = GetVehicleHandlingInt(newveh, "CHandlingData", "nInitialDriveGears")
else
numgears = GetVehicleHandlingInt(newveh, "CHandlingData", "nInitialDriveGears") + 1
end
hbrake = GetVehicleHandlingFloat(newveh, "CHandlingData", "fHandBrakeForce")
topspeedGTA = GetVehicleHandlingFloat(newveh, "CHandlingData", "fInitialDriveMaxFlatVel")
topspeedms = (topspeedGTA * 1.32)/3.6
acc = GetVehicleHandlingFloat(newveh, "CHandlingData", "fInitialDriveForce")
--SetVehicleMaxSpeed(newveh,topspeedms)
selectedgear = 0
Citizen.Wait(50)
ready = true
end
end
end
end
end)
function resetvehicle()
SetVehicleHandlingFloat(vehicle, "CHandlingData", "fInitialDriveForce", acc)
SetVehicleHandlingFloat(vehicle, "CHandlingData", "fInitialDriveMaxFlatVel",topspeedGTA)
SetVehicleHandlingFloat(vehicle, "CHandlingData", "fHandBrakeForce", hbrake)
SetVehicleHighGear(vehicle, numgears)
ModifyVehicleTopSpeed(vehicle,1)
--SetVehicleMaxSpeed(vehicle,topspeedms)
SetVehicleHandbrake(vehicle, false)
vehicle = nil
numgears = nil
topspeedGTA = nil
topspeedms = nil
acc = nil
hash = nil
hbrake = nil
selectedgear = 0
currspeedlimit = nil
ready = false
end
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if manualon == true and vehicle ~= nil then
DisableControlAction(0, 80, true)
DisableControlAction(0, 21, true)
end
end
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if manualon == true and vehicle ~= nil then
if vehicle ~= nil then
-- Shift up and down
if ready == true then
if IsDisabledControlJustPressed(0, 21) then
if selectedgear <= numgears - 1 then
DisableControlAction(0, 71, true)
Wait(300)
selectedgear = selectedgear + 1
DisableControlAction(0, 71, false)
SimulateGears()
end
elseif IsDisabledControlJustPressed(0, 80) then
if selectedgear > -1 then
DisableControlAction(0, 71, true)
Wait(300)
selectedgear = selectedgear - 1
DisableControlAction(0, 71, false)
SimulateGears()
end
end
end
end
end
end
end)
function SimulateGears()
local engineup = GetVehicleMod(vehicle,11)
if selectedgear > 0 then
local ratio
if Config.vehicles[hash] ~= nil then
if selectedgear ~= 0 and selectedgear ~= nil then
if numgears ~= nil and selectedgear ~= nil then
ratio = Config.vehicles[hash][numgears][selectedgear] * (1/0.9)
else
ratio = Config.gears[numgears][selectedgear] * (1/0.9)
end
end
else
if selectedgear ~= 0 and selectedgear ~= nil then
if numgears ~= nil and selectedgear ~= nil then
ratio = Config.gears[numgears][selectedgear] * (1/0.9)
else
end
end
end
if ratio ~= nil then
SetVehicleHighGear(vehicle,1)
newacc = ratio * acc
newtopspeedGTA = topspeedGTA / ratio
newtopspeedms = topspeedms / ratio
--if GetEntitySpeed(vehicle) > newtopspeedms then
--selectedgear = selectedgear + 1
--else
SetVehicleHandbrake(vehicle, false)
SetVehicleHandlingFloat(vehicle, "CHandlingData", "fInitialDriveForce", newacc)
SetVehicleHandlingFloat(vehicle, "CHandlingData", "fInitialDriveMaxFlatVel", newtopspeedGTA)
SetVehicleHandlingFloat(vehicle, "CHandlingData", "fHandBrakeForce", hbrake)
ModifyVehicleTopSpeed(vehicle,1)
--SetVehicleMaxSpeed(vehicle,newtopspeedms)
currspeedlimit = newtopspeedms
--end
end
elseif selectedgear == 0 then
--SetVehicleHandlingFloat(vehicle, "CHandlingData", "fInitialDriveMaxFlatVel", 0.0)
elseif selectedgear == -1 then
--if GetEntitySpeedVector(vehicle,true).y > 0.1 then
--selectedgear = selectedgear + 1
--else
SetVehicleHandbrake(vehicle, false)
SetVehicleHighGear(vehicle,numgears)
SetVehicleHandlingFloat(vehicle, "CHandlingData", "fInitialDriveForce", acc)
SetVehicleHandlingFloat(vehicle, "CHandlingData", "fInitialDriveMaxFlatVel", topspeedGTA)
SetVehicleHandlingFloat(vehicle, "CHandlingData", "fHandBrakeForce", hbrake)
ModifyVehicleTopSpeed(vehicle,1)
--SetVehicleMaxSpeed(vehicle,topspeedms)
--end
end
SetVehicleMod(vehicle,11,engineup,false)
end
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if manualon == true and vehicle ~= nil then
if selectedgear == -1 then
if GetVehicleCurrentGear(vehicle) == 1 then
DisableControlAction(0, 71, true)
end
elseif selectedgear > 0 then
if GetEntitySpeedVector(vehicle,true).y < 0.0 then
DisableControlAction(0, 72, true)
end
elseif selectedgear == 0 then
SetVehicleHandbrake(vehicle, true)
if IsControlPressed(0, 76) == false then
SetVehicleHandlingFloat(vehicle, "CHandlingData", "fHandBrakeForce", 0.0)
else
SetVehicleHandlingFloat(vehicle, "CHandlingData", "fHandBrakeForce", hbrake)
end
end
else
Citizen.Wait(100)
end
end
end)
local disable = false
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if realistic == true then
if manualon == true and vehicle ~= nil then
if selectedgear > 1 then
if IsControlPressed(0,71) then
local speed = GetEntitySpeed(vehicle)
local minspeed = currspeedlimit / 7
if speed < minspeed then
if GetVehicleCurrentRpm(vehicle) < 0.4 then
disable = true
end
end
end
end
else
Citizen.Wait(100)
end
else
Citizen.Wait(100)
end
end
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if disable == true then
SetVehicleEngineOn(vehicle,false,true,false)
Citizen.Wait(1000)
disable = false
end
end
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if vehicle ~= nil and selectedgear ~= 0 then
local speed = GetEntitySpeed(vehicle)
if currspeedlimit ~= nil then
if speed >= currspeedlimit then
if Config.enginebrake == true then
if speed / currspeedlimit > 1.1 then
--print('dead')
local hhhh = speed / currspeedlimit
SetVehicleCurrentRpm(vehicle,hhhh)
SetVehicleCheatPowerIncrease(vehicle,-100.0)
--SetVehicleBurnout(vehicle,true)
else
--SetVehicleBurnout(vehicle,false)
SetVehicleCheatPowerIncrease(vehicle,0.0)
end
else
SetVehicleCheatPowerIncrease(vehicle,0.0)
end
--SetVehicleHandbrake(vehicle, true)
--if IsControlPressed(0, 76) == false then
--SetVehicleHandlingFloat(vehicle, "CHandlingData", "fHandBrakeForce", 0.0)
-- else
--SetVehicleHandlingFloat(vehicle, "CHandlingData", "fHandBrakeForce", hbrake)
--end
else
--SetVehicleHandbrake(vehicle, false)
--if IsControlPressed(0, 76) == false then
--else
--SetVehicleHandbrake(vehicle, true)
--SetVehicleHandlingFloat(vehicle, "CHandlingData", "fHandBrakeForce", hbrake)
--end
end
else
if speed >= topspeedms then
SetVehicleCheatPowerIncrease(vehicle,0.0)
--SetVehicleHandbrake(vehicle, true)
--if IsControlPressed(0, 76) == false then
--SetVehicleHandlingFloat(vehicle, "CHandlingData", "fHandBrakeForce", 0.0)
--else
--SetVehicleHandlingFloat(vehicle, "CHandlingData", "fHandBrakeForce", hbrake)
--end
else
--SetVehicleHandbrake(vehicle, false)
--if IsControlPressed(0, 76) == false then
--else
--SetVehicleHandbrake(vehicle, true)
--SetVehicleHandlingFloat(vehicle, "CHandlingData", "fHandBrakeForce", hbrake)
--end
end
end
end
end
end)
---------------debug
Citizen.CreateThread(function()
Citizen.Wait(100)
if Config.gearhud == 1 then
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if manualon == true and vehicle ~= nil then
SetTextFont(0)
SetTextProportional(1)
SetTextScale(0.0, 0.3)
SetTextColour(128, 128, 128, 255)
SetTextDropshadow(0, 0, 0, 0, 255)
SetTextEdge(1, 0, 0, 0, 255)
SetTextDropShadow()
SetTextOutline()
SetTextEntry("STRING")
AddTextComponentString("~r~Gear: ~w~"..getinfo(selectedgear))
DrawText(0.015, 0.78)
else
Citizen.Wait(100)
end
end
end)
elseif Config.gearhud == 2 then
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if manualon == true and vehicle ~= nil then
SetTextFont(0)
SetTextProportional(1)
SetTextScale(0.0, 0.3)
SetTextColour(128, 128, 128, 255)
SetTextDropshadow(0, 0, 0, 0, 255)
SetTextEdge(1, 0, 0, 0, 255)
SetTextDropShadow()
SetTextOutline()
SetTextEntry("STRING")
AddTextComponentString("~r~Gear: ~w~"..getinfo(selectedgear).." ~r~Km/h: ~w~"..round((GetEntitySpeed(vehicle)*3.6),0).." ~r~RPM: ~w~"..round(GetVehicleCurrentRpm(vehicle),2))
DrawText(0.015, 0.78)
else
Citizen.Wait(100)
end
end
end)
end
end)
function getinfo(gea)
if gea == 0 then
return "N"
elseif gea == -1 then
return "R"
else
return gea
end
end
function round(value, numDecimalPlaces)
if numDecimalPlaces then
local power = 10^numDecimalPlaces
return math.floor((value * power) + 0.5) / (power)
else
return math.floor(value + 0.5)
end
end
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
--if manualon == true and vehicle ~= nil then
SetTextFont(0)
SetTextProportional(1)
SetTextScale(0.0, 0.2)
SetTextColour(128, 128, 128, 255)
SetTextDropshadow(0, 0, 0, 0, 255)
SetTextEdge(1, 0, 0, 0, 255)
SetTextDropShadow()
SetTextOutline()
SetTextEntry("STRING")
if manualon == true then
if realistic == false then
AddTextComponentString("~r~HRSGears: ~g~On ~r~Mode: ~g~Arcade")
else
AddTextComponentString("~r~HRSGears: ~g~On ~r~Mode: ~g~Realistic")
end
else
AddTextComponentString("~r~HRSGears: ~w~Off")
end
DrawText(0.95, 0.005)
end
end)