function Draw3DText(x,y,z,textInput,fontId,scaleX,scaleY)
local px,py,pz=table.unpack(GetGameplayCamCoords())
local dist = GetDistanceBetweenCoords(px,py,pz, x,y,z, 1)
local scale = (1/dist)20
local fov = (1/GetGameplayCamFov())100
local scale = scalefov
SetTextScale(scaleXscale, scaleY*scale)
SetTextFont(fontId)
SetTextProportional(1)
SetTextColour(250, 250, 250, 255) – You can change the text color here
SetTextDropshadow(1, 1, 1, 1, 255)
SetTextEdge(2, 0, 0, 0, 150)
SetTextDropShadow()
SetTextOutline()
SetTextEntry(“STRING”)
SetTextCentre(1)
AddTextComponentString(textInput)
SetDrawOrigin(x,y,z+2, 0)
DrawText(0.0, 0.0)
ClearDrawOrigin()
end
And when I use this it doesn’t work and I don’t see any 3D Text.
Well, it’s working for static coords but whenever I want to Draw 3D Text at NPC position I get nothing:
function setGuardTags(GuardList)
local guardCoords
for key, guard in ipairs(GuardList) do
guardCoords = GetEntityCoords(guard)
Draw3DText( guardCoords.x, guardCoords.y, guardCoords.z -1.400, “Z-10 Prototype”, 4, 0.1, 0.1)
end
end
I tried something like that as well:
function setGuardTags(GuardList)
local guardCoords
for key, guard in ipairs(GuardList) do – we iterate the GuardList
guardCoords = GetEntityCoords(guard)
print(guard)
Draw3DText( guardCoords.x, guardCoords.y, guardCoords.z -1.400, “Z-10 Prototype”, 4, 0.1, 0.1)
end
while true do
Citizen.Wait(0)
if GetDistanceBetweenCoords( guardCoords.x, guardCoords.y, guardCoords.z, GetEntityCoords(GetPlayerPed(-1))) < 10.0 then
Draw3DText( guardCoords.x, guardCoords.y, guardCoords.z -1.400, “Z-10 Prototype”, 4, 0.1, 0.1)
end
end
end
function setGuardTags(GuardList)
local guardCoords
for key, guard in ipairs(GuardList) do – we iterate the GuardList
guardCoords = GetEntityCoords(guard)
while true do
Citizen.Wait(0)
if GetDistanceBetweenCoords( guardCoords.x, guardCoords.y, guardCoords.z, GetEntityCoords(GetPlayerPed(-1))) < 10.0 then
Draw3DText( guardCoords.x, guardCoords.y, guardCoords.z -1.400 -1.000, “Z-10 Prototype”, 4, 0.1, 0.1)
end
end
end
end
Okay, any ideas why it only creates 3d text for first NPC?
local table = {
{x=00.00, y=000.00, z=00.00}, -- XYZ1
}
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
for k in pairs(table) do
DrawMarker(1, table[k].x, table[k].y, table[k].z, 0, 0, 0, 0, 0, 0, 4.501, 4.5001, 0.5001, 0, 0, 255, 200, 0, 0, 0, 0)
end
end
end)
Okay, thanks for the tips. Can I make a table for guardCoords and then whenever I call guardCoords = GetEntityCoords(guard) it’s gonna add new coord to the table?