SHARE
TWEET

Untitled

a guest Jun 26th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Settings
  2. local color = { r = 255, g = 255, b = 255, alpha = 255 } -- Color of the text
  3. local font = 0 -- Font of the text
  4. local time = 7000 -- Duration of the display of the text : 1000ms = 1sec
  5. local background = {
  6.     enable = true,
  7.     color = { r = 35, g = 35, b = 35, alpha = 220 },
  8. }
  9. local chatMessage = false
  10. local dropShadow = true
  11.  
  12. -- Don't touch
  13. local nbrDisplaying = 1
  14.  
  15. RegisterCommand('me', function(source, args)
  16.     local text = '*' -- edit here if you want to change the language : EN: the person / FR: la personne
  17.     for i = 1,#args do
  18.         text = text .. ' ' .. args[i]
  19.     end
  20.     text = text .. ' *'
  21.     TriggerServerEvent('3dme:shareDisplay', text)
  22. end)
  23.  
  24. RegisterNetEvent('3dme:triggerDisplay')
  25. AddEventHandler('3dme:triggerDisplay', function(text, source)
  26.     local offset = 1 + (nbrDisplaying*0.14)
  27.     Display(GetPlayerFromServerId(source), text, offset)
  28. end)
  29.  
  30. function Display(mePlayer, text, offset)
  31.     local displaying = true
  32.  
  33.     -- Chat message
  34.     if chatMessage then
  35.         local coordsMe = GetEntityCoords(GetPlayerPed(mePlayer), false)
  36.         local coords = GetEntityCoords(PlayerPedId(), false)
  37.         local dist = Vdist2(coordsMe, coords)
  38.         if dist < 2500 then
  39.             TriggerEvent('chat:addMessage', {
  40.                 color = { color.r, color.g, color.b },
  41.                 multiline = true,
  42.                 args = { text}
  43.             })
  44.         end
  45.     end
  46.  
  47.     Citizen.CreateThread(function()
  48.         Wait(time)
  49.         displaying = false
  50.     end)
  51.     Citizen.CreateThread(function()
  52.         nbrDisplaying = nbrDisplaying + 1
  53.         print(nbrDisplaying)
  54.         while displaying do
  55.             Wait(0)
  56.             local coordsMe = GetEntityCoords(GetPlayerPed(mePlayer), false)
  57.             local coords = GetEntityCoords(PlayerPedId(), false)
  58.             local dist = Vdist2(coordsMe, coords)
  59.             if dist < 2500 then
  60.                 DrawText3D(coordsMe['x'], coordsMe['y'], coordsMe['z']+offset, text)
  61.             end
  62.         end
  63.         nbrDisplaying = nbrDisplaying - 1
  64.     end)
  65. end
  66.  
  67. function DrawText3D(x,y,z, text)
  68.     local onScreen,_x,_y = World3dToScreen2d(x,y,z)
  69.     local px,py,pz = table.unpack(GetGameplayCamCoord())
  70.     local dist = GetDistanceBetweenCoords(px,py,pz, x,y,z, 1)
  71.  
  72.     local scale = ((1/dist)*2)*(1/GetGameplayCamFov())*100
  73.  
  74.     if onScreen then
  75.  
  76.         -- Formalize the text
  77.         SetTextColour(color.r, color.g, color.b, color.alpha)
  78.         SetTextScale(0.0*scale, 0.55*scale)
  79.         SetTextFont(font)
  80.         SetTextProportional(1)
  81.         SetTextCentre(true)
  82.         if dropShadow then
  83.             SetTextDropshadow(10, 100, 100, 100, 255)
  84.         end
  85.  
  86.         -- Calculate width and height
  87.         BeginTextCommandWidth("STRING")
  88.         AddTextComponentString(text)
  89.         local height = GetTextScaleHeight(0.55*scale, font)
  90.         local width = EndTextCommandGetWidth(font)
  91.  
  92.         -- Diplay the text
  93.         SetTextEntry("STRING")
  94.         AddTextComponentString(text)
  95.         EndTextCommandDisplayText(_x, _y)
  96.  
  97.         if background.enable then
  98.             DrawRect(_x, _y+scale/45, width, height, background.color.r, background.color.g, background.color.b , background.color.alpha)
  99.         end
  100.     end
  101. 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