From f71d2a021bcd5d179bcd443b6cdf87be8fe151c2 Mon Sep 17 00:00:00 2001 From: JesseS6998 Date: Fri, 17 Apr 2026 23:46:18 -0230 Subject: [PATCH 1/2] Fixed - Spike deletion issue. When multiple groups of spikes are placed you can only delete one group, This rework fixes that to insure spikes are stored and deleted per group to prevent "bugged" spikes. --- client.lua | 61 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 51 insertions(+), 10 deletions(-) diff --git a/client.lua b/client.lua index 01c6329..735a1fb 100644 --- a/client.lua +++ b/client.lua @@ -130,6 +130,7 @@ end) --Spike Strip Spawn Event local SpawnedSpikes = {} + RegisterNetEvent('SEM_InteractionMenu:Spikes-SpawnSpikes') AddEventHandler('SEM_InteractionMenu:Spikes-SpawnSpikes', function(Length) if IsPedInAnyVehicle(PlayerPedId(), false) then @@ -137,29 +138,69 @@ AddEventHandler('SEM_InteractionMenu:Spikes-SpawnSpikes', function(Length) return end - local SpawnCoords = GetOffsetFromEntityInWorldCoords(GetPlayerPed(PlayerId()) , 0.0, 2.0, 0.0) + local ped = PlayerPedId() + local SpawnCoords = GetOffsetFromEntityInWorldCoords(ped, 0.0, 2.0, 0.0) + + local group = {} + for a = 1, Length do - local Spike = CreateObject(GetHashKey('P_ld_stinger_s'), SpawnCoords.x, SpawnCoords.y, SpawnCoords.z, 1, 1, 1) + local Spike = CreateObject(GetHashKey('P_ld_stinger_s'), SpawnCoords.x, SpawnCoords.y, SpawnCoords.z, true, true, true) local NetID = NetworkGetNetworkIdFromEntity(Spike) + SetNetworkIdExistsOnAllMachines(NetID, true) SetNetworkIdCanMigrate(NetID, false) - SetEntityHeading(Spike, GetEntityHeading(GetPlayerPed(PlayerId()) )) + + SetEntityHeading(Spike, GetEntityHeading(ped)) PlaceObjectOnGroundProperly(Spike) FreezeEntityPosition(Spike, true) + + table.insert(group, { + NetID = NetID, + Coords = GetEntityCoords(Spike) + }) + SpawnCoords = GetOffsetFromEntityInWorldCoords(Spike, 0.0, 4.0, 0.0) - table.insert(SpawnedSpikes, NetID) end + + table.insert(SpawnedSpikes, group) end) ---Spike Strip Delete Event RegisterNetEvent('SEM_InteractionMenu:Spikes-DeleteSpikes') AddEventHandler('SEM_InteractionMenu:Spikes-DeleteSpikes', function() - for a = 1, #SpawnedSpikes do - local Spike = NetworkGetEntityFromNetworkId(SpawnedSpikes[a]) - DeleteEntity(Spike) + local ped = PlayerPedId() + local playerCoords = GetEntityCoords(ped) + + local closestIndex = nil + local closestDist = math.huge + + for i = 1, #SpawnedSpikes do + local group = SpawnedSpikes[i] + local coords = group[1].Coords + local dist = #(playerCoords - coords) + + if dist < closestDist then + closestDist = dist + closestIndex = i + end + end + + if not closestIndex or closestDist > 15 then + Notify('~r~No spikes found nearby') + return end - Notify('~r~Spikes Strips Removed!') - SpawnedSpikes = {} + + local group = SpawnedSpikes[closestIndex] + + for i = 1, #group do + local entity = NetworkGetEntityFromNetworkId(group[i].NetID) + if DoesEntityExist(entity) then + DeleteEntity(entity) + end + end + + table.remove(SpawnedSpikes, closestIndex) + + Notify('~r~Removed Spikes') end) --Spike Strip Tire Popping From 1486594bde2c86e6d7b970712fb7b08f674d5b0f Mon Sep 17 00:00:00 2001 From: JesseS6998 Date: Fri, 17 Apr 2026 23:55:03 -0230 Subject: [PATCH 2/2] Re-add comment that was removed during update. --- client.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/client.lua b/client.lua index 735a1fb..c3bdd8d 100644 --- a/client.lua +++ b/client.lua @@ -165,6 +165,7 @@ AddEventHandler('SEM_InteractionMenu:Spikes-SpawnSpikes', function(Length) table.insert(SpawnedSpikes, group) end) +--Spike Strip Delete Event RegisterNetEvent('SEM_InteractionMenu:Spikes-DeleteSpikes') AddEventHandler('SEM_InteractionMenu:Spikes-DeleteSpikes', function() local ped = PlayerPedId()