Skip to content

Commit 01c2c5d

Browse files
committed
Update v3.1
* Added Hotwire Function in compatibility with VehicleKeyChain
1 parent 11a4596 commit 01c2c5d

File tree

8 files changed

+314
-46
lines changed

8 files changed

+314
-46
lines changed

README.md

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,64 @@ FiveM Script - Vehicle Engine Toggle On/Off
1515
## Config
1616
```
1717
Config = {}
18-
Config.Locale = 'en'
19-
18+
----------------------------------------------------------------
19+
Config.Locale = 'de'
20+
Config.VersionChecker = true
21+
----------------------------------------------------------------
2022
-- Change 'false' to 'true' to toggle the engine automatically on when entering a vehicle
2123
Config.OnAtEnter = false
22-
23-
Config.UseKey = true
24+
----------------------------------------------------------------
25+
Config.UseKey = true -- Set true if you want to use a Hotkey
2426
Config.ToggleKey = 244 -- M (https://docs.fivem.net/docs/game-references/controls/)
25-
Config.UseCommand = true
26-
Config.Commad = 'engine' -- If Config.UseKey = false then you can use the command instead
27-
27+
Config.UseCommand = false -- Set true if you want to use a Command
28+
Config.Commad = 'engine'
29+
----------------------------------------------------------------
2830
-- If both false then Default ESX Notification is active!
2931
Config.Notifications = false -- https://forum.cfx.re/t/release-standalone-notification-script/1464244
30-
Config.OkokNotify = false -- https://okok.tebex.io/package/4724993
31-
32+
Config.OkokNotify = true -- https://forum.cfx.re/t/okoknotify-standalone-paid/3907758
33+
----------------------------------------------------------------
3234
-- Vehicle Key System - set true then only the Owner of the Vehicle or someone with a Key can start the Engine
3335
Config.VehicleKeyChain = false -- https://kiminazes-script-gems.tebex.io/package/4524211
36+
----------------------------------------------------------------
37+
Config.RemoveLockpickItem = true -- Set true if you like to remove item after failing lockpicking
38+
Config.LockpickItem = 'lockpick' -- Set the itemname what you want to use
39+
Config.Probability = {
40+
lockpick = 66, -- default: 66%
41+
alarm = 33, -- default: 33%
42+
searchKey = 66 -- default: 66%
43+
}
44+
Config.LockpickKey = {
45+
enable = false, -- Set to true if you want to use a Hotkey
46+
key = 38 -- default: E // Set the Hotkey
47+
}
48+
Config.ProgessBar = {
49+
enable = true, -- Set true if you want to show a progressbar
50+
time = 8 -- In seconds // Time how long does it takes
51+
}
52+
Config.Animation = {
53+
InsideOutsideAnimation = true, -- Set to false if you want same Animation for inside and outside
54+
generalAnimation = 'WORLD_HUMAN_WELDING',
55+
56+
insideVehicle = { -- Animation inside Vehicle
57+
dict = 'anim@amb@clubhouse@tutorial@bkr_tut_ig3@',
58+
anim = 'machinic_loop_mechandplayer'
59+
},
60+
outsideVehicle = { -- Animation outside Vehicle
61+
dict = 'anim@amb@clubhouse@tutorial@bkr_tut_ig3@',
62+
anim = 'machinic_loop_mechandplayer'
63+
}
64+
}
3465
```
3566

