Hi there,
So I recently tried to make an image of a GPS only be visible when a player is in a vehicle.
client.lua
Citizen.CreateThread(function()
while true do
Citizen.Wait(1)
if IsPedInAnyVehicle(PlayerPedId(), true) then
display = true
TriggerEvent('logo:display', true)
elseif not IsPedInAnyVehicle(PlayerPedId(), true) then
display = false
TriggerEvent('logo:display', false)
end
end
end)
What I’m trying to achieve
When a player is in a vehicle, they see the mini map and a GPS image.
When a player is walking, the mini-map and GPS image are hidden.
Citizen.CreateThread(function()
while true do
Citizen.Wait(1)
if IsPedInAnyVehicle(PlayerPedId(), true) then
display = true
TriggerEvent('logo:display', true)
else
display = false
TriggerEvent('logo:display', false)
end
end
end)
I updated the code yet the image still remains and I’m not too sure why.
AddEventHandler('onClientMapStart', function()
Citizen.CreateThread(function()
local display = false
local startTime = GetGameTimer()
local delay = 70000 -- ms
Citizen.CreateThread(function()
while true do
Citizen.Wait(1)
if IsPedInAnyVehicle(PlayerPedId(), true) then
display = true
TriggerEvent('logo:display', true)
else
display = false
TriggerEvent('logo:display', false)
end
end
end)
local IsPaused = false
Citizen.CreateThread(function()
while true do
Citizen.Wait(1)
if IsPauseMenuActive() and not IsPaused then
IsPaused = true
TriggerEvent('logo:display', false)
elseif not IsPauseMenuActive() and IsPaused then
IsPaused = false
TriggerEvent('logo:display', true)
end
end
end)