Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local hasAlreadyEnteredMarker = false
- local isInPOSTERMarker = false
- local display = true
- local menuIsShowed = false
- ESX = nil
- Citizen.CreateThread(function()
- while ESX == nil do
- TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
- Citizen.Wait(0)
- end
- end)
- AddEventHandler('onClientMapStart', function()
- Citizen.CreateThread(function()
- local startTime = GetGameTimer()
- local delay = 60000 -- ms
- TriggerEvent('disclaimer:display', true)
- while display do
- Citizen.Wait(1)
- ShowInfo('~y~Lire attentivement.~w~ Appuyez sur ~INPUT_CONTEXT~ pour fermer.', 0)
- if (GetTimeDifference(GetGameTimer(), startTime) > delay) then
- display = false
- TriggerEvent('disclaimer:display', false)
- end
- if (IsControlJustPressed(1, 51)) then
- display = false
- TriggerEvent('disclaimer:display', false)
- end
- end
- end)
- end)
- RegisterNetEvent('disclaimer:display')
- AddEventHandler('disclaimer:display', function(value)
- SetNuiFocus(false)
- menuIsShowed = false
- SendNUIMessage({
- type = "disclaimer",
- display = value
- })
- end)
- function ShowInfo(text, state)
- SetTextComponentFormat("STRING")
- AddTextComponentString(text)
- DisplayHelpTextFromStringLabel(0, state, 0, -1)
- end
- -- Render markers
- Citizen.CreateThread(function()
- while true do
- Wait(0)
- local coords = GetEntityCoords(GetPlayerPed(-1))
- for i=1, #Config.POSTERS, 1 do
- if(GetDistanceBetweenCoords(coords, Config.POSTERS[i].x, Config.POSTERS[i].y, Config.POSTERS[i].z, true) < Config.DrawDistance) then
- 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)
- end
- end
- end
- end)
- -- Activate menu when player is inside marker
- Citizen.CreateThread(function()
- while true do
- Wait(0)
- local coords = GetEntityCoords(GetPlayerPed(-1))
- isInPOSTERMarker = false
- for i=1, #Config.POSTERS, 1 do
- if(GetDistanceBetweenCoords(coords, Config.POSTERS[i].x, Config.POSTERS[i].y, Config.POSTERS[i].z, true) < Config.ZoneSize.x / 2) then
- isInPOSTERMarker = true
- display = false
- SetTextComponentFormat('STRING')
- AddTextComponentString(_U('press_e_atm'))
- DisplayHelpTextFromStringLabel(0, 0, 1, -1)
- end
- end
- if isInPOSTERMarker and not hasAlreadyEnteredMarker then
- hasAlreadyEnteredMarker = true
- menuIsShowed = false
- SendNUIMessage({
- type = "disclaimer",
- display = value
- })
- end
- end
- end)
- -- Menu interactions
- Citizen.CreateThread(function()
- while true do
- Wait(0)
- if IsControlJustReleased(0, 38) and isInPOSTERMarker then
- menuIsShowed = true
- TriggerEvent('disclaimer:display', false)
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement