Skip to content

Commit 299eb7e

Browse files
committed
Update v3.4
* Changed a lot of things
1 parent 7a11431 commit 299eb7e

File tree

7 files changed

+49
-127
lines changed

7 files changed

+49
-127
lines changed

README.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Config = {}
1919
----------------------------------------------------------------
2020
Config.Locale = 'de'
2121
Config.VersionChecker = true
22+
Config.getSharedObject = 'esx:getSharedObject'
2223
----------------------------------------------------------------
2324
-- Change 'false' to 'true' to toggle the engine automatically on when entering a vehicle
2425
Config.OnAtEnter = false
@@ -28,13 +29,23 @@ Config.UseKey = true -- Set true if you want to use a Hotkey
2829
Config.UseCommand = false -- Set true if you want to use a Command
2930
Config.Commad = 'engine'
3031
----------------------------------------------------------------
31-
-- If both false then Default ESX Notification is active!
32-
Config.Notifications = false -- https://forum.cfx.re/t/release-standalone-notification-script/1464244
33-
Config.OkokNotify = true -- https://forum.cfx.re/t/okoknotify-standalone-paid/3907758
34-
----------------------------------------------------------------
3532
-- Vehicle Key System - set true then only the Owner of the Vehicle or someone with a Key can start the Engine
3633
Config.VehicleKeyChain = false -- https://kiminazes-script-gems.tebex.io/package/4524211
3734
----------------------------------------------------------------
35+
-- !!! This function is clientside AND serverside !!!
36+
-- Look for type == 'client' and type == 'server'
37+
Config.Notification = function(src, type, xPlayer, message) -- xPlayer = ESX.GetPlayerFromId(src)
38+
if type == 'client' then -- clientside
39+
ESX.ShowNotification(message) -- replace this with your Notify // example: exports['okokNotify']:Alert('Crafting', message, 5000, 'info')
40+
elseif type == 'server' then -- serverside
41+
xPlayer.showNotification(message) -- replace this with your Notify // example: TriggerClientEvent('okokNotify:Alert', src, 'Crafting', message, 5000, 'info')
42+
end
43+
end
44+
----------------------------------------------------------------
45+
Config.progressBar = function(time, message)
46+
exports['pogressBar']:drawBar(time, message)
47+
end
48+
----------------------------------------------------------------
3849
Config.RemoveLockpickItem = true -- Set true if you like to remove item after failing lockpicking
3950
Config.LockpickItem = 'lockpick' -- Set the itemname what you want to use
4051
Config.startEngine = true -- Set true if you want to start the engine after successfull lockpicking

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.3
1+
3.4

client.lua

