I was looking for a 3D text function but I couldn’t find one. So here’s my function:
local function Draw3DText(textInput, x, y, z, fontId, scl_factor, cam)
local onScreen, px, py = GetScreenCoordFromWorldCoord(x, y, z)
if onScreen then
local camExist = DoesCamExist(cam)
local camCoords = camExist and GetCamCoord(cam) or GetGameplayCamCoords()
local dist = #(vec3(x, y, z) - camCoords)
local scale1 = (1/dist)*20
local fov = (1/(camExist and GetCamFov(cam) or GetGameplayCamFov()))*100
local scale = scale1*fov*scl_factor
SetTextCentre(1)
SetTextScale(scale, scale)
SetTextFontForCurrentCommand(fontId)
SetTextColor(255, 255, 255, 150)
SetTextDropshadow(1, 1, 1, 0, 255)
DisplayText(CreateVarString(10, "LITERAL_STRING", textInput), px, py)
end
end
You need to put it inside a while loop:
while true do
Wait(0)
local coords = GetEntityCoords(PlayerPedid())
Draw3DText("My text", coords.x, coords.y, coords.z + 0.5, 0, 0.05, 0)
end