fix(server/commands): dv command inconsistency

This commit is contained in:
Andyyy7666
2025-01-18 14:40:01 +01:00
parent d132c12025
commit a9785ce754

View File

@@ -321,48 +321,36 @@ lib.addCommand("dv", {
} }
}, function(source, args, raw) }, function(source, args, raw)
local ped = GetPlayerPed(source) local ped = GetPlayerPed(source)
local veh = GetVehiclePedIsIn(ped)
if veh and veh ~= 0 and DoesEntityExist(veh) then
DeleteEntity(veh)
return TriggerClientEvent("chat:addMessage", source, {
color = {50, 100, 235},
multiline = true,
args = {"Staff action", "deleted 1 vehicle"}
})
end
local count = 0
local coords = GetEntityCoords(ped) local coords = GetEntityCoords(ped)
local count = 0
local message = nil
local veh = lib.getClosestVehicle(coords, 3.0)
if args.range then if args.range then
for _, veh in ipairs(GetAllVehicles()) do local vehicles = lib.getNearbyVehicles(coords, args.range)
local vehDist = #(GetEntityCoords(veh) - coords) count = #vehicles
if vehDist < args.range then
DeleteEntity(veh) for i=1, count do
count += 1 local veh = vehicles[i]
end DeleteEntity(veh.vehicle)
end end
return TriggerClientEvent("chat:addMessage", source, { elseif veh then
color = {50, 100, 235}, DeleteEntity(veh)
multiline = true, count = 1
args = {"Staff action", ("deleted %d vehicles"):format(count)}
})
end end
local closest, dist if count == 0 then
for _, veh in ipairs(GetAllVehicles()) do message = {"Staff action [dv]", "no vehicles found"}
local vehDist = #(GetEntityCoords(veh) - coords) elseif count == 1 then
if vehDist < 5.0 and not closest or (dist and dist > vehDist) then message = {"Staff action [dv]", "deleted 1 vehicle"}
closest = veh else
dist = vehDist message = {"Staff action [dv]", ("deleted %d vehicles"):format(count)}
end
end end
if not closest then return "no vehicle found nearby" end
DeleteEntity(closest)
TriggerClientEvent("chat:addMessage", source, { TriggerClientEvent("chat:addMessage", source, {
color = {50, 100, 235}, color = {50, 100, 235},
multiline = true, multiline = true,
args = {"Staff action", "deleted 1 vehicle"} args = message
}) })
end) end)