Files
Jacob 605f9ca8fc Improve vehicle delete script.
+ Added /delallnow to instantly delete vehicles without the wait.
+ Changed base command timer from 1 minute to 5 minutes.
2022-04-29 00:59:39 +01:00

152 lines
7.0 KiB
Lua

RegisterNetEvent("delall")
AddEventHandler("delall", function ()
if Config.alerts then
exports['EGRP-Notifications']:Warning("System", "Vehicles will be wiped in 5 minutes. Stay in your vehicle to prevent deletion.", "top", 5000, true)
Citizen.Wait(240000)
exports['EGRP-Notifications']:Warning("System", "Vehicles will be wiped in 1 minute. Stay in your vehicle to prevent deletion.", "top", 5000, true)
--TriggerEvent("chat:addMessage", {color = { 255, 0, 0},multiline = false,args = {"[SYSTEM]", "Vehicles will be wiped in ^*^11 minute.^r Stay in your vehicle if you do not want it to be deleted."}})
Citizen.Wait(30000)
exports['EGRP-Notifications']:Warning("System", "Vehicles will be wiped in 30 seconds. Stay in your vehicle to prevent deletion.", "top", 5000, true)
--TriggerEvent("chat:addMessage", {color = { 255, 0, 0},multiline = false,args = {"[SYSTEM]", "Vehicles will be wiped in ^*^130 seconds.^r Stay in your vehicle if you do not want it to be deleted."}})
Citizen.Wait(25000)
exports['EGRP-Notifications']:Warning("System", "Vehicles will be wiped in 5 seconds. Stay in your vehicle to prevent deletion.", "top", 5000, true)
--TriggerEvent("chat:addMessage", {color = { 255, 0, 0},multiline = false,args = {"[SYSTEM]", "Vehicles will be wiped in ^*^15 seconds.^r Stay in your vehicle if you do not want it to be deleted."}})
Citizen.Wait(5000)
end
Citizen.Wait(1000)
for vehicle in EnumerateVehicles() do
if (not IsPedAPlayer(GetPedInVehicleSeat(vehicle, -1))) then
if Config.OnlyWipeBroken == true then
if GetVehicleEngineHealth(vehicle) <= 100.0 then
SetVehicleHasBeenOwnedByPlayer(vehicle, false)
SetEntityAsMissionEntity(vehicle, false, false)
DeleteVehicle(vehicle)
if Config.UseESX then
ESX.Game.DeleteVehicle(vehicle)
end
DeleteEntity(vehicle)
DeleteVehicle(vehicle)
if Config.UseESX then
ESX.Game.DeleteVehicle(vehicle)
end
DeleteEntity(vehicle)
if (DoesEntityExist(vehicle)) then
DeleteVehicle(vehicle)
if Config.UseESX then
ESX.Game.DeleteVehicle(vehicle)
end
DeleteEntity(vehicle)
DeleteVehicle(vehicle)
if Config.UseESX then
ESX.Game.DeleteVehicle(vehicle)
end
DeleteEntity(vehicle)
end
end
else
SetVehicleHasBeenOwnedByPlayer(vehicle, false)
SetEntityAsMissionEntity(vehicle, false, false)
DeleteVehicle(vehicle)
if Config.UseESX then
ESX.Game.DeleteVehicle(vehicle)
end
DeleteEntity(vehicle)
DeleteVehicle(vehicle)
if Config.UseESX then
ESX.Game.DeleteVehicle(vehicle)
end
DeleteEntity(vehicle)
if (DoesEntityExist(vehicle)) then
DeleteVehicle(vehicle)
if Config.UseESX then
ESX.Game.DeleteVehicle(vehicle)
end
DeleteEntity(vehicle)
DeleteVehicle(vehicle)
if Config.UseESX then
ESX.Game.DeleteVehicle(vehicle)
end
DeleteEntity(vehicle)
end
end
if Config.use10msdelay then
Citizen.Wait(10)
end
end
end
if Config.DoneNotify then
exports['EGRP-Notifications']:Success("System", "Vehicles have been successfully wiped!", "top", 5000, true)
--TriggerEvent("chat:addMessage", {color = { 255, 0, 0},multiline = false,args = {"[SYSTEM]", "Vehicles have been wiped!"}})
end
end)
--Delete all vehicles instantly--
RegisterNetEvent("delallnow")
AddEventHandler("delallnow", function ()
Citizen.Wait(1000)
for vehicle in EnumerateVehicles() do
if (not IsPedAPlayer(GetPedInVehicleSeat(vehicle, -1))) then
if Config.OnlyWipeBroken == true then
if GetVehicleEngineHealth(vehicle) <= 100.0 then
SetVehicleHasBeenOwnedByPlayer(vehicle, false)
SetEntityAsMissionEntity(vehicle, false, false)
DeleteVehicle(vehicle)
if Config.UseESX then
ESX.Game.DeleteVehicle(vehicle)
end
DeleteEntity(vehicle)
DeleteVehicle(vehicle)
if Config.UseESX then
ESX.Game.DeleteVehicle(vehicle)
end
DeleteEntity(vehicle)
if (DoesEntityExist(vehicle)) then
DeleteVehicle(vehicle)
if Config.UseESX then
ESX.Game.DeleteVehicle(vehicle)
end
DeleteEntity(vehicle)
DeleteVehicle(vehicle)
if Config.UseESX then
ESX.Game.DeleteVehicle(vehicle)
end
DeleteEntity(vehicle)
end
end
else
SetVehicleHasBeenOwnedByPlayer(vehicle, false)
SetEntityAsMissionEntity(vehicle, false, false)
DeleteVehicle(vehicle)
if Config.UseESX then
ESX.Game.DeleteVehicle(vehicle)
end
DeleteEntity(vehicle)
DeleteVehicle(vehicle)
if Config.UseESX then
ESX.Game.DeleteVehicle(vehicle)
end
DeleteEntity(vehicle)
if (DoesEntityExist(vehicle)) then
DeleteVehicle(vehicle)
if Config.UseESX then
ESX.Game.DeleteVehicle(vehicle)
end
DeleteEntity(vehicle)
DeleteVehicle(vehicle)
if Config.UseESX then
ESX.Game.DeleteVehicle(vehicle)
end
DeleteEntity(vehicle)
end
end
if Config.use10msdelay then
Citizen.Wait(10)
end
end
end
if Config.DoneNotify then
exports['EGRP-Notifications']:Success("System", "Vehicles have been successfully wiped!", "top", 5000, true)
--TriggerEvent("chat:addMessage", {color = { 255, 0, 0},multiline = false,args = {"[SYSTEM]", "Vehicles have been wiped!"}})
end
end)