How to remove parkinglot swing barriers

Hi there guys!

I’m talking about those red and white swing gates that everyone just drives through, breaking them in the process. Everyone on the server hates them because they damage their car and want them gone from the parking lot at Legion square that we use for the car garage.

Is there a way to remove those two gates?

Thanks for your time!

I am not really sure if they are “Doors” in-game. Maybe you can make a script to set their angle to all the way open?

Honestly just throwing out ideas.

1 Like

I appreciate even educated guesses at this point. My searches haven’t found a single result. I’m at a loss currently.

Actually… I wonder if you made a script to delete the entity when the player gets close? Just so if it respawns it will get removed again?

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"}
Citizen.CreateThread(function()
   while true do
		local player = PlayerId()
		local plyPed = GetPlayerPed(player)
		local plyPos = GetEntityCoords(plyPed, false)

		for a = 1, #gates do
			local gate = GetClosestObjectOfType(plyPos.x, plyPos.y, plyPos.z, 100.0, GetHashKey(gates[a]), 1, 1, 1)
			if gate ~= 0 or gate ~= nil then
				DeleteEntity(gate)
			end
		end
	   Citizen.Wait(1000)
   end
end)

I have not tested as I just free wrote it… So no idea if it works

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!