-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclient.lua
More file actions
195 lines (121 loc) · 3.85 KB
/
client.lua
File metadata and controls
195 lines (121 loc) · 3.85 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
local playerPed = 0
local playerVehicle = 0
local vehicleAllowed = false
local vehControlEnabled = false
local isPadShaking = false
Citizen.CreateThread(function()
while (true) do
if (vehicleAllowed) then
if not (vehControlEnabled) then
if (GetEntitySpeed(playerVehicle) > 30.0) then
if (GetVehicleSteeringAngle(playerVehicle) > 30.0) or (GetVehicleSteeringAngle(playerVehicle) < -30.0) then
if (math.random(0, config.steeringChance) == 0) then
TriggerEvent('VehicleControlLoss', playerVehicle)
end
end
end
else
if (IsControlPressed(0, 72)) or (IsControlPressed(0, 76)) then
ShakePad()
end
end
end
Citizen.Wait(0)
end
end)
Citizen.CreateThread(function()
while (true) do
playerPed = PlayerPedId()
playerVehicle = GetVehiclePedIsIn(playerPed, false)
if (IsWeatherAccurate(GetNextWeatherTypeHashName())) then
if (playerVehicle ~= 0) and (GetPedInVehicleSeat(playerVehicle, -1) == playerPed) then
if not (IsClassDisabled(playerVehicle)) and not (IsVehicleDisabled(playerVehicle)) then
if not (vehicleAllowed) then
vehicleAllowed = true
end
if not (vehControlEnabled) then
if (GetEntitySpeed(playerVehicle) > 20.0) then
if (math.random(0, config.randomChance) == 0) then
TriggerEvent('VehicleControlLoss', playerVehicle)
end
end
end
else
if (vehicleAllowed) then
vehicleAllowed = false
end
end
else
if (vehicleAllowed) then
vehicleAllowed = false
end
end
else
if (vehicleAllowed) then
vehicleAllowed = false
end
end
Citizen.Wait(1000)
end
end)
function IsWeatherAccurate(weather)
local accurateWeather = {
1840358669, -- Clearing
1420204096, -- Rain
-1233681761, -- Thunder
-1429616491, -- Xmas
603685163, -- Light Snow
-273223690, -- Snow
669657108 -- Blizzard
}
for i,var in pairs(accurateWeather) do
if (var == weather) then
return true
end
end
return false
end
function IsClassDisabled(vehicle)
local vehClass = GetVehicleClass(vehicle)
local disabledClasses = {
10, -- Industrial
13, -- Cycles
14, -- Boats
15, -- Helicopters
16, -- Planes
19, -- Military
21 -- Trains
}
for i,var in pairs(disabledClasses) do
if (var == vehClass) then
return true
end
end
return false
end
function IsVehicleDisabled(vehicle)
for i,var in pairs(config.disabledVehicles) do
if (GetHashKey(var) == GetEntityModel(vehicle)) then
return true
end
end
return false
end
function ShakePad()
if not (isPadShaking) then
isPadShaking = true
local shakeDuration = math.random(1, 2) * 100
StopPadShake(0)
SetPadShake(0, shakeDuration, 255)
Wait(shakeDuration + 100)
isPadShaking = false
end
end
RegisterNetEvent('VehicleControlLoss')
AddEventHandler('VehicleControlLoss', function(vehicle)
vehControlEnabled = true
SetVehicleReduceGrip(vehicle, true)
Wait(math.random(1, 8) * 1000)
SetVehicleReduceGrip(vehicle, false)
vehControlEnabled = false
end)