mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-16 21:46:03 +01:00
fix(server/commands): dv command inconsistency
This commit is contained in:
@@ -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)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user