-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathclient.lua
More file actions
95 lines (86 loc) · 3 KB
/
Copy pathclient.lua
File metadata and controls
95 lines (86 loc) · 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
local QBCore = exports["qb-core"]:GetCoreObject()
local currentClass = "A"
local vaildveh = false
local player = QBCore.Functions.GetPlayerData()
local PlayerJob = {}
PlayerJob = player.job
local IsThreadActive = false
local function validVehicle(vehicleModel)
local isValid = false
if Config.VehiclesConfig[vehicleModel] then isValid = true end
return isValid
end
local function getHandlingConfig(vehicleModel)
if Config.VehiclesConfig[vehicleModel] then
return Config.VehiclesConfig[vehicleModel][currentClass]
end
end
local function changeClass()
local vehicle = GetVehiclePedIsIn(PlayerPedId())
if currentClass == "A" then
currentClass = "A+"
elseif currentClass == "A+" then
currentClass = "S+"
SetVehicleModKit(vehicle, 0)
ToggleVehicleMod(vehicle, 22, true)
ToggleVehicleMod(vehicle, 18, true)
SetVehicleMod(vehicle, 11, 2, false)
SetVehicleXenonLightsColor(vehicle, 1)
elseif currentClass == "S+" then
currentClass = "A"
ToggleVehicleMod(vehicle, 22, false)
ToggleVehicleMod(vehicle, 18, false)
SetVehicleMod(vehicle, 11, -1, false)
end
end
local updateHandliong = function(vehicle)
for k,v in pairs(getHandlingConfig(GetEntityModel(vehicle))) do
SetVehicleHandlingFloat(vehicle, "CHandlingData", k, v)
end
end
local handlingThread = function()
CreateThread(function()
while IsThreadActive do
local Sleeper = 1000
local plyPed = PlayerPedId()
if IsPedInAnyVehicle(plyPed, false) then
local plyVehicle = GetVehiclePedIsIn(plyPed)
if DoesEntityExist(plyVehicle) and validVehicle(GetEntityModel(plyVehicle)) then
vaildveh = true
updateHandliong(plyVehicle)
if IsControlPressed(0, Config.KeyBind) then
changeClass()
QBCore.Functions.Notify(("Changed class to %s"):format(currentClass))
updateHandliong(plyVehicle)
end
Sleeper = 200
end
else
vaildveh = false
currentClass = "A"
end
Wait(Sleeper)
end
end)
end
RegisterNetEvent('QBCore:Client:OnJobUpdate', function(JobInfo)
PlayerJob = JobInfo
if JobInfo.name == 'police' then
IsThreadActive = true
handlingThread()
else
IsThreadActive = false
end
end)
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
player = QBCore.Functions.GetPlayerData()
if player.job.name == "police" then
IsThreadActive = true
handlingThread()
else
IsThreadActive = false
end
end)
RegisterCommand("carhash", function()
print(('^6[^3qb-pursuitmode^6]^0: Vehicle Hash "%s"'):format(GetEntityModel(GetVehiclePedIsIn(PlayerPedId(), -1))))
end)