Closed BurnhamR closed 3 months ago
Clip of previous code
Config = {
language = 'en',
color = { r = 230, g = 230, b = 230, a = 255 }, -- Text color
font = 0, -- Text font
time = 5000, -- Duration to display the text (in ms)
scale = 0.5, -- Text scale
dist = 250, -- Min. distance to draw
}
local function draw3dText(coords, text)
local camCoords = GetGameplayCamCoord()
local dist = #(coords - camCoords)
-- Experimental math to scale the text down
local scale = 200 / (GetGameplayCamFov() * dist)
-- Format the text
SetTextColour(c.color.r, c.color.g, c.color.b, c.color.a)
SetTextScale(0.0, c.scale * scale)
SetTextFont(c.font)
SetTextDropshadow(0, 0, 0, 0, 55)
SetTextDropShadow()
SetTextCentre(true)
-- Diplay the text
BeginTextCommandDisplayText("STRING")
AddTextComponentSubstringPlayerName(text)
SetDrawOrigin(coords, 0)
EndTextCommandDisplayText(0.0, 0.0)
ClearDrawOrigin()
end
-- @desc Display the text above the head of a ped
-- @param ped the target ped
-- @param text the text to display
local function displayText(ped, text)
local playerPed = PlayerPedId()
local playerPos = GetEntityCoords(playerPed)
local targetPos = GetEntityCoords(ped)
local dist = #(playerPos - targetPos)
local los = HasEntityClearLosToEntity(playerPed, ped, 17)
if dist <= c.dist and los then
local exists = peds[ped] ~= nil
peds[ped] = {
time = GetGameTimer() + c.time,
text = text
}
if not exists then
local display = true
while display do
Wait(0)
local pos = GetOffsetFromEntityInWorldCoords(ped, 0.0, 0.0, 1.0)
draw3dText(pos, peds[ped].text)
display = GetGameTimer() <= peds[ped].time
end
peds[ped] = nil
end
end
end
I have implemented this.
Feature Request
Feature Description
We need too add 3d text above the player how we previously had it.
Problem or Reason
This allows it to be easier for player to see what player ran
/me
Additional Context
Benefits
See Reason.