Skip to content

Commit 1a6c036

Browse files
committed
3d text scaling
the "Draw3DText" function now has 5 parameters and the 4th one is the scale factor. Please check commit
1 parent 9161c4d commit 1a6c036

File tree

1 file changed

+22
-19
lines changed
  • FiveM - All About Vectors with Blips and 3D Text/vectors

1 file changed

+22
-19
lines changed

FiveM - All About Vectors with Blips and 3D Text/vectors/client.lua

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,37 @@ local blip = AddBlipForCoord(v2.x, v2.y)
99
-- sets the blip id (which icon will be desplayed)
1010
-- https://runtime.fivem.net/doc/natives/#_0xDF735600A4696DAF
1111
SetBlipSprite(blip, 364)
12-
-- sets where the blip to be shown on both the minimap and the menu map
12+
-- sets where the blip to be shown on both the minimap and the menu map
1313
-- https://runtime.fivem.net/doc/natives/#_0x9029B2F3DA924928
1414
SetBlipDisplay(blip, 6)
1515
-- how big the blip will be
1616
-- https://runtime.fivem.net/doc/natives/#_0xD38744167B2FA257
1717
SetBlipScale(blip, 0.9)
1818
-- blip entry type
19-
BeginTextCommandSetBlipName("STRING");
19+
BeginTextCommandSetBlipName("STRING")
2020
-- The title of the blip
2121
AddTextComponentString("Do not enter")
2222
EndTextCommandSetBlipName(blip)
2323

24-
25-
RegisterCommand("tp", function(source, args)
26-
-- https://runtime.fivem.net/doc/natives/#_0x06843DA7060A026B
27-
SetEntityCoords(PlayerPedId(), v3.x, v3.y, v3.z, true, true, true, false)
28-
SetEntityHeading(PlayerPedId(), v3.w)
29-
end)
30-
24+
RegisterCommand(
25+
"tp",
26+
function(source, args)
27+
-- https://runtime.fivem.net/doc/natives/#_0x06843DA7060A026B
28+
SetEntityCoords(PlayerPedId(), v3.x, v3.y, v3.z, true, true, true, false)
29+
SetEntityHeading(PlayerPedId(), v3.w)
30+
end
31+
)
3132

3233
-- forked from https://forum.fivem.net/t/3d-text-above-cyrcle-marker-trigger/161363/7 user: MixZira
33-
function Draw3DText(x, y, z, text)
34+
function Draw3DText(x, y, z, scl_factor, text)
3435
local onScreen, _x, _y = World3dToScreen2d(x, y, z)
3536
local p = GetGameplayCamCoords()
3637
local distance = GetDistanceBetweenCoords(p.x, p.y, p.z, x, y, z, 1)
3738
local scale = (1 / distance) * 2
3839
local fov = (1 / GetGameplayCamFov()) * 100
39-
local scale = scale * fov
40+
local scale = scale * fov * scl_factor
4041
if onScreen then
41-
SetTextScale(0.0, 0.35)
42+
SetTextScale(0.0, scale)
4243
SetTextFont(0)
4344
SetTextProportional(1)
4445
SetTextColour(255, 255, 255, 255)
@@ -49,19 +50,21 @@ function Draw3DText(x, y, z, text)
4950
SetTextEntry("STRING")
5051
SetTextCentre(1)
5152
AddTextComponentString(text)
52-
DrawText(_x,_y)
53+
DrawText(_x, _y)
5354
end
5455
end
5556

5657
local distance_until_text_disappears = 5000
5758

58-
Citizen.CreateThread(function()
59-
while true do
60-
Citizen.Wait(0)
61-
-- the "Vdist2" native checks how far two vectors are from another.
59+
Citizen.CreateThread(
60+
function()
61+
while true do
62+
Citizen.Wait(0)
63+
-- the "Vdist2" native checks how far two vectors are from another.
6264
-- https://runtime.fivem.net/doc/natives/#_0xB7A628320EFF8E47
6365
if Vdist2(GetEntityCoords(PlayerPedId(), false), v1) < distance_until_text_disappears then
64-
Draw3DText(v1.x,v1.y,v1.z, "test")
66+
Draw3DText(v1.x, v1.y, v1.z, 1.5, "test")
6567
end
68+
end
6669
end
67-
end)
70+
)

0 commit comments

Comments
 (0)