Error with Drawtext

New to Lua and not sure why this is throwing a error.

RegisterCommand('findBin', function()
    local pos = GetEntityCoords(GetPlayerPed(-1), false)
    local nearestbin = GetClosestObjectOfType(pos.x, pos.y, pos.z, 5.0, GetHashKey("prop_dumpster_01a"), false,false, false)
    local binpos = GetEntityCoords(nearestbin)
    while true do
        Citizen.Wait(0)
        DrawMarker(27, binpos.x, binpos.y, binpos.z + .5, 0, 0, 0, 0, 0, 0, 3.001, 3.0001, 1.0001, 255, 0, 0, 200, 0, 0, 0, 0)
       -- ESX.Game.Utils.DrawText3D(binpos, "[~g~E~s~] to collect Bag", 0.50)
    end
end)

If i have the DrawText commented out the Marker draws just as expected. If i uncommet the DrawText to get marker and text - the marker flashes for a sec and disappears. can’t figure out why the DrawText is throwing a error.

Any suggestions would be appericated.

SpikE

Please post the error :slight_smile:

Sorry worded that poorly. It does not give me a error in the console at all - the only thing that happens is the Maker flashes and then stops… but if i take just the DrawText line out the marker stays.

It must have been something very small that i was missing. Because I started over from scratch and it seems to be able to draw both the marker and text now. If anyone see’s what the small part i missed was would love to figure it out so i can look for it next time.

SpikE

Markers need to be drawn every tick. I’d suggest making a thread and having an if statement in that :slight_smile:

Since it was in a While true do - loop shoudl have been drawing every tick… as i said without the draw text the marker worked fine… was something wrong with the drawtext line … starting over fixed it for me.

Not sure how to mark this subject closed since i figured out a fix.

SpikE

Ohhh. My bad, thought it was the marker. Try call a native drawtext function. Maybe its ESX causing the issue.