Skip to content

Commit 254b9ae

Browse files
committed
Update v4.2.4
1 parent b4bbaa4 commit 254b9ae

File tree

7 files changed

+66
-61
lines changed

7 files changed

+66
-61
lines changed

client/hotwire.lua

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,12 @@ toggleLockpick = function()
4141
end
4242

4343
if alarmStage.liveCoords and owner then
44-
TriggerServerEvent('msk_enginetoggle:liveCoords', owner, NetworkGetNetworkIdFromEntity(vehicle), GetEntityCoords(vehicle))
44+
TriggerServerEvent('msk_enginetoggle:liveCoords', owner, VehToNet(vehicle), GetEntityCoords(vehicle))
4545
end
4646

47+
local debug = false
48+
if not debug then return end
49+
4750
MSK.LoadAnimDict(animation.dict)
4851
TaskPlayAnim(playerPed, animation.dict, animation.anim, 8.0, 1.0, -1, 49, 0, false, false, false)
4952
FreezeEntityPosition(playerPed, true)
@@ -226,7 +229,9 @@ end)
226229
inOneSync = function(netId)
227230
local vehicle = NetworkDoesNetworkIdExist(netId) and NetworkGetEntityFromNetworkId(netId)
228231

229-
if DoesEntityExist(vehicle) then return {vehicle = vehicle} end
232+
if DoesEntityExist(vehicle) then
233+
return {vehicle = vehicle}
234+
end
230235
return false
231236
end
232237

@@ -239,51 +244,46 @@ deleteVehicleBlip = function(netId)
239244
end
240245
RegisterNetEvent('msk_enginetoggle:deleteVehicleBlip', deleteVehicleBlip)
241246

242-
showVehicleBlip = function(netId, coords)
243-
local OneSync = inOneSync(netId)
247+
addVehicleBlip = function(netId, coords)
248+
local blip = AddBlipForCoord(coords.x, coords.y, coords.z)
244249

245-
if not activeBlips[netId] then
246-
local blip = AddBlipForCoord(coords.x, coords.y, coords.z)
250+
SetBlipSprite(blip, 326)
251+
SetBlipDisplay(blip, 2)
252+
SetBlipColour(blip, 1)
253+
SetBlipScale(blip, 1.0)
254+
SetBlipFlashes(blip, true)
255+
SetBlipAsShortRange(blip, false)
247256

248-
SetBlipSprite(blip, 326)
249-
SetBlipDisplay(blip, 2)
250-
SetBlipColour(blip, 1)
251-
SetBlipScale(blip, 1.0)
252-
SetBlipFlashes(blip, true)
253-
SetBlipAsShortRange(blip, false)
257+
BeginTextCommandSetBlipName('STRING')
258+
AddTextComponentString(Translation[Config.Locale]['blip_stolen_vehicle'])
259+
EndTextCommandSetBlipName(blip)
254260

255-
BeginTextCommandSetBlipName('STRING')
256-
AddTextComponentString(Translation[Config.Locale]['blip_stolen_vehicle'])
257-
EndTextCommandSetBlipName(blip)
261+
activeBlips[netId] = {isActive = false, blip = blip}
262+
end
258263

259-
activeBlips[netId] = {
260-
isActive = false,
261-
blip = blip
262-
}
263-
end
264+
showVehicleBlip = function(netId, coords)
265+
if not activeBlips[netId] then addVehicleBlip(netId, coords) end
266+
local OneSync = inOneSync(netId)
264267

265-
if not OneSync and activeBlips[netId] then
266-
activeBlips[netId].isActive = false
267-
ShowHeadingIndicatorOnBlip(activeBlips[netId].blip, false)
268-
SetBlipCoords(activeBlips[netId].blip, coords.x, coords.y, coords.z)
269-
elseif OneSync and activeBlips[netId] and not activeBlips[netId].isActive then
268+
if OneSync and activeBlips[netId] and not activeBlips[netId].isActive then
270269
CreateThread(function()
271270
activeBlips[netId].isActive = true
272271

273-
while activeBlips[netId] and activeBlips[netId].isActive do
274-
if DoesEntityExist(OneSync.vehicle) then
275-
local vehicleCoords = GetEntityCoords(OneSync.vehicle)
276-
local heading = math.ceil(GetEntityHeading(OneSync.vehicle))
277-
278-
SetBlipCoords(activeBlips[netId].blip, vehicleCoords.x, vehicleCoords.y, vehicleCoords.z)
279-
ShowHeadingIndicatorOnBlip(activeBlips[netId].blip, true)
280-
SetBlipRotation(activeBlips[netId].blip, heading)
281-
else
282-
deleteVehicleBlip(netId)
283-
break
284-
end
272+
while activeBlips[netId] and activeBlips[netId].isActive and DoesEntityExist(OneSync.vehicle) do
273+
local vehicleCoords = GetEntityCoords(OneSync.vehicle)
274+
local heading = math.ceil(GetEntityHeading(OneSync.vehicle))
275+
276+
SetBlipCoords(activeBlips[netId].blip, vehicleCoords.x, vehicleCoords.y, vehicleCoords.z)
277+
ShowHeadingIndicatorOnBlip(activeBlips[netId].blip, true)
278+
SetBlipRotation(activeBlips[netId].blip, heading)
279+
280+
Wait(0)
285281
end
286282
end)
283+
elseif not OneSync and activeBlips[netId] then
284+
activeBlips[netId].isActive = false
285+
SetBlipCoords(activeBlips[netId].blip, coords.x, coords.y, coords.z)
286+
ShowHeadingIndicatorOnBlip(activeBlips[netId].blip, false)
287287
end
288288

