Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. local color = {r = 74, g = 39, b = 216, alpha = 255} -- Color of the text
  2. local font = 0 -- Font of the text
  3. local time = 7000 -- Duration of the display of the text : 1000ms = 1sec
  4. local nbrDisplaying = 1
  5.  
  6. RegisterCommand('me', function(source, args)
  7. local text = '* the person' -- edit here if you want to change the language : EN: the person / FR: la personne
  8. for i = 1,#args do
  9. text = text .. ' ' .. args[i]
  10. end
  11. text = text .. ' *'
  12. TriggerServerEvent('3dme:shareDisplay', text)
  13. end)
  14.  
  15. RegisterNetEvent('3dme:triggerDisplay')
  16. AddEventHandler('3dme:triggerDisplay', function(text, source)
  17. local offset = 1 + (nbrDisplaying*0.14)
  18. Display(GetPlayerFromServerId(source), text, offset)
  19. end)
  20.  
  21. function Display(mePlayer, text, offset)
  22. local displaying = true
  23. Citizen.CreateThread(function()
  24. Wait(time)
  25. displaying = false
  26. end)
  27. Citizen.CreateThread(function()
  28. nbrDisplaying = nbrDisplaying + 1
  29. print(nbrDisplaying)
  30. while displaying do
  31. Wait(0)
  32. local coordsMe = GetEntityCoords(GetPlayerPed(mePlayer), false)
  33. local coords = GetEntityCoords(PlayerPedId(), false)
  34. local dist = GetDistanceBetweenCoords(coordsMe['x'], coordsMe['y'], coordsMe['z'], coords['x'], coords['y'], coords['z'], true)
  35. if dist < 50 then
  36. DrawText3D(coordsMe['x'], coordsMe['y'], coordsMe['z']+offset, text)
  37. end
  38. end
  39. nbrDisplaying = nbrDisplaying - 1
  40. end)
  41. end
  42.  
  43. function DrawText3D(x,y,z, text)
  44. local onScreen,_x,_y = World3dToScreen2d(x,y,z)
  45. local px,py,pz = table.unpack(GetGameplayCamCoord())
  46. local dist = GetDistanceBetweenCoords(px,py,pz, x,y,z, 1)
  47.  
  48. local scale = (1/dist)*2
  49. local fov = (1/GetGameplayCamFov())*100
  50. local scale = scale*fov
  51.  
  52. if onScreen then
  53. SetTextScale(0.0*scale, 0.55*scale)
  54. SetTextFont(font)
  55. SetTextProportional(1)
  56. SetTextColour(color.r, color.g, color.b, color.alpha)
  57. SetTextDropshadow(0, 0, 0, 0, 255)
  58. SetTextEdge(2, 0, 0, 0, 150)
  59. --SetTextDropShadow()
  60. --SetTextOutline()
  61. SetTextEntry("STRING")
  62. SetTextCentre(true)
  63. AddTextComponentString(text)
  64. EndTextCommandDisplayText(_x, _y)
  65. end
  66. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement