SHARE
TWEET

Untitled

a guest Apr 23rd, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --
  2. --
  3. --
  4. -- 3d /me
  5. --
  6. --
  7. --
  8. local color = {r = 255, g = 255, b = 255, alpha = 255} -- Color of the text
  9. local font = 0 -- Font of the text
  10. local time = 7000 -- Duration of the display of the text : 1000ms = 1sec
  11. local nbrDisplaying = 1
  12.  
  13. RegisterCommand('me', function(source, args)
  14.     local text = '* '
  15.     for i = 1,#args do
  16.         text = text .. ' ' .. args[i]
  17.     end
  18.     text = text .. ' *'
  19.     TriggerServerEvent('3dme:shareDisplay', text)
  20. end)
  21.  
  22. RegisterNetEvent('3dme:triggerDisplay')
  23. AddEventHandler('3dme:triggerDisplay', function(text, source)
  24.     local offset = 1 + (nbrDisplaying*0.14)
  25.     Display(GetPlayerFromServerId(source), text, offset)
  26. end)
  27.  
  28. function Display(mePlayer, text, offset)
  29.     local displaying = true
  30.     Citizen.CreateThread(function()
  31.         Wait(time)
  32.         displaying = false
  33.     end)
  34.     Citizen.CreateThread(function()
  35.         nbrDisplaying = nbrDisplaying + 1
  36.         print(nbrDisplaying)
  37.         while displaying do
  38.             Wait(0)
  39.             local coordsMe = GetEntityCoords(GetPlayerPed(mePlayer), false)
  40.             local coords = GetEntityCoords(PlayerPedId(), false)
  41.             local dist = GetDistanceBetweenCoords(coordsMe['x'], coordsMe['y'], coordsMe['z'], coords['x'], coords['y'], coords['z'], true)
  42.             if dist < 50 then
  43.                 DrawText3D(coordsMe['x'], coordsMe['y'], coordsMe['z']+offset, text)
  44.             end
  45.         end
  46.         nbrDisplaying = nbrDisplaying - 1
  47.     end)
  48. end
  49.  
  50. function DrawText3D(x,y,z, text)
  51.     local onScreen,_x,_y = World3dToScreen2d(x,y,z)
  52.     local px,py,pz = table.unpack(GetGameplayCamCoord())
  53.     local dist = GetDistanceBetweenCoords(px,py,pz, x,y,z, 1)
  54.  
  55.     local scale = (1/dist)*2
  56.     local fov = (1/GetGameplayCamFov())*100
  57.     local scale = scale*fov
  58.  
  59.     if onScreen then
  60.         SetTextScale(0.0*scale, 0.55*scale)
  61.         SetTextFont(font)
  62.         SetTextProportional(1)
  63.         SetTextColour(color.r, color.g, color.b, color.alpha)
  64.         SetTextDropshadow(0, 0, 0, 0, 255)
  65.         SetTextEdge(2, 0, 0, 0, 150)
  66.         --SetTextDropShadow()
  67.         --SetTextOutline()
  68.         SetTextEntry("STRING")
  69.         SetTextCentre(true)
  70.         AddTextComponentString(text)
  71.         EndTextCommandDisplayText(_x, _y)
  72.     end
  73. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top