mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-31 02:08:55 +00:00
/dv command changes (see desc)
- Added optional /dv argument for deleting vehicles in proximity - Use RequestControlOfEntity native to properly delete entities
This commit is contained in:
+33
-7
@@ -323,16 +323,42 @@ AddEventHandler('esx:pickupWeapon', function(weaponPickup, weaponName, ammo)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx:deleteVehicle')
|
||||
AddEventHandler('esx:deleteVehicle', function()
|
||||
AddEventHandler('esx:deleteVehicle', function(radius)
|
||||
local playerPed = PlayerPedId()
|
||||
local vehicle = ESX.Game.GetVehicleInDirection()
|
||||
|
||||
if IsPedInAnyVehicle(playerPed, true) then
|
||||
vehicle = GetVehiclePedIsIn(playerPed, false)
|
||||
end
|
||||
if radius and tonumber(radius) then
|
||||
radius = tonumber(radius) + 0.01
|
||||
local vehicles = ESX.Game.GetVehiclesInArea(GetEntityCoords(playerPed), radius)
|
||||
|
||||
if DoesEntityExist(vehicle) then
|
||||
ESX.Game.DeleteVehicle(vehicle)
|
||||
for k,entity in ipairs(vehicles) do
|
||||
local attempt = 0
|
||||
|
||||
while not NetworkHasControlOfEntity(entity) and attempt < 100 and DoesEntityExist(entity) do
|
||||
Citizen.Wait(100)
|
||||
NetworkRequestControlOfEntity(entity)
|
||||
attempt = attempt + 1
|
||||
end
|
||||
|
||||
if DoesEntityExist(entity) and NetworkHasControlOfEntity(entity) then
|
||||
ESX.Game.DeleteVehicle(entity)
|
||||
end
|
||||
end
|
||||
else
|
||||
local vehicle, attempt = ESX.Game.GetVehicleInDirection(), 0
|
||||
|
||||
if IsPedInAnyVehicle(playerPed, true) then
|
||||
vehicle = GetVehiclePedIsIn(playerPed, false)
|
||||
end
|
||||
|
||||
while not NetworkHasControlOfEntity(vehicle) and attempt < 100 and DoesEntityExist(vehicle) do
|
||||
Citizen.Wait(100)
|
||||
NetworkRequestControlOfEntity(vehicle)
|
||||
attempt = attempt + 1
|
||||
end
|
||||
|
||||
if DoesEntityExist(vehicle) and NetworkHasControlOfEntity(vehicle) then
|
||||
ESX.Game.DeleteVehicle(vehicle)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
+8
-4
@@ -43,16 +43,20 @@ end, function(source, args, user)
|
||||
end, {help = _U('spawn_car'), params = {{name = 'car', help = _U('spawn_car_param')}}})
|
||||
|
||||
TriggerEvent('es:addGroupCommand', 'cardel', 'admin', function(source, args, user)
|
||||
TriggerClientEvent('esx:deleteVehicle', source)
|
||||
TriggerClientEvent('esx:deleteVehicle', source, args[1])
|
||||
end, function(source, args, user)
|
||||
TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient Permissions.' } })
|
||||
end, {help = _U('delete_vehicle')})
|
||||
end, {help = _U('delete_vehicle'), params = {
|
||||
{name = 'radius', help = 'Optional, delete every vehicle within the specified radius'}
|
||||
}})
|
||||
|
||||
TriggerEvent('es:addGroupCommand', 'dv', 'admin', function(source, args, user)
|
||||
TriggerClientEvent('esx:deleteVehicle', source)
|
||||
TriggerClientEvent('esx:deleteVehicle', source, args[1])
|
||||
end, function(source, args, user)
|
||||
TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient Permissions.' } })
|
||||
end, {help = _U('delete_vehicle')})
|
||||
end, {help = _U('delete_vehicle'), params = {
|
||||
{name = 'radius', help = 'Optional, delete every vehicle within the specified radius'}
|
||||
}})
|
||||
|
||||
TriggerEvent('es:addGroupCommand', 'setmoney', 'admin', function(source, args, user)
|
||||
local playerId = source
|
||||
|
||||
Reference in New Issue
Block a user