fixes
This commit is contained in:
parent
9426a0d280
commit
bbe8c6f8ce
137 changed files with 164 additions and 12842 deletions
|
@ -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)
|
||||
|
|
|
@ -1,41 +1,77 @@
|
|||
-- Client-side freeze handling (put this in a client file)
|
||||
RegisterNetEvent('ox_commands:freeze', function(freezeStatus, notify)
|
||||
local playerPed = PlayerPedId()
|
||||
FreezeEntityPosition(playerPed, freezeStatus)
|
||||
|
||||
if notify then
|
||||
lib.notify({
|
||||
title = freezeStatus and 'Frozen' or 'Unfrozen',
|
||||
description = freezeStatus and 'You have been frozen by an admin' or 'You have been unfrozen by an admin',
|
||||
type = freezeStatus and 'error' or 'success'
|
||||
})
|
||||
end
|
||||
end)
|
||||
|
||||
-- Server-side commands (put this in a server file)
|
||||
lib.addCommand('freeze', {
|
||||
help = 'Freeze the player',
|
||||
help = 'Freeze a player',
|
||||
params = {
|
||||
{
|
||||
name = 'target',
|
||||
type = 'playerId',
|
||||
help = 'Target player\'s server id',
|
||||
},
|
||||
help = 'Target player server ID',
|
||||
optional = true -- Makes target optional (self-target if omitted)
|
||||
}
|
||||
},
|
||||
restricted = 'group.admin'
|
||||
}, function(source, args, raw)
|
||||
local entity = GetPlayerPed(args.target)
|
||||
local target = args.target or source -- If no target specified, target self
|
||||
local entity = GetPlayerPed(target)
|
||||
|
||||
if entity ~= 0 then
|
||||
TriggerClientEvent('ox_commands:freeze', args.target, true, true)
|
||||
return TriggerClientEvent('ox_commands:notify', source, { type = 'success', description = 'success' })
|
||||
TriggerClientEvent('ox_commands:freeze', target, true, source ~= target) -- Only notify if targeting someone else
|
||||
lib.notify(source, {
|
||||
title = 'Success',
|
||||
description = ('Player %d frozen'):format(target),
|
||||
type = 'success'
|
||||
})
|
||||
else
|
||||
lib.notify(source, {
|
||||
title = 'Error',
|
||||
description = 'Invalid target player',
|
||||
type = 'error'
|
||||
})
|
||||
end
|
||||
|
||||
lib.notify(source, { type = 'error', description = 'invalid_target' })
|
||||
end)
|
||||
|
||||
lib.addCommand('thaw', {
|
||||
help = 'Unfreeze the player',
|
||||
help = 'Unfreeze a player',
|
||||
params = {
|
||||
{
|
||||
name = 'target',
|
||||
type = 'playerId',
|
||||
help = 'Target player\'s server id',
|
||||
},
|
||||
help = 'Target player server ID',
|
||||
optional = true -- Makes target optional (self-target if omitted)
|
||||
}
|
||||
},
|
||||
restricted = 'group.admin'
|
||||
}, function(source, args, raw)
|
||||
local entity = GetPlayerPed(args.target)
|
||||
local target = args.target or source -- If no target specified, target self
|
||||
local entity = GetPlayerPed(target)
|
||||
|
||||
if entity ~= 0 then
|
||||
TriggerClientEvent('ox_commands:freeze', args.target, false, true)
|
||||
return TriggerClientEvent('ox_commands:notify', source, { type = 'success', description = 'success' })
|
||||
TriggerClientEvent('ox_commands:freeze', target, false, source ~= target) -- Only notify if targeting someone else
|
||||
lib.notify(source, {
|
||||
title = 'Success',
|
||||
description = ('Player %d unfrozen'):format(target),
|
||||
type = 'success'
|
||||
})
|
||||
else
|
||||
lib.notify(source, {
|
||||
title = 'Error',
|
||||
description = 'Invalid target player',
|
||||
type = 'error'
|
||||
})
|
||||
end
|
||||
|
||||
lib.notify(source, { type = 'error', description = 'invalid_target' })
|
||||
end)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue