add delped

This commit is contained in:
KingMcDonalds
2025-07-10 13:26:22 -07:00
parent 1efdcefbca
commit faec7d5d1f
3 changed files with 96 additions and 0 deletions
+92
View File
@@ -0,0 +1,92 @@
-- Don't forget that the script is essentially the same delveh from WolfKnight179
-- But only to delete ped instead of a vehicle
-- I actually took from delveh all system of delete and even some of his comments lol
-- So let's all say thank you to him
-- Thx WolfKnight179
-- And thanks to the other people who helped him
RegisterCommand("dp", function()
TriggerEvent("wk:deletePed")
end, false)
TriggerEvent("chat:addSuggestion", "/dp", "Delete ped")
-- The distance to check in front of the player for a ped
local distanceToCheck = 5.0
-- The number of times to retry deleting a ped if it fails the first time
local numRetries = 5
-- Add an event handler for the deletePed event
RegisterNetEvent("wk:deletePed")
AddEventHandler("wk:deletePed", function()
local ped = GetPlayerPed(-1)
if (DoesEntityExist(ped) and IsPedOnFoot(ped)) then
local pos = GetEntityCoords(ped)
if (nearestPed) then
DeleteNearestPed(nearestPed, numRetries)
else
local inFrontOfPlayer = GetOffsetFromEntityInWorldCoords(ped, 0.0, distanceToCheck, 0.0)
local ped = GetPedInDirection(ped, pos, inFrontOfPlayer)
if (DoesEntityExist(ped)) then
DeleteNearestPed(ped, numRetries)
else
Notify("~y~You must be near the ped to delete it.")
end
end
end
end)
function DeleteNearestPed(ped, timeoutMax)
local timeout = 0
SetEntityAsMissionEntity(ped, true, true)
DeletePed(ped)
if (DoesEntityExist(ped)) then
Notify("~r~Failed to delete ped, trying again...")
-- Fallback if ped doesn't get deleted
while (DoesEntityExist(ped) and timeout < timeoutMax) do
DeletePed(ped)
-- Ped got banned
if (not DoesEntityExist(ped)) then
Notify("~g~Ped deleted.")
end
-- Increase the timeout counter and make the system wait
timeout = timeout + 1
Citizen.Wait(500)
-- We've timed out and the ped still hasn't been deleted
if (DoesEntityExist(ped) and (timeout == timeoutMax - 1)) then
Notify("~r~Failed to delete vehicle after " .. timeoutMax .. " retries.")
end
end
else
Notify("~g~Ped deleted.")
end
end
-- Gets a ped in a certain direction
-- As I understand this function writes Konijima in WolfKnight's delveh script
-- So all credits to him
-- Thx Konijima
function GetPedInDirection(entFrom, coordFrom, coordTo)
local rayHandle = StartShapeTestCapsule(coordFrom.x, coordFrom.y, coordFrom.z, coordTo.x, coordTo.y, coordTo.z, 5.0, 10, entFrom, 7)
local _, _, _, _, ped = GetShapeTestResult(rayHandle)
if (IsEntityAPed(ped)) then
return ped
end
end
-- Shows a notification on the player's screen
function Notify(text)
SetNotificationTextEntry("STRING")
AddTextComponentString(text)
DrawNotification(false, false)
end
+3
View File
@@ -0,0 +1,3 @@
fx_version "bodacious"
game "gta5"
client_script "client.lua"
+1
View File
@@ -73,6 +73,7 @@ ensure SmartHoseLite
ensure SmartFiresLite ensure SmartFiresLite
ensure SmartFiresLite ensure SmartFiresLite
ensure ebu_flatbeds_ers ensure ebu_flatbeds_ers
ensure delped
ensure Cruise-Control ensure Cruise-Control
ensure guidehud ensure guidehud
ensure EGRP-LoadingScreen ensure EGRP-LoadingScreen