Hey there,
I’m new here and started out yesterday and ran into a weird problem when drawing many blips from an array and found a solution right away. This is for people who might run into the same problem.
When creating/drawing blips with a function like this
Citizen.CreateThread(function()
for _, info in pairs(blips) do
info.blip = AddBlipForCoord(info.x, info.y, info.z)
SetBlipSprite(info.blip, info.id)
SetBlipDisplay(info.blip, 4)
SetBlipScale(info.blip, 0.8)
SetBlipColour(info.blip, info.colour)
SetBlipAsShortRange(info.blip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString(info.title)
EndTextCommandSetBlipName(info.blip)
end
end)
and a list like this, that has many entries (mine has over 200)
local blips = {
{title="ExampleTitle", colour=5, id=466, x=2911.85, y=4485.54, z=47.71},
--...
--total number of entries > 200
}
you might run into the same problem.
What happened was that that for the first 160 blips, the title (later displayed in the map legend) was designated correctly, but for the next/last ~80 blips it would not, or only partially draw the title, which resulted in the blips being labeled as something like “eTitle” instead of “ExampleTitle”.
I solved this by adding a Wait(1), because I was suspecting that somehow the function couldn’t process the title designation part fast enough.
Working version looks like this:
Citizen.CreateThread(function()
for _, info in pairs(blips) do
info.blip = AddBlipForCoord(info.x, info.y, info.z)
SetBlipSprite(info.blip, info.id)
SetBlipDisplay(info.blip, 4)
SetBlipScale(info.blip, 0.8)
SetBlipColour(info.blip, info.colour)
SetBlipAsShortRange(info.blip, true)
BeginTextCommandSetBlipName("STRING")
Citizen.Wait(1) -- this line solves the problem!
AddTextComponentString(info.title)
EndTextCommandSetBlipName(info.blip)
end
end)
It has the side effect that it takes about half a second to draw all the blips, a worthy tradeoff imo.
So, if you have very many blips and they are labeled wrong, or missing part of it’s title, being truncated, you might find your solution here.
My experience tells me that the problem might even lie somewhere else, but this works, so I hope it forks for you as well.
Cheers