How to remove parkinglot swing barriers

Hi there xander and thanks for the help.

I added this to a new resource as a client file and started it. I get no errors in either client or server but the gates are still there when I arrive to the spot.

Any idea on how I can narrow down what needs to be changed?

maybe at the end change the 1, 1, 1 to 0, 1, 1? :man_shrugging:

Maybe also add a print message above the DeleteEntity and say print("Deleting Entity")

Just to visualize in the console if the object is being found?

It’s spamming “Deleting entity” in F8 as we drive through the world but the gates are still here when we pull up.

Lets me hop in me dev server and see if I can get it :stuck_out_tongue_winking_eye:

1 Like

For some reason I guess the GetClosestObjectOfType native does not return those objects… Which is odd because that native works fine for doors and stuff…

But it says it’s deleting the entities, so is it not finding them or is it just failing at deleting them?

Its def something wrong with the way I am writing this…

Ah… Looks like these are 2 separate props

Oh does that mean those have to be scanned for and deleted as well?

Ahhh… I got it.

local gates = {
	"p_barier_test_s",
	"prop_sec_barier_01a",
	"prop_sec_barier_02a",
	"prop_sec_barier_02b",
	"prop_sec_barier_03a",
	"prop_sec_barier_03b",
	"prop_sec_barier_04a",
	"prop_sec_barier_04b",
	"prop_sec_barier_base_01",
	"prop_sec_barrier_ld_01a",
	"prop_sec_barrier_ld_02a"
}
Citizen.CreateThread(function()
   while true do
		for a = 1, #gates do
			local player = PlayerId()
			local plyPed = GetPlayerPed(player)
			local plyPos = GetEntityCoords(plyPed, false)
			local gate = GetClosestObjectOfType(plyPos.x, plyPos.y, plyPos.z, 100.0, GetHashKey(gates[a]), 0, 0, 0)
			if gate ~= 0 then
				SetEntityAsMissionEntity(gate, 1, 1)
				DeleteObject(gate)
				SetEntityAsNoLongerNeeded(gate)
			end
		end
	   Citizen.Wait(5000)
   end
end)
2 Likes

Haha, that’s fantastic! In spaces where there’s two close to each other, you can see the other until the script checks for the next one but I imagine that’s a result of trying not to burn up too much resource and don’t have an issue with it showing it for a short time until it gets deleted.

Thanks so much for your help, I can’t tell you how much I appreciate it!

1 Like

It just finds the closest one to you and removes it then the next one next to that would be next in line. You could decrease the Citizen.Wait(timerMS) to make the process faster.

1 Like

I’d like to ask one more question concerning this if I could. How would I look up the prop names if I wanted to expand this script to remove other items? I’ve never dealt with props before and don’t have a resource like I do for the ped list on rage wiki.

https://objects.■■■■■.net/

1 Like

That resource can also be very useful to get objects.

1 Like

Thanks a bunch, downloading now!

     Where do i put??



     local gates = {
"p_barier_test_s",
"prop_sec_barier_01a",
"prop_sec_barier_02a",
"prop_sec_barier_02b",
"prop_sec_barier_03a",
"prop_sec_barier_03b",
"prop_sec_barier_04a",
"prop_sec_barier_04b",
"prop_sec_barier_base_01",
"prop_sec_barrier_ld_01a",
"prop_sec_barrier_ld_02a"

}
Citizen.CreateThread(function()
while true do
for a = 1, #gates do
local player = PlayerId()
local plyPed = GetPlayerPed(player)
local plyPos = GetEntityCoords(plyPed, false)
local gate = GetClosestObjectOfType(plyPos.x, plyPos.y, plyPos.z, 100.0, GetHashKey(gates[a]), 0, 0, 0)
if gate ~= 0 then
SetEntityAsMissionEntity(gate, 1, 1)
DeleteObject(gate)
SetEntityAsNoLongerNeeded(gate)
end
end
Citizen.Wait(5000)
end
end)

I wonder if you could use this for blimps and certains heli’s

Hey I have a question:

Is there a way you can let the barrier open sooner, like they always open when you slightly bump into them but is there a way to make them recognize you instead at like 0,3m distance? I’ve noticed that the barriers at the island function just the way I hope the one’s on mainland would do so too.

Honestly I’m not sure.