289289
SetTimeout(2500, function()

client/vehiclekeys.lua

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,14 @@ getIsKeyOwner = function(vehicle)
4747
if not Config.VehicleKeys.enable then return true end
4848
local isKeyOwner, ignoreVehicle, ignorePlate = false, false, false
4949
local plate = GetVehicleNumberPlateText(vehicle)
50-
local canToggleEngine = true
5150

5251
if not Config.VehicleKeys.uniqueItems then
5352
if Config.VehicleKeys.script == 'msk_vehiclekeys' and (GetResourceState("msk_vehiclekeys") == "started") then
5453
isKeyOwner = exports["msk_vehiclekeys"]:HasPlayerKeyOrIsVehicleOwner(vehicle)
5554
elseif Config.VehicleKeys.script == 'VehicleKeyChain' and (GetResourceState("VehicleKeyChain") == "started") then
5655
isKeyOwner = exports["VehicleKeyChain"]:IsVehicleOrKeyOwner(vehicle)
57-
elseif Config.VehicleKeys.script == 'vehicle_keys' and (GetResourceState("vehicle_keys") == "started") then
58-
isKeyOwner = exports["vehicle_keys"]:doesPlayerOwnPlate(plate)
56+
elseif Config.VehicleKeys.script == 'vehicles_keys' and (GetResourceState("vehicles_keys") == "started") then
57+
isKeyOwner = exports["vehicles_keys"]:doesPlayerOwnPlate(plate)
5958
elseif Config.VehicleKeys.script == 'wasabi_carlock' and (GetResourceState("wasabi_carlock") == "started") then
6059
isKeyOwner = exports.wasabi_carlock:HasKey(plate)
6160
elseif Config.VehicleKeys.script == 'qs-vehiclekeys' and (GetResourceState("qs-vehiclekeys") == "started") then
@@ -81,10 +80,6 @@ getIsKeyOwner = function(vehicle)
8180
end
8281
end
8382

84-
if not isKeyOwner and not ignoreVehicle and not ignorePlate then
85-
canToggleEngine = false
86-
end
87-
88-
return canToggleEngine
83+
return isKeyOwner or ignoreVehicle or ignorePlate
8984
end
9085
exports('getIsKeyOwner', getIsKeyOwner)

config.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ Config.EngineFromSecondSeat = false
4242
-- Vehicle Key System - set true then only the Owner of the Vehicle or someone with a Key can start the Engine
4343

4444
-- msk_vehiclekeys: https://forum.cfx.re/t/esx-qbcore-msk-vehiclekeys-unique-items/5264475
45-
-- vehicle_keys: https://forum.cfx.re/t/esx-qbcore-vehicles-keys-vehicles-lock-remote-control-ui-and-much-more/4857274
45+
-- vehicles_keys: https://forum.cfx.re/t/esx-qbcore-vehicles-keys-vehicles-lock-remote-control-ui-and-much-more/4857274
4646
-- VehicleKeyChain: https://forum.cfx.re/t/release-vehicle-key-chain-v4-1-4-esx-qb/3319563
4747

4848
Config.VehicleKeys = {
4949
enable = true, -- Set true to enable this feature
5050

51-
-- Supported Scripts: 'msk_vehiclekeys', 'VehicleKeyChain', 'vehicle_keys', 'okokGarage', 'wasabi_carlock', 'qs-vehiclekeys'
51+
-- Supported Scripts: 'msk_vehiclekeys', 'VehicleKeyChain', 'vehicles_keys', 'okokGarage', 'wasabi_carlock', 'qs-vehiclekeys'
5252
script = 'msk_vehiclekeys',
5353

5454
-- This is for inventories with metadata like ox_inventory

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 '4.2.3'
7+
version '4.2.4'
88

99
lua54 'yes'
1010

server/hotwire.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,10 @@ RegisterNetEvent('msk_enginetoggle:policeAlert', function(coords)
156156
end)
157157

158158
RegisterNetEvent('msk_enginetoggle:liveCoords', function(owner, netId, coords)
159-
local playerId = nil
160159
local Player = GetPlayerFromIdentifier(owner)
161160
if not Player then return end
162-
161+
local playerId = nil
162+
163163
if Config.Framework == 'ESX' then
164164
playerId = Player.source
165165
elseif Config.Framework == 'QBCore' then

server/main.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ RegisterNetEvent('msk_enginetoggle:enteredVehicle', function(plate, seat, netId,
103103
local src = source
104104
local Player = GetPlayerFromId(src)
105105
local identifier = nil
106-
plate = MSK.Trim(plate, true)
107106

108107
if Config.Framework == 'ESX' then
109108
identifier = Player.identifier
@@ -115,7 +114,7 @@ RegisterNetEvent('msk_enginetoggle:enteredVehicle', function(plate, seat, netId,
115114

116115
local result = MySQL.query.await(('SELECT * FROM %s WHERE %s = @owner AND plate = @plate'):format(VEHICLE_TABLE_NAME, OWNER_COLUMN_NAME), {
117116
['@owner'] = identifier,
118-
['@plate'] = plate
117+
['@plate'] = MSK.Trim(plate, true)
119118
})
120119

121120
if result and result[1] then

server/versionchecker.lua

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
local AUTHOR = "Musiker15"
2-
local NAME = "msk_enginetoggle"
2+
local NAME = "VERSIONS"
3+
local FILE = "EngineToggle.json"
34

45
local RESOURCE_NAME = "msk_enginetoggle"
56
local NAME_COLORED = "[^2"..GetCurrentResourceName().."^0]"
6-
local GITHUB_URL = "https://api.github.com/repos/%s/%s/releases/latest"
7-
local DOWNLOAD_URL = "https://github.com/%s/%s/releases/tag/v%s"
7+
local GITHUB_URL = "https://raw.githubusercontent.com/%s/%s/main/%s"
8+
local DOWNLOAD_URL = "https://github.com/MSK-Scripts/%s/releases/tag/v%s"
89

910
local RENAME_WARNING = NAME_COLORED .. "^3 [WARNING] This resource should not be renamed! This can lead to errors. Please rename it to^0 %s"
10-
local CHECK_FAILED = NAME_COLORED .. "^1 [ERROR] Version Check failed! Http Error: %s ^3Please update to the latest version.^0"
11+
local CHECK_FAILED = NAME_COLORED .. "^1 [ERROR] Version Check failed! Http Error: %s^0 - ^3Please update to the latest version.^0"
1112
local BETA_VERSION = NAME_COLORED .. "^3 [WARNING] Beta version detected^0 - ^5Current Version:^0 %s - ^5Latest Version:^0 %s"
1213
local UP_TO_DATE = NAME_COLORED .. "^2 ✓ Resource is Up to Date^0 - ^5Current Version:^2 %s ^0"
1314
local NEW_VERSION = NAME_COLORED .. "^3 [Update Available] ^5Current Version:^0 %s - ^5Latest Version:^0 %s\n" .. NAME_COLORED .. "^5 Download:^4 %s ^0"
@@ -47,14 +48,14 @@ local PrintKeyScripts = function()
4748
end
4849
end
4950

50-
local CheckVersionCallback = function(status, response, header)
51+
local CheckVersionCallback = function(status, response, headers)
5152
if status ~= 200 then
5253
print(CHECK_FAILED:format(status))
5354
return
5455
end
5556

56-
local latestRelease = json.decode(response)
57-
local latestVersion = latestRelease.tag_name:gsub('v', '')
57+
local response = json.decode(response)
58+
local latestVersion = response[1].version
5859
local currentVersion = GetResourceMetadata(GetCurrentResourceName(), "version")
5960

6061
if currentVersion == latestVersion then
@@ -76,8 +77,18 @@ local CheckVersionCallback = function(status, response, header)
7677
end
7778

7879
if current[i] < latest[i] then
79-
print(NEW_VERSION:format(currentVersion, latestVersion, DOWNLOAD_URL:format(AUTHOR, NAME, latestVersion)))
80+
print(NEW_VERSION:format(currentVersion, latestVersion, DOWNLOAD_URL:format(RESOURCE_NAME, latestVersion)))
8081
PrintKeyScripts()
82+
83+
for i = 1, #response do
84+
if response[i].version == currentVersion then break end
85+
print(("%s ^3[Changelogs v%s]^0"):format(NAME_COLORED, response[i].version))
86+
87+
for k = 1, #response[i].changelogs do
88+
print(response[i].changelogs[k])
89+
end
90+
end
91+
8192
break
8293
end
8394
end
@@ -86,7 +97,7 @@ end
8697
VersionChecker = function()
8798
CreateThread(function()
8899
CheckResourceName()
89-
PerformHttpRequest(GITHUB_URL:format(AUTHOR, NAME), CheckVersionCallback)
100+
PerformHttpRequest(GITHUB_URL:format(AUTHOR, NAME, FILE), CheckVersionCallback)
90101
end)
91102
end
92103
VersionChecker()

0 commit comments

Comments
 (0)