Hi ! I would like to point out that my English is not so good since I am basic French.
This is my question.
I would like to know how could we make a command to display the IDs of other players around, but that doing the same command again removes them? I added a script for the GSR Test, but we need the IDs of the people around. In RP it doesn’t really ask ‘What is your ID’ so we would like to set up a command to let us know more quickly. Thank you!
Something like this should do it
local playerDistances = {}
local toggle = false
RegisterCommand("toggleid", function(source, args, raw)
if toggle then
toggle = false
else
toggle = true
end
end)
Citizen.CreateThread(function()
Wait(50)
while true do
for id = 0, 255 do
if NetworkIsPlayerActive(id) then
if GetPlayerPed(id) ~= GetPlayerPed(-1) then
if (playerDistances[id] < 20) then
x2, y2, z2 = table.unpack(GetEntityCoords(GetPlayerPed(id), true))
if NetworkIsPlayerTalking(id) and toggle == true then
DrawText3D(x2, y2, z2+1, GetPlayerServerId(id), 247, 124, 24)
elseif toggle == true then
DrawText3D(x2, y2, z2+1, GetPlayerServerId(id), 255, 255, 255)
end
end
end
end
end
Citizen.Wait(0)
end
end)
Citizen.CreateThread(function()
while true do
for id = 0, 255 do
if GetPlayerPed(id) ~= GetPlayerPed(-1) then
x1, y1, z1 = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
x2, y2, z2 = table.unpack(GetEntityCoords(GetPlayerPed(id), true))
distance = math.floor(GetDistanceBetweenCoords(x1, y1, z1, x2, y2, z2, true))
playerDistances[id] = distance
end
end
Citizen.Wait(1000)
end
end)
SCRIPT ERROR: @chat/client/commands.lua:105: attempt to call a nil value (global ‘DrawText3D’)
I dont know what problem is it
ahh, i forgot to include the drawtext3d function, add this to the code
function DrawText3D(x,y,z, text, r,g,b)
local onScreen,_x,_y=World3dToScreen2d(x,y,z)
local px,py,pz=table.unpack(GetGameplayCamCoords())
local dist = GetDistanceBetweenCoords(px,py,pz, x,y,z, 1)
local scale = (2/dist)*2
local fov = (1/GetGameplayCamFov())*100
local scale = scale*fov
if onScreen then
SetTextScale(0.0*scale, 0.55*scale)
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