Skip to content

Commit

Permalink
Update v4.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Musiker15 committed Sep 15, 2024
1 parent b4bbaa4 commit 254b9ae
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 61 deletions.
74 changes: 37 additions & 37 deletions client/hotwire.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ toggleLockpick = function()
end

if alarmStage.liveCoords and owner then
TriggerServerEvent('msk_enginetoggle:liveCoords', owner, NetworkGetNetworkIdFromEntity(vehicle), GetEntityCoords(vehicle))
TriggerServerEvent('msk_enginetoggle:liveCoords', owner, VehToNet(vehicle), GetEntityCoords(vehicle))
end

local debug = false
if not debug then return end

MSK.LoadAnimDict(animation.dict)
TaskPlayAnim(playerPed, animation.dict, animation.anim, 8.0, 1.0, -1, 49, 0, false, false, false)
FreezeEntityPosition(playerPed, true)
Expand Down Expand Up @@ -226,7 +229,9 @@ end)
inOneSync = function(netId)
local vehicle = NetworkDoesNetworkIdExist(netId) and NetworkGetEntityFromNetworkId(netId)

if DoesEntityExist(vehicle) then return {vehicle = vehicle} end
if DoesEntityExist(vehicle) then
return {vehicle = vehicle}
end
return false
end

Expand All @@ -239,51 +244,46 @@ deleteVehicleBlip = function(netId)
end
RegisterNetEvent('msk_enginetoggle:deleteVehicleBlip', deleteVehicleBlip)

showVehicleBlip = function(netId, coords)
local OneSync = inOneSync(netId)
addVehicleBlip = function(netId, coords)
local blip = AddBlipForCoord(coords.x, coords.y, coords.z)

if not activeBlips[netId] then
local blip = AddBlipForCoord(coords.x, coords.y, coords.z)
SetBlipSprite(blip, 326)
SetBlipDisplay(blip, 2)
SetBlipColour(blip, 1)
SetBlipScale(blip, 1.0)
SetBlipFlashes(blip, true)
SetBlipAsShortRange(blip, false)

SetBlipSprite(blip, 326)
SetBlipDisplay(blip, 2)
SetBlipColour(blip, 1)
SetBlipScale(blip, 1.0)
SetBlipFlashes(blip, true)
SetBlipAsShortRange(blip, false)
BeginTextCommandSetBlipName('STRING')
AddTextComponentString(Translation[Config.Locale]['blip_stolen_vehicle'])
EndTextCommandSetBlipName(blip)

BeginTextCommandSetBlipName('STRING')
AddTextComponentString(Translation[Config.Locale]['blip_stolen_vehicle'])
EndTextCommandSetBlipName(blip)
activeBlips[netId] = {isActive = false, blip = blip}
end

activeBlips[netId] = {
isActive = false,
blip = blip
}
end
showVehicleBlip = function(netId, coords)
if not activeBlips[netId] then addVehicleBlip(netId, coords) end
local OneSync = inOneSync(netId)

if not OneSync and activeBlips[netId] then
activeBlips[netId].isActive = false
ShowHeadingIndicatorOnBlip(activeBlips[netId].blip, false)
SetBlipCoords(activeBlips[netId].blip, coords.x, coords.y, coords.z)
elseif OneSync and activeBlips[netId] and not activeBlips[netId].isActive then
if OneSync and activeBlips[netId] and not activeBlips[netId].isActive then
CreateThread(function()
activeBlips[netId].isActive = true

while activeBlips[netId] and activeBlips[netId].isActive do
if DoesEntityExist(OneSync.vehicle) then
local vehicleCoords = GetEntityCoords(OneSync.vehicle)
local heading = math.ceil(GetEntityHeading(OneSync.vehicle))

SetBlipCoords(activeBlips[netId].blip, vehicleCoords.x, vehicleCoords.y, vehicleCoords.z)
ShowHeadingIndicatorOnBlip(activeBlips[netId].blip, true)
SetBlipRotation(activeBlips[netId].blip, heading)
else
deleteVehicleBlip(netId)
break
end
while activeBlips[netId] and activeBlips[netId].isActive and DoesEntityExist(OneSync.vehicle) do
local vehicleCoords = GetEntityCoords(OneSync.vehicle)
local heading = math.ceil(GetEntityHeading(OneSync.vehicle))

SetBlipCoords(activeBlips[netId].blip, vehicleCoords.x, vehicleCoords.y, vehicleCoords.z)
ShowHeadingIndicatorOnBlip(activeBlips[netId].blip, true)
SetBlipRotation(activeBlips[netId].blip, heading)

Wait(0)
end
end)
elseif not OneSync and activeBlips[netId] then
activeBlips[netId].isActive = false
SetBlipCoords(activeBlips[netId].blip, coords.x, coords.y, coords.z)
ShowHeadingIndicatorOnBlip(activeBlips[netId].blip, false)
end