3667
## Requirements
68+
* Standalone
3769
* ESX Framework **only** for `ESX.ShowNotification`
3870
### Optional
3971
* Notification (https://forum.cfx.re/t/release-standalone-notification-script/1464244)
4072
* okokNotify (https://forum.cfx.re/t/okoknotify-standalone-paid/3907758)
4173
* VehicleKeyChain (https://forum.cfx.re/t/release-vehicle-key-chain/3319563)
42-
* RealisticVehicleDamage (https://forum.cfx.re/t/release-realistic-vehicle-failure/57801)
74+
* ProgessBar (https://forum.cfx.re/t/release-pogress-bar-progress-bar-standalone-smooth-animation/838951)
75+
4376
#### VehicleKeyChain
4477
Make sure to add the following in every Script that spawns a Vehicle
4578
```lua
@@ -72,6 +105,4 @@ end
72105
```
73106

74107
## License
75-
**GNU General Public License v3.0**
76-
77-
You can use and edit this Script but please do not reupload this without tagging me
108+
**GNU General Public License v3.0**

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.1
1+
3.1

client.lua

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
ESX = nil
2+
Citizen.CreateThread(function()
3+
while ESX == nil do
4+
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
5+
Citizen.Wait(0)
6+
end
7+
end)
8+
19
local vehicles = {}; RPWorking = true
210

311
Citizen.CreateThread(function()
@@ -137,6 +145,119 @@ if Config.OnAtEnter then
137145
end)
138146
end
139147

148+
if Config.LockpickKey.enable then
149+
Citizen.CreateThread(function()
150+
while true do
151+
Citizen.Wait(0)
152+
if IsControlJustReleased(1, Config.LockpickKey.key) then
153+
TriggerServerEvent('EngineToggle:hasItem')
154+
end
155+
end
156+
end)
157+
end
158+
159+
RegisterNetEvent('EngineToggle:hotwire')
160+
AddEventHandler('EngineToggle:hotwire', function()
161+
local playerPed = PlayerPedId()
162+
local coords = GetEntityCoords(playerPed)
163+
local animTime = Config.ProgessBar.time * 1000
164+
165+
if IsAnyVehicleNearPoint(coords.x, coords.y, coords.z, 5.0) then
166+
local vehicle
167+
local animation
168+
local chance = math.random(100)
169+
local alarm = math.random(100)
170+
171+
if IsPedInAnyVehicle(playerPed, false) then
172+
vehicle = GetVehiclePedIsIn(playerPed, false)
173+
animation = {dict = Config.Animation.insideVehicle.dict, anim = Config.Animation.insideVehicle.anim}
174+
else
175+
vehicle = GetClosestVehicle(coords.x, coords.y, coords.z, 2.0, 0, 71)
176+
animation = {dict = Config.Animation.outsideVehicle.dict, anim = Config.Animation.outsideVehicle.anim}
177+
end
178+
179+
if DoesEntityExist(vehicle) then
180+
if alarm <= Config.Probability.alarm then
181+
SetVehicleAlarm(vehicle, true)
182+
StartVehicleAlarm(vehicle)
183+
end
184+
185+
if not Config.Animation.InsideOutsideAnimation then
186+
TaskStartScenarioInPlace(playerPed, Config.Animation.InsideOutsideAnimation, 0, true)
187+
FreezeEntityPosition(PlayerPedId(), true)
188+
elseif Config.Animation.InsideOutsideAnimation then
189+
loadAnimDict(animation.dict)
190+
TaskPlayAnim(playerPed, animation.dict, animation.anim, 8.0, 1.0, -1, 49, 0, false, false, false)
191+
FreezeEntityPosition(playerPed, true)
192+
end
193+
194+
Citizen.CreateThread(function()
195+
if Config.ProgessBar.enable then
196+
exports['pogressBar']:drawBar(animTime, _U('hotwiring'))
197+
end
198+
Citizen.Wait(animTime)
199+
200+
if chance <= Config.Probability.lockpick then
201+
SetVehicleDoorsLocked(vehicle, 1)
202+
SetVehicleDoorsLockedForAllPlayers(vehicle, false)
203+
FreezeEntityPosition(playerPed, false)
204+
ClearPedTasksImmediately(playerPed)
205+
206+
if Config.Notifications then
207+
TriggerEvent('notifications', "#FF0000", _U('header'), _U('vehicle_unlocked'))
208+
elseif Config.OkokNotify then
209+
exports['okokNotify']:Alert(_U('header'), _U('vehicle_unlocked'), 5000, 'info')
210+
else
211+
TriggerEvent('esx:showNotification', _U('vehicle_unlocked'))
212+
end
213+
else
214+
TriggerServerEvent('EngineToggle:delhotwire')
215+
FreezeEntityPosition(playerPed, false)
216+
ClearPedTasksImmediately(playerPed)
217+
218+
if Config.Notifications then
219+
TriggerEvent('notifications', "#FF0000", _U('header'), _U('hotwiring_failed'))
220+
elseif Config.OkokNotify then
221+
exports['okokNotify']:Alert(_U('header'), _U('hotwiring_failed'), 5000, 'info')
222+
else
223+
TriggerEvent('esx:showNotification', _U('hotwiring_failed'))
224+
end
225+
end
226+
227+
Citizen.Wait(500)
228+
229+
if GetVehicleDoorLockStatus(vehicle) == 1 then
230+
SetVehicleNeedsToBeHotwired(vehicle, true)
231+
else
232+
IsVehicleNeedsToBeHotwired(vehicle)
233+
end
234+
235+
TaskEnterVehicle(playerPed, vehicle, 10.0, -1, 1.0, 1, 0)
236+
Citizen.Wait(5000)
237+
238+
if Config.VehicleKeyChain then
239+
local vehicle2 = GetVehiclePedIsIn(playerPed, false)
240+
local plate = GetVehicleNumberPlateText(vehicle2)
241+
242+
if Config.Notifications then
243+
TriggerEvent('notifications', "#FF0000", _U('header'), _U('hotwiring_foundkey'))
244+
elseif Config.OkokNotify then
245+
exports['okokNotify']:Alert(_U('header'), _U('hotwiring_foundkey'), 5000, 'info')
246+
else
247+
TriggerEvent('esx:showNotification', _U('hotwiring_foundkey'))
248+
end
249+
250+
TriggerServerEvent('EngineToggle:addcarkeys', playerPed, plate)
251+
Citizen.Wait(200)
252+
TriggerEvent('EngineToggle:Engine')
253+
else
254+
TriggerEvent('EngineToggle:Engine')
255+
end
256+
end)
257+
end
258+
end
259+
end)
260+
140261
function table.contains(table, element)
141262
for _, value in pairs(table) do
142263
if value[1] == element then
@@ -145,3 +266,10 @@ function table.contains(table, element)
145266
end
146267
return false
147268
end
269+
270+
function loadAnimDict(dict)
271+
while (not HasAnimDictLoaded(dict)) do
272+
RequestAnimDict(dict)
273+
Citizen.Wait(5)
274+
end
275+
end

config.lua

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,48 @@
11
Config = {}
22
----------------------------------------------------------------
33
Config.Locale = 'de'
4+
Config.VersionChecker = true
45
----------------------------------------------------------------
56
-- Change 'false' to 'true' to toggle the engine automatically on when entering a vehicle
67
Config.OnAtEnter = false
78
----------------------------------------------------------------
8-
Config.UseKey = true
9+
Config.UseKey = true -- Set true if you want to use a Hotkey
910
Config.ToggleKey = 244 -- M (https://docs.fivem.net/docs/game-references/controls/)
10-
Config.UseCommand = false
11+
Config.UseCommand = false -- Set true if you want to use a Command
1112
Config.Commad = 'engine'
1213
----------------------------------------------------------------
1314
-- If both false then Default ESX Notification is active!
1415
Config.Notifications = false -- https://forum.cfx.re/t/release-standalone-notification-script/1464244
15-
Config.OkokNotify = false -- https://forum.cfx.re/t/okoknotify-standalone-paid/3907758
16+
Config.OkokNotify = true -- https://forum.cfx.re/t/okoknotify-standalone-paid/3907758
1617
----------------------------------------------------------------
1718
-- Vehicle Key System - set true then only the Owner of the Vehicle or someone with a Key can start the Engine
18-
Config.VehicleKeyChain = false -- https://kiminazes-script-gems.tebex.io/package/4524211
19+
Config.VehicleKeyChain = false -- https://kiminazes-script-gems.tebex.io/package/4524211
20+
----------------------------------------------------------------
21+
Config.RemoveLockpickItem = true -- Set true if you like to remove item after failing lockpicking
22+
Config.LockpickItem = 'lockpick' -- Set the itemname what you want to use
23+
Config.Probability = {
24+
lockpick = 66, -- default: 66%
25+
alarm = 33, -- default: 33%
26+
searchKey = 66 -- default: 66%
27+
}
28+
Config.LockpickKey = {
29+
enable = false, -- Set to true if you want to use a Hotkey
30+
key = 38 -- default: E // Set the Hotkey
31+
}
32+
Config.ProgessBar = {
33+
enable = true, -- Set true if you want to show a progressbar
34+
time = 8 -- In seconds // Time how long does it takes
35+
}
36+
Config.Animation = {
37+
InsideOutsideAnimation = true, -- Set to false if you want same Animation for inside and outside
38+
generalAnimation = 'WORLD_HUMAN_WELDING',
39+
40+
insideVehicle = { -- Animation inside Vehicle
41+
dict = 'anim@amb@clubhouse@tutorial@bkr_tut_ig3@',
42+
anim = 'machinic_loop_mechandplayer'
43+
},
44+
outsideVehicle = { -- Animation outside Vehicle
45+
dict = 'anim@amb@clubhouse@tutorial@bkr_tut_ig3@',
46+
anim = 'machinic_loop_mechandplayer'
47+
}
48+
}

fxmanifest.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ games { 'gta5' }
33

44
author 'Musiker15'
55
description 'ESX Better Engine Toggle'
6-
version '3.0.1'
6+
version '3.1'
77

8-
shared_scripts {
8+
shared_script {
99
'@es_extended/locale.lua',
1010
'locales/*.lua',
11-
'config.lua'
11+
'config.lua',
1212
}
1313

1414
client_scripts {
15-
'client.lua'
15+
'client.lua',
1616
}
1717

1818
server_scripts {
19-
'server.lua'
20-
}
19+
'server.lua',
20+
}

locales/de.lua

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Locales ['de'] = {
2+
----------------------------------------------------------------
23
['notification_header'] = 'Dein Fahrzeug',
34

45
['n_engine_start'] = 'Der Motor wurde gestartet',
@@ -15,4 +16,18 @@ Locales ['de'] = {
1516
['n_engine_onatenter'] = 'Der Motor läuft bereits',
1617
['okok_engine_onatenter'] = 'Der Motor läuft bereits',
1718
['engine_onatenter'] = 'Der Motor läuft bereits',
19+
----------------------------------------------------------------
20+
['header'] = 'Fremdes Fahrzeug',
21+
22+
['hasno_lockpick'] = 'Du hast keinen Dietrich dabei',
23+
['hotwiring'] = 'Fahrzeug wird geknackt...',
24+
['vehicle_unlocked'] = 'Fahrzeug geknackt',
25+
['hotwiring_failed'] = 'Dietrich ist abgebrochen',
26+
['hotwire_activesearchkey'] = 'Du suchst nach dem Fahrzeugschlüssel...',
27+
['hotwiring_foundkey'] = 'Fahrzeugschlüssel gefunden',
28+
['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",
32+
['hotwire_searchkey'] = 'Drücke ~r~E~s~ um den Fahrzeugschlüssel zu suchen',
1833
}

locales/en.lua

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Locales ['en'] = {
2-
['notification_header'] = 'Your Vehicle',
2+
----------------------------------------------------------------
3+
['notification_header'] = 'Personal Vehicle',
34

45
['n_engine_start'] = 'The Engine started',
56
['n_engine_stop'] = 'The Engine stopped',
@@ -15,4 +16,18 @@ Locales ['en'] = {
1516
['n_engine_onatenter'] = 'The Engine is running',
1617
['okok_engine_onatenter'] = 'The Engine is running',
1718
['engine_onatenter'] = 'The Engine is running',
19+
----------------------------------------------------------------
20+
['header'] = 'Fremdes Fahrzeug',
21+
22+
['hasno_lockpick'] = 'Du hast keinen Dietrich dabei',
23+
['hotwiring'] = 'Fahrzeug wird geknackt...',
24+
['vehicle_unlocked'] = 'Fahrzeug geknackt',
25+
['hotwiring_failed'] = 'Dietrich ist abgebrochen',
26+
['hotwire_activesearchkey'] = 'Du suchst nach dem Fahrzeugschlüssel...',
27+
['hotwiring_foundkey'] = 'Fahrzeugschlüssel gefunden',
28+
['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",
32+
['hotwire_searchkey'] = 'Drücke ~r~E~s~ um den Fahrzeugschlüssel zu suchen',
1833
}

0 commit comments

Comments
 (0)