1
1
ESX = nil
2
2
Citizen .CreateThread (function ()
3
3
while ESX == nil do
4
- TriggerEvent (' esx: getSharedObject' , function (obj ) ESX = obj end )
4
+ TriggerEvent (Config . getSharedObject , function (obj ) ESX = obj end )
5
5
Citizen .Wait (0 )
6
6
end
7
7
end )
@@ -66,59 +66,29 @@ AddEventHandler('EngineToggle:Engine', function()
66
66
netTime = netTime - 1
67
67
end
68
68
69
- if Config .VehicleKeyChain then
69
+ if Config .VehicleKeyChain and ( GetResourceState ( " VehicleKeyChain " ) == " started " ) then
70
70
local isVehicleOrKeyOwner = exports [" VehicleKeyChain" ]:IsVehicleOrKeyOwner (veh )
71
71
72
72
if IsPedInAnyVehicle (PlayerPedId (), false ) and isVehicleOrKeyOwner then
73
73
if (GetPedInVehicleSeat (veh , - 1 ) == PlayerPedId ()) then
74
74
vehicles [StateIndex ][2 ] = not GetIsVehicleEngineRunning (veh )
75
75
if vehicles [StateIndex ][2 ] then
76
- if Config .Notifications then
77
- TriggerEvent (' notifications' , " #00EE00" , Translation [Config .Locale ][' notification_header' ], Translation [Config .Locale ][' n_engine_start' ])
78
- elseif Config .OkokNotify then
79
- exports [' okokNotify' ]:Alert (Translation [Config .Locale ][' notification_header' ], Translation [Config .Locale ][' okok_engine_start' ], 5000 , ' info' )
80
- else
81
- TriggerEvent (' esx:showNotification' , Translation [Config .Locale ][' engine_start' ])
82
- end
76
+ Config .Notification (source , ' client' , nil , Translation [Config .Locale ][' engine_start' ])
83
77
else
84
- if Config .Notifications then
85
- TriggerEvent (' notifications' , " #FF0000" , Translation [Config .Locale ][' notification_header' ], Translation [Config .Locale ][' n_engine_stop' ])
86
- elseif Config .OkokNotify then
87
- exports [' okokNotify' ]:Alert (Translation [Config .Locale ][' notification_header' ], Translation [Config .Locale ][' okok_engine_stop' ], 5000 , ' info' )
88
- else
89
- TriggerEvent (' esx:showNotification' , Translation [Config .Locale ][' engine_stop' ])
90
- end
78
+ Config .Notification (source , ' client' , nil , Translation [Config .Locale ][' engine_stop' ])
91
79
end
92
80
end
93
81
elseif IsPedInAnyVehicle (PlayerPedId (), false ) and (not isVehicleOrKeyOwner ) then
94
- if Config .Notifications then
95
- TriggerEvent (' notifications' , " #FF0000" , Translation [Config .Locale ][' notification_header' ], Translation [Config .Locale ][' n_key_nokey' ])
96
- elseif Config .OkokNotify then
97
- exports [' okokNotify' ]:Alert (Translation [Config .Locale ][' notification_header' ], Translation [Config .Locale ][' okok_key_nokey' ], 5000 , ' error' )
98
- else
99
- TriggerEvent (' esx:showNotification' , Translation [Config .Locale ][' key_nokey' ])
100
- end
82
+ Config .Notification (source , ' client' , nil , Translation [Config .Locale ][' key_nokey' ])
101
83
end
102
84
else
103
85
if IsPedInAnyVehicle (PlayerPedId (), false ) then
104
86
if (GetPedInVehicleSeat (veh , - 1 ) == PlayerPedId ()) then
105
87
vehicles [StateIndex ][2 ] = not GetIsVehicleEngineRunning (veh )
106
88
if vehicles [StateIndex ][2 ] then
107
- if Config .Notifications then
108
- TriggerEvent (' notifications' , " #00EE00" , Translation [Config .Locale ][' notification_header' ], Translation [Config .Locale ][' n_engine_start' ])
109
- elseif Config .OkokNotify then
110
- exports [' okokNotify' ]:Alert (Translation [Config .Locale ][' notification_header' ], Translation [Config .Locale ][' okok_engine_start' ], 5000 , ' info' )
111
- else
112
- TriggerEvent (' esx:showNotification' , Translation [Config .Locale ][' engine_start' ])
113
- end
89
+ Config .Notification (source , ' client' , nil , Translation [Config .Locale ][' engine_start' ])
114
90
else
115
- if Config .Notifications then
116
- TriggerEvent (' notifications' , " #FF0000" , Translation [Config .Locale ][' notification_header' ], Translation [Config .Locale ][' n_engine_stop' ])
117
- elseif Config .OkokNotify then
118
- exports [' okokNotify' ]:Alert (Translation [Config .Locale ][' notification_header' ], Translation [Config .Locale ][' okok_engine_stop' ], 5000 , ' info' )
119
- else
120
- TriggerEvent (' esx:showNotification' , Translation [Config .Locale ][' engine_stop' ])
121
- end
91
+ Config .Notification (source , ' client' , nil , Translation [Config .Locale ][' engine_stop' ])
122
92
end
123
93
end
124
94
end
@@ -139,13 +109,7 @@ if Config.OnAtEnter then
139
109
if vehicle [1 ] == GetVehiclePedIsTryingToEnter (PlayerPedId ()) and not vehicle [2 ] then
140
110
Citizen .Wait (0 )
141
111
vehicle [2 ] = true
142
- if Config .Notifications then
143
- TriggerEvent (' notifications' , " #00EE00" , Translation [Config .Locale ][' notification_header' ], Translation [Config .Locale ][' n_engine_onatenter' ])
144
- elseif Config .OkokNotify then
145
- exports [' okokNotify' ]:Alert (Translation [Config .Locale ][' notification_header' ], Translation [Config .Locale ][' okok_engine_onatenter' ], 5000 , ' warning' )
146
- else
147
- TriggerEvent (' esx:showNotification' , Translation [Config .Locale ][' engine_onatenter' ])
148
- end
112
+ Config .Notification (source , ' client' , nil , Translation [Config .Locale ][' engine_onatenter' ])
149
113
end
150
114
end
151
115
end
@@ -200,7 +164,7 @@ AddEventHandler('EngineToggle:hotwire', function()
200
164
201
165
Citizen .CreateThread (function ()
202
166
if Config .ProgessBar .enable then
203
- exports [ ' pogressBar ' ]: drawBar (animTime , Translation [Config .Locale ][' hotwiring' ])
167
+ Config . progressBar (animTime , Translation [Config .Locale ][' hotwiring' ])
204
168
end
205
169
Citizen .Wait (animTime )
206
170
@@ -209,26 +173,13 @@ AddEventHandler('EngineToggle:hotwire', function()
209
173
SetVehicleDoorsLockedForAllPlayers (vehicle , false )
210
174
FreezeEntityPosition (playerPed , false )
211
175
ClearPedTasksImmediately (playerPed )
212
-
213
- if Config .Notifications then
214
- TriggerEvent (' notifications' , " #FF0000" , Translation [Config .Locale ][' header' ], Translation [Config .Locale ][' vehicle_unlocked' ])
215
- elseif Config .OkokNotify then
216
- exports [' okokNotify' ]:Alert (Translation [Config .Locale ][' header' ], Translation [Config .Locale ][' vehicle_unlocked' ], 5000 , ' info' )
217
- else
218
- TriggerEvent (' esx:showNotification' , Translation [Config .Locale ][' vehicle_unlocked' ])
219
- end
176
+ Config .Notification (source , ' client' , nil , Translation [Config .Locale ][' vehicle_unlocked' ])
220
177
else
221
178
TriggerServerEvent (' EngineToggle:delhotwire' )
222
179
FreezeEntityPosition (playerPed , false )
223
180
ClearPedTasksImmediately (playerPed )
224
-
225
- if Config .Notifications then
226
- TriggerEvent (' notifications' , " #FF0000" , Translation [Config .Locale ][' header' ], Translation [Config .Locale ][' hotwiring_failed' ])
227
- elseif Config .OkokNotify then
228
- exports [' okokNotify' ]:Alert (Translation [Config .Locale ][' header' ], Translation [Config .Locale ][' hotwiring_failed' ], 5000 , ' info' )
229
- else
230
- TriggerEvent (' esx:showNotification' , Translation [Config .Locale ][' hotwiring_failed' ])
231
- end
181
+ Config .Notification (source , ' client' , nil , Translation [Config .Locale ][' hotwiring_failed' ])
182
+ return
232
183
end
233
184
234
185
Citizen .Wait (500 )
@@ -246,21 +197,15 @@ AddEventHandler('EngineToggle:hotwire', function()
246
197
return
247
198
end
248
199
249
- if Config .VehicleKeyChain then
200
+ if Config .VehicleKeyChain and ( GetResourceState ( " VehicleKeyChain " ) == " started " ) then
250
201
local vehicle2 = GetVehiclePedIsIn (playerPed , false )
251
202
local plate = GetVehicleNumberPlateText (vehicle2 )
252
203
253
204
if Config .Probability .enableSearchKey then
254
205
if chance <= Config .Probability .searchKey then
255
206
TriggerServerEvent (' EngineToggle:addcarkeys' , plate )
256
207
else
257
- if Config .Notifications then
258
- TriggerEvent (' notifications' , " #FF0000" , Translation [Config .Locale ][' header' ], Translation [Config .Locale ][' hotwiring_notfoundkey' ])
259
- elseif Config .OkokNotify then
260
- exports [' okokNotify' ]:Alert (Translation [Config .Locale ][' header' ], Translation [Config .Locale ][' hotwiring_notfoundkey' ], 5000 , ' info' )
261
- else
262
- TriggerEvent (' esx:showNotification' , Translation [Config .Locale ][' hotwiring_notfoundkey' ])
263
- end
208
+ Config .Notification (source , ' client' , nil , Translation [Config .Locale ][' hotwiring_notfoundkey' ])
264
209
end
265
210
else
266
211
TriggerServerEvent (' EngineToggle:addcarkeys' , plate )
0 commit comments