SetTimeout(2500, function()
Expand Down
11 changes: 3 additions & 8 deletions client/vehiclekeys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,14 @@ getIsKeyOwner = function(vehicle)
if not Config.VehicleKeys.enable then return true end
local isKeyOwner, ignoreVehicle, ignorePlate = false, false, false
local plate = GetVehicleNumberPlateText(vehicle)
local canToggleEngine = true

if not Config.VehicleKeys.uniqueItems then
if Config.VehicleKeys.script == 'msk_vehiclekeys' and (GetResourceState("msk_vehiclekeys") == "started") then
isKeyOwner = exports["msk_vehiclekeys"]:HasPlayerKeyOrIsVehicleOwner(vehicle)
elseif Config.VehicleKeys.script == 'VehicleKeyChain' and (GetResourceState("VehicleKeyChain") == "started") then
isKeyOwner = exports["VehicleKeyChain"]:IsVehicleOrKeyOwner(vehicle)
elseif Config.VehicleKeys.script == 'vehicle_keys' and (GetResourceState("vehicle_keys") == "started") then
isKeyOwner = exports["vehicle_keys"]:doesPlayerOwnPlate(plate)
elseif Config.VehicleKeys.script == 'vehicles_keys' and (GetResourceState("vehicles_keys") == "started") then
isKeyOwner = exports["vehicles_keys"]:doesPlayerOwnPlate(plate)
elseif Config.VehicleKeys.script == 'wasabi_carlock' and (GetResourceState("wasabi_carlock") == "started") then
isKeyOwner = exports.wasabi_carlock:HasKey(plate)
elseif Config.VehicleKeys.script == 'qs-vehiclekeys' and (GetResourceState("qs-vehiclekeys") == "started") then
Expand All @@ -81,10 +80,6 @@ getIsKeyOwner = function(vehicle)
end
end

if not isKeyOwner and not ignoreVehicle and not ignorePlate then
canToggleEngine = false
end

return canToggleEngine
return isKeyOwner or ignoreVehicle or ignorePlate
end
exports('getIsKeyOwner', getIsKeyOwner)
4 changes: 2 additions & 2 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ Config.EngineFromSecondSeat = false
-- Vehicle Key System - set true then only the Owner of the Vehicle or someone with a Key can start the Engine

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

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

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

-- This is for inventories with metadata like ox_inventory
Expand Down
2 changes: 1 addition & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ games { 'gta5' }
author 'Musiker15 - MSK Scripts'
name 'msk_enginetoggle'
description 'EngineToggle for Vehicles'
version '4.2.3'
version '4.2.4'

lua54 'yes'

Expand Down
4 changes: 2 additions & 2 deletions server/hotwire.lua
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ RegisterNetEvent('msk_enginetoggle:policeAlert', function(coords)
end)

RegisterNetEvent('msk_enginetoggle:liveCoords', function(owner, netId, coords)
local playerId = nil
local Player = GetPlayerFromIdentifier(owner)
if not Player then return end

local playerId = nil

if Config.Framework == 'ESX' then
playerId = Player.source
elseif Config.Framework == 'QBCore' then
Expand Down
3 changes: 1 addition & 2 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ RegisterNetEvent('msk_enginetoggle:enteredVehicle', function(plate, seat, netId,
local src = source
local Player = GetPlayerFromId(src)
local identifier = nil
plate = MSK.Trim(plate, true)

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

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

if result and result[1] then
Expand Down
29 changes: 20 additions & 9 deletions server/versionchecker.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
local AUTHOR = "Musiker15"
local NAME = "msk_enginetoggle"
local NAME = "VERSIONS"
local FILE = "EngineToggle.json"

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

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

local CheckVersionCallback = function(status, response, header)
local CheckVersionCallback = function(status, response, headers)
if status ~= 200 then
print(CHECK_FAILED:format(status))
return
end

local latestRelease = json.decode(response)
local latestVersion = latestRelease.tag_name:gsub('v', '')
local response = json.decode(response)
local latestVersion = response[1].version
local currentVersion = GetResourceMetadata(GetCurrentResourceName(), "version")

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

if current[i] < latest[i] then
print(NEW_VERSION:format(currentVersion, latestVersion, DOWNLOAD_URL:format(AUTHOR, NAME, latestVersion)))
print(NEW_VERSION:format(currentVersion, latestVersion, DOWNLOAD_URL:format(RESOURCE_NAME, latestVersion)))
PrintKeyScripts()

for i = 1, #response do
if response[i].version == currentVersion then break end
print(("%s ^3[Changelogs v%s]^0"):format(NAME_COLORED, response[i].version))

for k = 1, #response[i].changelogs do
print(response[i].changelogs[k])
end
end

break
end
end
Expand All @@ -86,7 +97,7 @@ end
VersionChecker = function()
CreateThread(function()
CheckResourceName()
PerformHttpRequest(GITHUB_URL:format(AUTHOR, NAME), CheckVersionCallback)
PerformHttpRequest(GITHUB_URL:format(AUTHOR, NAME, FILE), CheckVersionCallback)
end)
end
VersionChecker()

0 comments on commit 254b9ae

Please sign in to comment.