Skip to content

Commit

Permalink
Update v4.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Musiker15 committed Oct 8, 2024
1 parent b3a747a commit bc17dc5
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 37 deletions.
30 changes: 15 additions & 15 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,17 @@ toggleEngine = function(bypass)
end

if not bypass then
canToggleEngine = getIsKeyOwner(vehicle)
local isBlacklisted = IsVehicleBlacklisted(vehicle)

if isBlacklisted then
return -- Just return without any info
end

local isWhitelisted = IsVehicleWhitelisted(vehicle)

if not isWhitelisted then
canToggleEngine = getIsKeyOwner(vehicle)
end
end

if not canToggleEngine then
Expand All @@ -64,6 +74,9 @@ toggleEngine = function(bypass)
disabledDrive = false
Config.Notification(nil, Translation[Config.Locale]['engine_start'], 'success')
end

TriggerEvent('msk_enginetoggle:toggledEngine', vehicle, not isEngineOn)
TriggerServerEvent('msk_enginetoggle:toggledEngine', VehToNet(vehicle), not isEngineOn)
end
exports('toggleEngine', toggleEngine)
RegisterNetEvent('msk_enginetoggle:toggleEngine', toggleEngine)
Expand Down Expand Up @@ -257,19 +270,6 @@ end
exports('GetVehicleDamaged', GetVehicleDamaged)
exports('getVehicleDamaged', GetVehicleDamaged) -- Support for old versions

GetPedVehicleSeat = function(playerPed, vehicle)
if not playerPed then playerPed = PlayerPedId() end
if not vehicle then vehicle = currentVehicle and currentVehicle.vehicle or GetVehiclePedIsIn(playerPed) end
if not vehicle or not DoesEntityExist(vehicle) then return end

for i = -1, 16 do
if (GetPedInVehicleSeat(vehicle, i) == playerPed) then
return i
end
end
return -1
end

disableDrive = function()
if disabledDrive then return end
disabledDrive = true
Expand All @@ -291,6 +291,6 @@ disableDrive = function()
end

logging = function(code, ...)
if code == 'debug' and not Config.Debug then return end
if not Config.Debug then return end
MSK.Logging(code, ...)
end
68 changes: 68 additions & 0 deletions client/utils.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
GetPedVehicleSeat = function(playerPed, vehicle)
if not playerPed then playerPed = PlayerPedId() end
if not vehicle then vehicle = currentVehicle and currentVehicle.vehicle or GetVehiclePedIsIn(playerPed) end
if not vehicle or not DoesEntityExist(vehicle) then return end

for i = -1, 16 do
if (GetPedInVehicleSeat(vehicle, i) == playerPed) then
return i
end
end
return -1
end

IsVehicleWhitelisted = function(vehicle)
local vehicleClass = GetVehicleClass(vehicle)

for k, class in pairs(Config.Whitelist.classes) do
if vehicleClass == class then
return true
end
end

local vehicleModel = GetEntityModel(vehicle)

for k, model in pairs(Config.Whitelist.vehicles) do
local modelHash = type(model) == 'number' and model or GetHashKey(model)

if vehicleModel == modelHash then
return true
end
end

local vehiclePlate = GetVehicleNumberPlateText(vehicle)

for k, plate in pairs(Config.Whitelist.plates) do
if string.find(MSK.String.Trim(vehiclePlate, true), MSK.String.Trim(plate, true)) then
return true
end
end
end

IsVehicleBlacklisted = function(vehicle)
local vehicleClass = GetVehicleClass(vehicle)

for k, class in pairs(Config.Whitelist.classes) do
if vehicleClass == class then
return true
end
end

local vehicleModel = GetEntityModel(vehicle)

for k, model in pairs(Config.Whitelist.vehicles) do
local modelHash = type(model) == 'number' and model or GetHashKey(model)

if vehicleModel == modelHash then
return true
end
end

local vehiclePlate = GetVehicleNumberPlateText(vehicle)

for k, plate in pairs(Config.Whitelist.plates) do
if string.find(MSK.String.Trim(vehiclePlate, true), MSK.String.Trim(plate, true)) then
return true
end
end
end
18 changes: 1 addition & 17 deletions client/vehiclekeys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,6 @@ getIsKeyOwner = function(vehicle)
isKeyOwner = getKeyFromInventory(plate)
end

for k, v in pairs(Config.Whitelist.vehicles) do
local modelHash = type(v) == 'number' and v or GetHashKey(v)

if GetEntityModel(vehicle) == modelHash then
ignoreVehicle = true
break
end
end

for k, v in pairs(Config.Whitelist.plates) do
if string.find(MSK.Trim(plate), MSK.Trim(v)) then
ignorePlate = true
break
end
end

return (isKeyOwner or ignoreVehicle or ignorePlate)
return isKeyOwner
end
exports('getIsKeyOwner', getIsKeyOwner)
27 changes: 24 additions & 3 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ Config.VehicleKeys = {

-- This is for inventories with metadata like ox_inventory
-- Supported Inventories: ox_inventory, qs-inventory, core_inventory
-- For okokGarage you have to set this to true!
-- For okokGarage you have to set this to true
-- For msk_vehiclekeys you have to set this to false
uniqueItems = false, -- If set to true, it will search for the item in the inventory
item = 'keys', -- Item in your inventory for vehicle keys
}
Expand All @@ -64,12 +65,28 @@ Config.SaveAngleOnExit = 75 -- default: F - 75 (Exit Vehicle)
-- With this feature you can set vehicles and plates for which you don't need a key to start the engine
-- either exact plates or just a string that should be in the vehicles plate e.g. "ESX" will ignore te plate "ESX1234" too
Config.Whitelist = {
classes = {

},
vehicles = {
-- Please use `` and NOT '' or ""
`caddy`, `caddy2`, `caddy3`, `airtug`, `docktug`, `forklift`, `mower`, `tractor2`,
},
plates = {
"ESX", "MSK", "Test"
"ESX", "MSK", "Test",
},
}

Config.Blacklist = {
classes = {
13, 21,
},
vehicles = {
-- Please use `` and NOT '' or ""
`bmx`, `cruiser`, `fixter`, `scorcher`, `tribike`, `tribike2`, `tribike3`,
},
plates = {
"ESX2", "MSK2", "Test2",
},
}
----------------------------------------------------------------
Expand Down Expand Up @@ -179,4 +196,8 @@ Config.Animation = {
action = 'skillbar', -- Set to 'skillbar' or 'progressbar'
time = 15, -- in seconds // How long does it take to hotwire the vehicle // Only for 'progressbar'
}
}
}
----------------------------------------------------------------
exports('Config', function()
return Config
end)
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.6'
version '4.3.0'

lua54 'yes'

Expand Down
2 changes: 1 addition & 1 deletion server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,6 @@ MSK.Register('msk_enginetoggle:getInventory', function(source, inv)
end)

logging = function(code, ...)
if code == 'debug' and not Config.Debug then return end
if not Config.Debug then return end
MSK.Logging(code, ...)
end

0 comments on commit bc17dc5

Please sign in to comment.