local RESOURCE_CODE = GetResourceMetadata(GetCurrentResourceName(), "resource_code", 0)
local SPLASH_IMG = GetResourceMetadata(GetCurrentResourceName(), "SPLASH_IMG", 0)

--Setup the splash image on script load
Citizen.CreateThread(function()
  print("Setting Up LoadSplash")
  SendNUIMessage({
    type = "setIMG",
    value = SPLASH_IMG,
  })
end)

-- Show and hide the splash without spinner
function displaySplash(bool)
  SendNUIMessage({
    type = "showSplash",
    status = bool,
  })
end

RegisterNetEvent(RESOURCE_CODE..':ShowStaticSplash')
AddEventHandler(RESOURCE_CODE..':ShowStaticSplash', function(bool)
  displaySplash(bool)
end)

-- Show and hide the splash with spinner
function displayLoadSplash(bool)
  SendNUIMessage({
    type = "showLoadingSplash",
    status = bool,
  })
end

RegisterNetEvent(RESOURCE_CODE..':ShowLoadingSplash')
AddEventHandler(RESOURCE_CODE..':ShowLoadingSplash', function(bool)
  displayLoadSplash(bool)
end)

