From faec7d5d1f1ea96a4d5f9bd66953f9e09bc01e7a Mon Sep 17 00:00:00 2001 From: KingMcDonalds Date: Thu, 10 Jul 2025 13:26:22 -0700 Subject: [PATCH] add delped --- resources/delped/client.lua | 92 +++++++++++++++++++++++++++++++++ resources/delped/fxmanifest.lua | 3 ++ server.cfg | 1 + 3 files changed, 96 insertions(+) create mode 100644 resources/delped/client.lua create mode 100644 resources/delped/fxmanifest.lua diff --git a/resources/delped/client.lua b/resources/delped/client.lua new file mode 100644 index 000000000..e3791e5b8 --- /dev/null +++ b/resources/delped/client.lua @@ -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 \ No newline at end of file diff --git a/resources/delped/fxmanifest.lua b/resources/delped/fxmanifest.lua new file mode 100644 index 000000000..38666b0c8 --- /dev/null +++ b/resources/delped/fxmanifest.lua @@ -0,0 +1,3 @@ +fx_version "bodacious" +game "gta5" +client_script "client.lua" \ No newline at end of file diff --git a/server.cfg b/server.cfg index ae76f0693..264dbcfd2 100644 --- a/server.cfg +++ b/server.cfg @@ -73,6 +73,7 @@ ensure SmartHoseLite ensure SmartFiresLite ensure SmartFiresLite ensure ebu_flatbeds_ers +ensure delped ensure Cruise-Control ensure guidehud ensure EGRP-LoadingScreen