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.
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
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?
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…
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)
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!
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.
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.