LUA - Icon not hiding on opening Map

Hi, there I am new here and hope this is the right place to ask.

I want to create a simple script in lua for FiveM to show my Icon on screen and display the PlayerID.
So far it works, but I can’t hide the icon when showing the Game-Map.

Maybe I did some stupid mistakes in my code. Hope someone has time to help me out on this to understand my mistake:

client.lua

Citizen.CreateThread(function()
    Wait(50)
	  local display = true


    while true do
	
			if (IsBigmapActive()==true) then
			
				display = false
				TriggerEvent('logo:display', display)
			
			elseif (IsBigmapActive()==false) then
							
				display = true	  
			    TriggerEvent('logo:display', display)
				txtprinter(1.410, 0.795, 1.0,1.0,0.50, "~b~PlayerID:~r~  ".. GetPlayerServerId(NetworkGetEntityOwner(GetPlayerPed(-1))) .. '', 255, 255, 255, 255)
			end
				
	Citizen.Wait(1)
    end
end)


function txtprinter(x,y ,width,height,scale, text, r,g,b,a, outline)
    SetTextFont(4)
    SetTextProportional(0)
    SetTextScale(scale, scale)
	SetTextColour( 0,0,0, 255 )
    SetTextDropShadow(0, 0, 0, 0,255)
    SetTextEdge(1, 0, 0, 0, 255)
    SetTextDropShadow()
	SetTextOutline()
    SetTextEntry("STRING")
    AddTextComponentString(text)
    DrawText(x - width/2, y - height/2 + 0.005)
end


AddEventHandler('onClientMapStart', function()
Citizen.CreateThread(function()
  local display = false
TriggerEvent('logo:display', false)
end)
end)


RegisterNetEvent('logo:display')
AddEventHandler('logo:display', function(value)
SendNUIMessage({
 type = "logo",
display = value
})
end)

My PNG Logo gets loaded via ui-Folder and this html and js:

script.js

$(function(){
	window.onload = function(e){
		window.addEventListener('message', function(event){

			var item = event.data;
			if (item !== undefined && item.type === "logo") {

				if (item.display === true) {
					$('#logo').delay(100).fadeIn( "slow" );
				} else if (item.display === false) {
					$('#logo').fadeOut( "slow" );
				}
			}
		});
	};
});

The Text for the Player-ID gets removed once I open the map, but the icon doesn’t.
It should, as I am setting the display var to false and the fadeout should be triggered?

logoproblem1

IsPauseMenuActive

i do it like this and it works

1 Like

You helped a lot. Thank you so much!!!

Solution:

Citizen.CreateThread(function()
    Wait(50)

    while true do
	
	
		if IsPauseMenuActive() then
			
			display = false
			TriggerEvent('logo:display', false)
			print("pause on")
			
		elseif IsPauseMenuActive() == false then

				print("pause off")							
				display = true	  
				TriggerEvent('logo:display', true)
				txtprinter(1.410, 0.795, 1.0,1.0,0.50, "~b~PlayerID:~r~  ".. GetPlayerServerId(NetworkGetEntityOwner(GetPlayerPed(-1))) .. '', 255, 255, 255, 255)
		end
				
	Citizen.Wait(1)
    end

	
end)

Have to ask a further question.

Icon is hiding well on

IsPauseMenuActive

But I am not sure how to hide once a menue is loaded (NativeUI for example from another ressource).
Is there a special function to determine if a menue is opened?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.