Advertisement
Stivicx

Disclaimer

Oct 9th, 2017
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.94 KB | None | 0 0
  1. local hasAlreadyEnteredMarker = false
  2. local isInPOSTERMarker            = false
  3. local display = true
  4. local menuIsShowed            = false
  5.  
  6. ESX = nil
  7.  
  8. Citizen.CreateThread(function()
  9.     while ESX == nil do
  10.         TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
  11.         Citizen.Wait(0)
  12.     end
  13. end)
  14.  
  15. AddEventHandler('onClientMapStart', function()
  16.   Citizen.CreateThread(function()
  17.     local startTime = GetGameTimer()
  18.     local delay = 60000 -- ms
  19.  
  20.     TriggerEvent('disclaimer:display', true)
  21.  
  22.     while display do
  23.       Citizen.Wait(1)
  24.       ShowInfo('~y~Lire attentivement.~w~ Appuyez sur ~INPUT_CONTEXT~ pour fermer.', 0)
  25.       if (GetTimeDifference(GetGameTimer(), startTime) > delay) then
  26.         display = false
  27.         TriggerEvent('disclaimer:display', false)
  28.       end
  29.       if (IsControlJustPressed(1, 51)) then
  30.         display = false
  31.         TriggerEvent('disclaimer:display', false)
  32.       end
  33.     end
  34.   end)
  35. end)
  36.  
  37. RegisterNetEvent('disclaimer:display')
  38. AddEventHandler('disclaimer:display', function(value)
  39.   SetNuiFocus(false)
  40.   menuIsShowed = false
  41.   SendNUIMessage({
  42.     type = "disclaimer",
  43.     display = value
  44.   })
  45. end)
  46.  
  47. function ShowInfo(text, state)
  48.   SetTextComponentFormat("STRING")
  49.   AddTextComponentString(text)
  50.   DisplayHelpTextFromStringLabel(0, state, 0, -1)
  51. end
  52.  
  53. -- Render markers
  54. Citizen.CreateThread(function()
  55.     while true do      
  56.         Wait(0)    
  57.         local coords = GetEntityCoords(GetPlayerPed(-1))       
  58.         for i=1, #Config.POSTERS, 1 do
  59.             if(GetDistanceBetweenCoords(coords, Config.POSTERS[i].x, Config.POSTERS[i].y, Config.POSTERS[i].z, true) < Config.DrawDistance) then
  60.                 DrawMarker(Config.MarkerType, Config.POSTERS[i].x, Config.POSTERS[i].y, Config.POSTERS[i].z - Config.ZDiff, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.ZoneSize.x, Config.ZoneSize.y, Config.ZoneSize.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, false, false, false)
  61.             end
  62.         end
  63.     end
  64. end)
  65.  
  66. -- Activate menu when player is inside marker
  67. Citizen.CreateThread(function()
  68.     while true do      
  69.         Wait(0)    
  70.         local coords = GetEntityCoords(GetPlayerPed(-1))
  71.         isInPOSTERMarker = false
  72.         for i=1, #Config.POSTERS, 1 do
  73.             if(GetDistanceBetweenCoords(coords, Config.POSTERS[i].x, Config.POSTERS[i].y, Config.POSTERS[i].z, true) < Config.ZoneSize.x / 2) then
  74.                 isInPOSTERMarker = true
  75.                 display = false
  76.                 SetTextComponentFormat('STRING')
  77.                 AddTextComponentString(_U('press_e_atm'))
  78.                 DisplayHelpTextFromStringLabel(0, 0, 1, -1)
  79.             end
  80.         end
  81.         if isInPOSTERMarker and not hasAlreadyEnteredMarker then
  82.             hasAlreadyEnteredMarker = true
  83.                 menuIsShowed = false
  84.                 SendNUIMessage({
  85.                     type = "disclaimer",
  86.                     display = value
  87.             })
  88.         end
  89.     end
  90. end)
  91.  
  92. -- Menu interactions
  93. Citizen.CreateThread(function()
  94.     while true do
  95.         Wait(0)
  96.           if IsControlJustReleased(0, 38) and isInPOSTERMarker then
  97.                 menuIsShowed = true
  98.                 TriggerEvent('disclaimer:display', false)
  99.         end
  100.     end
  101. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement