Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
9,006
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.86 KB | None | 0 0
  1. local disPlayerNames = 5
  2.  
  3. playerDistances = {}
  4.  
  5.  
  6. Citizen.CreateThread(function()
  7.     while true do
  8.         for id = 0, 64 do
  9.             if NetworkIsPlayerActive(id) then
  10.                 if GetPlayerPed(id) ~= GetPlayerPed(-1) then
  11.                     if (playerDistances[id] < disPlayerNames) then
  12.                         x2, y2, z2 = table.unpack(GetEntityCoords(GetPlayerPed(id), true))
  13.                         if NetworkIsPlayerTalking(id) then
  14.                             DrawText3D(x2, y2, z2+1, GetPlayerServerId(id), 247,124,24)
  15.                         else
  16.                             DrawText3D(x2, y2, z2+1, GetPlayerServerId(id), 255,255,255)
  17.                         end
  18.                     end  
  19.                 end
  20.             end
  21.         end
  22.         Citizen.Wait(0)
  23.     end
  24. end)
  25.  
  26. Citizen.CreateThread(function()
  27.     while true do
  28.         for id = 0, 64 do
  29.             if GetPlayerPed(id) ~= GetPlayerPed(-1) then
  30.                 x1, y1, z1 = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
  31.                 x2, y2, z2 = table.unpack(GetEntityCoords(GetPlayerPed(id), true))
  32.                 distance = math.floor(GetDistanceBetweenCoords(x1,  y1,  z1,  x2,  y2,  z2,  true))
  33.                 playerDistances[id] = distance
  34.             end
  35.         end
  36.         Citizen.Wait(1000)
  37.     end
  38. end)
  39.  
  40.  
  41. function DrawText3D(x,y,z, text, r,g,b)
  42.     local onScreen,_x,_y=World3dToScreen2d(x,y,z)
  43.     local px,py,pz=table.unpack(GetGameplayCamCoords())
  44.     local dist = GetDistanceBetweenCoords(px,py,pz, x,y,z, 1)
  45.  
  46.     local scale = (1/dist)*2
  47.     local fov = (1/GetGameplayCamFov())*100
  48.     local scale = scale*fov
  49.    
  50.     if onScreen then
  51.         SetTextScale(0.0*scale, 0.55*scale)
  52.         SetTextFont(0)
  53.         SetTextProportional(1)
  54.         SetTextColour(r, g, b, 255)
  55.         SetTextDropshadow(0, 0, 0, 0, 255)
  56.         SetTextEdge(2, 0, 0, 0, 150)
  57.         SetTextDropShadow()
  58.         SetTextOutline()
  59.         SetTextEntry("STRING")
  60.         SetTextCentre(1)
  61.         AddTextComponentString(text)
  62.         DrawText(_x,_y)
  63.     end
  64. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement