Improve vehicle delete script.

+ Added /delallnow to instantly delete vehicles without the wait.
+ Changed base command timer from 1 minute to 5 minutes.
This commit is contained in:
Jacob
2022-04-29 00:59:39 +01:00
parent 90dfcd0feb
commit 605f9ca8fc
3 changed files with 76 additions and 0 deletions
+73
View File
@@ -1,6 +1,8 @@
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)
@@ -77,3 +79,74 @@ AddEventHandler("delall", function ()
--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)
+1
View File
@@ -2,6 +2,7 @@ Config = {}
Config = {
commandName = "delall", -- For manual carwipes
commandNowName = "delallnow", -- For manual carwipes
restricCommand = true, -- Now you need permission to do
alerts = true, -- Notify in chat when a carwipe is comming
use10msdelay = true, -- use 10ms delay by deleting a vehicle
+2
View File
@@ -1,5 +1,7 @@
RegisterCommand(Config.commandName, function(source, args, rawCommand) TriggerClientEvent("delall", -1) end, Config.restricCommand)
RegisterCommand(Config.commandNowName, function(source, args, rawCommand) TriggerClientEvent("delallnow", -1) end, Config.restricCommand)
function CleanUpCronTask(d, h, m)
TriggerClientEvent("delall", -1)
end