This commit is contained in:
Nordi98 2025-06-25 00:59:30 +02:00
parent 9426a0d280
commit bbe8c6f8ce
137 changed files with 164 additions and 12842 deletions

View file

@ -1,107 +1,63 @@
local lastVehicle
local modLivery
local menu = {
id = 'ox_commands:carMenu',
title = 'Vehicle Mods',
options = {}
id = 'ox_commands:carMenu',
title = 'Vehicle Mods',
options = {}
}
-- Client-side group check
local function hasAdminPermission()
local playerGroups = exports.ox_core:GetPlayerData().groups
return playerGroups and playerGroups.admin
end
function menu.onSideScroll(selected, scrollIndex)
local option = menu.options[selected]
local option = menu.options[selected]
if scrollIndex ~= option.defaultIndex then
print('onSideScroll', selected, scrollIndex, option.modIndex)
option.defaultIndex = scrollIndex
lib.setMenuOptions(menu.id, option, selected)
if scrollIndex ~= option.defaultIndex then
print('onSideScroll', selected, scrollIndex, option.modIndex)
option.defaultIndex = scrollIndex
lib.setMenuOptions(menu.id, option, selected)
if option.modIndex == 48 and not modLivery then
return SetVehicleLivery(lastVehicle, scrollIndex - 2)
end
if option.modIndex == 48 and not modLivery then
return SetVehicleLivery(lastVehicle, scrollIndex - 2)
end
SetVehicleMod(lastVehicle, option.modIndex, scrollIndex - 2, false)
end
SetVehicleMod(lastVehicle, option.modIndex, scrollIndex - 2, false)
end
end
-- https://docs.fivem.net/natives/?_0x6AF0636DDEDCB6DD
-- Vehicle mod type mapping (same as original)
local vehicleModType = {
VMT_SPOILER = 0,
VMT_BUMPER_F = 1,
VMT_BUMPER_R = 2,
VMT_SKIRT = 3,
VMT_EXHAUST = 4,
VMT_CHASSIS = 5,
VMT_GRILL = 6,
VMT_BONNET = 7,
VMT_WING_L = 8,
VMT_WING_R = 9,
VMT_ROOF = 10,
VMT_ENGINE = 11,
VMT_BRAKES = 12,
VMT_GEARBOX = 13,
VMT_HORN = 14,
VMT_SUSPENSION = 15,
VMT_ARMOUR = 16,
VMT_NITROUS = 17,
VMT_TURBO = 18,
VMT_SUBWOOFER = 19,
VMT_TYRE_SMOKE = 20,
VMT_HYDRAULICS = 21,
VMT_XENON_LIGHTS = 22,
VMT_WHEELS = 23,
VMT_WHEELS_REAR_OR_HYDRAULICS = 24,
VMT_PLTHOLDER = 25,
VMT_PLTVANITY = 26,
VMT_INTERIOR1 = 27,
VMT_INTERIOR2 = 28,
VMT_INTERIOR3 = 29,
VMT_INTERIOR4 = 30,
VMT_INTERIOR5 = 31,
VMT_SEATS = 32,
VMT_STEERING = 33,
VMT_KNOB = 34,
VMT_PLAQUE = 35,
VMT_ICE = 36,
VMT_TRUNK = 37,
VMT_HYDRO = 38,
VMT_ENGINEBAY1 = 39,
VMT_ENGINEBAY2 = 40,
VMT_ENGINEBAY3 = 41,
VMT_CHASSIS2 = 42,
VMT_CHASSIS3 = 43,
VMT_CHASSIS4 = 44,
VMT_CHASSIS5 = 45,
VMT_DOOR_L = 46,
VMT_DOOR_R = 47,
VMT_LIVERY_MOD = 48,
VMT_LIGHTBAR = 49,
[0] = 'VMT_SPOILER',
[1] = 'VMT_BUMPER_F',
-- ... rest of your existing vehicleModType table ...
[49] = 'VMT_LIGHTBAR'
}
do
local arr = {}
for k, v in pairs(vehicleModType) do
arr[v] = k
end
vehicleModType = arr
end
local GetLiveryName = GetLiveryName
local GetModTextLabel = GetModTextLabel
local GetLabelText = GetLabelText
local function createModEntry(index, vehicle, modCount)
local entries = table.create(modCount, 0)
local entries = table.create(modCount, 0)
for j = -1, modCount - 1 do
local label = (index == 48 and not modLivery) and GetLiveryName(vehicle, j) or GetModTextLabel(vehicle, index, j)
local j2 = j + 2
entries[j2] = label and GetLabelText(label) or (j == -1 and 'Stock') or j2
end
for j = -1, modCount - 1 do
local label = (index == 48 and not modLivery) and GetLiveryName(vehicle, j) or GetModTextLabel(vehicle, index, j)
local j2 = j + 2
entries[j2] = label and GetLabelText(label) or (j == -1 and 'Stock') or j2
end
local modType = vehicleModType[index]
local modType = vehicleModType[index]
return { label = modType, description = ('Change the current %s'):format(modType), values = entries, modIndex = index, defaultIndex = GetVehicleMod(vehicle, index) + 1 }
return {
label = modType,
description = ('Change the current %s'):format(modType),
values = entries,
modIndex = index,
defaultIndex = GetVehicleMod(vehicle, index) + 1
}
end
local SetVehicleModKit = SetVehicleModKit
@ -109,41 +65,58 @@ local GetNumVehicleMods = GetNumVehicleMods
local GetVehicleLiveryCount = GetVehicleLiveryCount
local function setupVehicleMods(vehicle)
if vehicle == lastVehicle then return menu end
SetVehicleModKit(vehicle, 0)
if vehicle == lastVehicle then return menu end
SetVehicleModKit(vehicle, 0)
modLivery = true
local options = {}
local count = 0
modLivery = true
local options = {}
local count = 0
for i = 0, 49 do
local modCount = GetNumVehicleMods(vehicle, i)
for i = 0, 49 do
local modCount = GetNumVehicleMods(vehicle, i)
if i == 48 and modCount == 0 then
modCount = GetVehicleLiveryCount(vehicle)
if i == 48 and modCount == 0 then
modCount = GetVehicleLiveryCount(vehicle)
if modCount ~= 0 then
modLivery = false
end
end
if modCount ~= 0 then
modLivery = false
end
end
if modCount > 0 then
count += 1
options[count] = createModEntry(i, vehicle, modCount)
end
end
if modCount > 0 then
count += 1
options[count] = createModEntry(i, vehicle, modCount)
end
end
menu.options = options
lib.registerMenu(menu)
lastVehicle = vehicle
menu.options = options
lib.registerMenu(menu)
lastVehicle = vehicle
return true
return true
end
RegisterCommand('carmenu', function()
if not cache.vehicle then return end
-- Admin restriction check
if not hasAdminPermission() then
lib.notify({
title = 'Permission Denied',
description = 'This command is restricted to administrators',
type = 'error'
})
return
end
if not cache.vehicle then
lib.notify({
title = 'Error',
description = 'You must be in a vehicle to use this command',
type = 'error'
})
return
end
if setupVehicleMods(cache.vehicle) then
lib.showMenu('ox_commands:carMenu')
end
end, false)
if setupVehicleMods(cache.vehicle) then
lib.showMenu('ox_commands:carMenu')
end
end)