Could someone help me out with some lua. I’m literally new to it. At the moment if I hold down the keybind it will show the player ID then hide it when I release key.
-
I’m trying to make it where the ID is showing by default.
Press once to turn off or press once to turn back on. A toggle instead of a hold. Basically -
Secondly, if turned on, when someone is talking it changes the colour of the drawtext3d. Which at the moment works kind of but it flickers between the two colors when the player is talking.
Perhaps an alternative to this would be if I just add an arrow where the ID would be or maybe some … after the ID to signify someone is talking. Hmm. Ideas?
Thanks coding geniuses out there. You are the GOAT.
local disPlayerNames = 5
local playerDistances = {}
local function DrawText3D(position, text, r,g,b)
local onScreen,_x,_y=World3dToScreen2d(position.x,position.y,position.z+1)
local dist = #(GetGameplayCamCoords()-position)
local scale = (1/dist)*2
local fov = (1/GetGameplayCamFov())*100
local scale = scale*fov
if onScreen then
if not useCustomScale then
SetTextScale(0.0*scale, 0.45*scale)
else
SetTextScale(0.0*scale, customScale)
end
SetTextFont(0)
SetTextProportional(1)
SetTextColour(r, g, b, 255)
SetTextDropshadow(0, 0, 0, 0, 255)
SetTextEdge(2, 0, 0, 0, 150)
SetTextDropShadow()
SetTextOutline()
SetTextEntry("STRING")
SetTextCentre(1)
AddTextComponentString(text)
DrawText(_x,_y)
end
end
local show = false
RegisterCommand("+showids", function()
show = true
CreateThread(function()
Wait(500)
for _, id in ipairs(GetActivePlayers()) do
local targetPed = GetPlayerPed(id)
if targetPed ~= PlayerPedId() then
if playerDistances[id] then
if playerDistances[id] < disPlayerNames then
local targetPedCords = GetEntityCoords(targetPed)
if NetworkIsPlayerTalking(id) then
DrawText3D(targetPedCords, GetPlayerServerId(id), 102,155,105)
end
end
end
end
end
Citizen.Wait(0)
end)
end)
RegisterCommand("-showids", function()
show = false
end)
RegisterKeyMapping("+showids", "(Hold) To Show ID's Over Head", "keyboard", "i")
Citizen.CreateThread(function()
while true do
local playerPed = PlayerPedId()
local playerCoords = GetEntityCoords(playerPed)
for _, id in ipairs(GetActivePlayers()) do
local targetPed = GetPlayerPed(id)
if targetPed ~= playerPed then
local distance = #(playerCoords-GetEntityCoords(targetPed))
playerDistances[id] = distance
end
end
Wait(1000)
end
end)