Lines changed: 14 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ESX = nil
22
Citizen.CreateThread(function()
33
while ESX == nil do
4-
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
4+
TriggerEvent(Config.getSharedObject, function(obj) ESX = obj end)
55
Citizen.Wait(0)
66
end
77
end)
@@ -66,59 +66,29 @@ AddEventHandler('EngineToggle:Engine', function()
6666
netTime = netTime -1
6767
end
6868

69-
if Config.VehicleKeyChain then
69+
if Config.VehicleKeyChain and (GetResourceState("VehicleKeyChain") == "started") then
7070
local isVehicleOrKeyOwner = exports["VehicleKeyChain"]:IsVehicleOrKeyOwner(veh)
7171

7272
if IsPedInAnyVehicle(PlayerPedId(), false) and isVehicleOrKeyOwner then
7373
if (GetPedInVehicleSeat(veh, -1) == PlayerPedId()) then
7474
vehicles[StateIndex][2] = not GetIsVehicleEngineRunning(veh)
7575
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'])
8377
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'])
9179
end
9280
end
9381
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'])
10183
end
10284
else
10385
if IsPedInAnyVehicle(PlayerPedId(), false) then
10486
if (GetPedInVehicleSeat(veh, -1) == PlayerPedId()) then
10587
vehicles[StateIndex][2] = not GetIsVehicleEngineRunning(veh)
10688
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'])
11490
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'])
12292
end
12393
end
12494
end
@@ -139,13 +109,7 @@ if Config.OnAtEnter then
139109
if vehicle[1] == GetVehiclePedIsTryingToEnter(PlayerPedId()) and not vehicle[2] then
140110
Citizen.Wait(0)
141111
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'])
149113
end
150114
end
151115
end
@@ -200,7 +164,7 @@ AddEventHandler('EngineToggle:hotwire', function()
200164

201165
Citizen.CreateThread(function()
202166
if Config.ProgessBar.enable then
203-
exports['pogressBar']:drawBar(animTime, Translation[Config.Locale]['hotwiring'])
167+
Config.progressBar(animTime, Translation[Config.Locale]['hotwiring'])
204168
end
205169
Citizen.Wait(animTime)
206170

@@ -209,26 +173,13 @@ AddEventHandler('EngineToggle:hotwire', function()
209173
SetVehicleDoorsLockedForAllPlayers(vehicle, false)
210174
FreezeEntityPosition(playerPed, false)
211175
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'])
220177
else
221178
TriggerServerEvent('EngineToggle:delhotwire')
222179
FreezeEntityPosition(playerPed, false)
223180
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
232183
end
233184

234185
Citizen.Wait(500)
@@ -246,21 +197,15 @@ AddEventHandler('EngineToggle:hotwire', function()
246197
return
247198
end
248199

249-
if Config.VehicleKeyChain then
200+
if Config.VehicleKeyChain and (GetResourceState("VehicleKeyChain") == "started") then
250201
local vehicle2 = GetVehiclePedIsIn(playerPed, false)
251202
local plate = GetVehicleNumberPlateText(vehicle2)
252203

253204
if Config.Probability.enableSearchKey then
254205
if chance <= Config.Probability.searchKey then
255206
TriggerServerEvent('EngineToggle:addcarkeys', plate)
256207
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'])
264209
end
265210
else
266211
TriggerServerEvent('EngineToggle:addcarkeys', plate)

config.lua

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Config = {}
22
----------------------------------------------------------------
33
Config.Locale = 'de'
44
Config.VersionChecker = true
5+
Config.getSharedObject = 'esx:getSharedObject'
56
----------------------------------------------------------------
67
-- Change 'false' to 'true' to toggle the engine automatically on when entering a vehicle
78
Config.OnAtEnter = false
@@ -11,13 +12,23 @@ Config.UseKey = true -- Set true if you want to use a Hotkey
1112
Config.UseCommand = false -- Set true if you want to use a Command
1213
Config.Commad = 'engine'
1314
----------------------------------------------------------------
14-
-- If both false then Default ESX Notification is active!
15-
Config.Notifications = false -- https://forum.cfx.re/t/release-standalone-notification-script/1464244
16-
Config.OkokNotify = true -- https://forum.cfx.re/t/okoknotify-standalone-paid/3907758
17-
----------------------------------------------------------------
1815
-- Vehicle Key System - set true then only the Owner of the Vehicle or someone with a Key can start the Engine
1916
Config.VehicleKeyChain = false -- https://kiminazes-script-gems.tebex.io/package/4524211
2017
----------------------------------------------------------------
18+
-- !!! This function is clientside AND serverside !!!
19+
-- Look for type == 'client' and type == 'server'
20+
Config.Notification = function(src, type, xPlayer, message) -- xPlayer = ESX.GetPlayerFromId(src)
21+
if type == 'client' then -- clientside
22+
ESX.ShowNotification(message) -- replace this with your Notify // example: exports['okokNotify']:Alert('Crafting', message, 5000, 'info')
23+
elseif type == 'server' then -- serverside
24+
xPlayer.showNotification(message) -- replace this with your Notify // example: TriggerClientEvent('okokNotify:Alert', src, 'Crafting', message, 5000, 'info')
25+
end
26+
end
27+
----------------------------------------------------------------
28+
Config.progressBar = function(time, message)
29+
exports['pogressBar']:drawBar(time, message)
30+
end
31+
----------------------------------------------------------------
2132
Config.RemoveLockpickItem = true -- Set true if you like to remove item after failing lockpicking
2233
Config.LockpickItem = 'lockpick' -- Set the itemname what you want to use
2334
Config.startEngine = true -- Set true if you want to start the engine after successfull lockpicking

fxmanifest.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ games { 'gta5' }
44
author 'Musiker15 - MSK Scripts'
55
name 'msk_enginetoggle'
66
description 'EngineToggle for Vehicles'
7-
version '3.3'
7+
version '3.4'
88

99
lua54 'yes'
1010

server.lua

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
local ESX = nil
2-
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
2+
TriggerEvent(Config.getSharedObject, function(obj) ESX = obj end)
33

44
if Config.UseCommand then
55
RegisterCommand(Config.Commad, function(source)
@@ -30,27 +30,14 @@ AddEventHandler('EngineToggle:hasItem', function()
3030
if hasItem > 0 then
3131
TriggerClientEvent('EngineToggle:hotwire', source)
3232
else
33-
if Config.Notifications then
34-
TriggerClientEvent('notifications', source, "#FF0000", Translation[Config.Locale]['header'], Translation[Config.Locale]['hasno_lockpick'])
35-
elseif Config.OkokNotify then
36-
TriggerClientEvent('okokNotify:Alert', source, Translation[Config.Locale]['header'], Translation[Config.Locale]['hasno_lockpick'], 5000, 'info')
37-
else
38-
TriggerEvent('esx:showNotification', source, Translation[Config.Locale]['hasno_lockpick'])
39-
end
33+
Config.Notification(source, 'server', xPlayer, Translation[Config.Locale]['hasno_lockpick'])
4034
end
4135
end)
4236

4337
RegisterNetEvent('EngineToggle:addcarkeys')
4438
AddEventHandler('EngineToggle:addcarkeys', function(plate)
4539
exports["VehicleKeyChain"]:AddTempKey(source, plate)
46-
47-
if Config.Notifications then
48-
TriggerEvent('notifications', source,"#FF0000", Translation[Config.Locale]['header'], Translation[Config.Locale]['hotwiring_foundkey'])
49-
elseif Config.OkokNotify then
50-
TriggerClientEvent('okokNotify:Alert', source, Translation[Config.Locale]['header'], Translation[Config.Locale]['hotwiring_foundkey'], 5000, 'info')
51-
else
52-
TriggerEvent('esx:showNotification', source, Translation[Config.Locale]['hotwiring_foundkey'])
53-
end
40+
Config.Notification(source, 'server', xPlayer, Translation[Config.Locale]['hotwiring_foundkey'])
5441
end)
5542

5643
---- Github Updater ----

translation.lua

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,63 +2,31 @@ Translation = {}
22
----------------------------------------------------------------
33
Translation = {
44
['de'] = {
5-
['notification_header'] = 'Dein Fahrzeug',
6-
['n_engine_start'] = 'Der Motor wurde gestartet',
7-
['n_engine_stop'] = 'Der Motor wurde gestoppt',
8-
['okok_engine_start'] = "Der Motor wurde <span style='color:#47cf73'>gestartet</span>",
9-
['okok_engine_stop'] = "Der Motor wurde <span style='color:#FF0000'>ausgeschalten</span>",
105
['engine_start'] = 'Der Motor wurde ~g~gestartet',
116
['engine_stop'] = 'Der Motor wurde ~r~gestoppt',
12-
13-
['n_key_nokey'] = 'Du besitzt keinen Schlüssel für dieses Fahrzeug',
14-
['okok_key_nokey'] = "Du besitzt keinen <span style='color:#FF0000'>Schlüssel</span> für dieses Fahrzeug",
157
['key_nokey'] = 'Du besitzt ~r~keinen~s~ Schlüssel für dieses Fahrzeug',
16-
17-
['n_engine_onatenter'] = 'Der Motor läuft bereits',
18-
['okok_engine_onatenter'] = 'Der Motor läuft bereits',
198
['engine_onatenter'] = 'Der Motor läuft bereits',
20-
21-
['header'] = 'Fremdes Fahrzeug',
229
['hasno_lockpick'] = 'Du hast keinen Dietrich dabei',
2310
['hotwiring'] = 'Fahrzeug wird geknackt...',
2411
['vehicle_unlocked'] = 'Fahrzeug geknackt',
2512
['hotwiring_failed'] = 'Dietrich ist abgebrochen',
2613
['hotwire_activesearchkey'] = 'Du suchst nach dem Fahrzeugschlüssel...',
2714
['hotwiring_foundkey'] = 'Fahrzeugschlüssel gefunden',
2815
['hotwiring_notfoundkey'] = 'Fahrzeugschlüssel nicht gefunden',
29-
30-
['n_hotwire_searchkey'] = "Drücke <span style='color:#47cf73'>E</span> um den Fahrzeugschlüssel zu suchen",
31-
['okok_hotwire_searchkey'] = "Drücke <span style='color:#47cf73'>E</span> um den Fahrzeugschlüssel zu suchen",
3216
['hotwire_searchkey'] = 'Drücke ~r~E~s~ um den Fahrzeugschlüssel zu suchen',
3317
},
3418
['en'] = {
35-
['notification_header'] = 'Personal Vehicle',
36-
['n_engine_start'] = 'The Engine started',
37-
['n_engine_stop'] = 'The Engine stopped',
38-
['okok_engine_start'] = 'The Engine <span style="color:#47cf73">started</span>',
39-
['okok_engine_stop'] = 'The Engine <span style="color:#FF0000">stopped</span>',
4019
['engine_start'] = 'The Engine ~g~started',
4120
['engine_stop'] = 'The Engine ~r~stopped',
42-
43-
['n_key_nokey'] = 'You do not have a Key for this Vehicle',
44-
['okok_key_nokey'] = 'You do not have a <span style="color:#FF0000">Key</span> for this Vehicle',
4521
['key_nokey'] = 'You do ~r~not~s~ have a Key for this Vehicle',
46-
47-
['n_engine_onatenter'] = 'The Engine is running',
48-
['okok_engine_onatenter'] = 'The Engine is running',
4922
['engine_onatenter'] = 'The Engine is running',
50-
51-
['header'] = 'Fremdes Fahrzeug',
5223
['hasno_lockpick'] = 'Du hast keinen Dietrich dabei',
5324
['hotwiring'] = 'Fahrzeug wird geknackt...',
5425
['vehicle_unlocked'] = 'Fahrzeug geknackt',
5526
['hotwiring_failed'] = 'Dietrich ist abgebrochen',
5627
['hotwire_activesearchkey'] = 'Du suchst nach dem Fahrzeugschlüssel...',
5728
['hotwiring_foundkey'] = 'Fahrzeugschlüssel gefunden',
5829
['hotwiring_notfoundkey'] = 'Fahrzeugschlüssel nicht gefunden',
59-
60-
['n_hotwire_searchkey'] = "Drücke <span style='color:#47cf73'>E</span> um den Fahrzeugschlüssel zu suchen",
61-
['okok_hotwire_searchkey'] = "Drücke <span style='color:#47cf73'>E</span> um den Fahrzeugschlüssel zu suchen",
6230
['hotwire_searchkey'] = 'Drücke ~r~E~s~ um den Fahrzeugschlüssel zu suchen',
6331
},
6432
}

0 commit comments

Comments
 (0)