Hey all, I’m currently developing a water management script for FD’s to use to have a little bit of a more realistic experience, by managing the water levels on their trucks. At the moment I’m trying to work out the best way to identify a fire hydrant in front of or around the player. Currently I’m having little success using a ray trace, which is this code:
Current Non-Functioning Ray Tracing Code
Citizen.CreateThread(function()
while true do
if findHydrant == true then
local pos = GetEntityCoords(GetPlayerPed(-1))
local entityWorld = GetOffsetFromEntityInWorldCoords(GetPlayerPed(-1), 0.0, 3.0, -1.0)
DrawLine(pos.x, pos.y, pos.z, entityWorld.x, entityWorld.y, entityWorld.z, 255, 0, 0, 255) --only for debugging purposes
local rayHandle = CastRayPointToPoint(pos.x, pos.y, pos.z, entityWorld.x, entityWorld.y, entityWorld.z, 10, GetPlayerPed(-1), 0)
local _, _, _, _, hydrantHandle = GetRaycastResult(rayHandle)
print(hydrantHandle) -- only for debug, at the moment is only printing 0
for i,v in ipairs(hydrants) do
if hydrantHandle == hydrants[i] then
activeHydrant = hydrantHandle
hydrantLocation = GetEntityCoords(hydrantHandle)
end
end
end
Citizen.Wait(0)
end
end)
The Ray tracing works to find a fire engine, but I’m struggling to get it to work for the hydrants.
The only other method of finding these hydrants that I can think of is just using a set of coordinates in a table, where the coordinates mark hydrants around the map…the only problem is there’s probably (easily) 200+ hydrants around. Which is a lot of data and finding to do. So I’d like to avoid that if possible.
I would appreciate any assistance or suggestions at all!