local requestedIpl = {
"h4_mph4_terrain_01_grass_0",
"h4_mph4_terrain_01_grass_1",
"h4_mph4_terrain_02_grass_0",
"h4_mph4_terrain_02_grass_1",
"h4_mph4_terrain_02_grass_2",
"h4_mph4_terrain_02_grass_3",
"h4_mph4_terrain_04_grass_0",
"h4_mph4_terrain_04_grass_1",
"h4_mph4_terrain_05_grass_0",
"h4_mph4_terrain_06_grass_0",
"h4_islandx_terrain_01",
"h4_islandx_terrain_01_lod",
"h4_islandx_terrain_01_slod",
"h4_islandx_terrain_02",
"h4_islandx_terrain_02_lod",
"h4_islandx_terrain_02_slod",
"h4_islandx_terrain_03",
"h4_islandx_terrain_03_lod",
"h4_islandx_terrain_04",
"h4_islandx_terrain_04_lod",
"h4_islandx_terrain_04_slod",
"h4_islandx_terrain_05",
"h4_islandx_terrain_05_lod",
"h4_islandx_terrain_05_slod",
"h4_islandx_terrain_06",
"h4_islandx_terrain_06_lod",
"h4_islandx_terrain_06_slod",
"h4_islandx_terrain_props_05_a",
"h4_islandx_terrain_props_05_a_lod",
"h4_islandx_terrain_props_05_b",
"h4_islandx_terrain_props_05_b_lod",
"h4_islandx_terrain_props_05_c",
"h4_islandx_terrain_props_05_c_lod",
"h4_islandx_terrain_props_05_d",
"h4_islandx_terrain_props_05_d_lod",
"h4_islandx_terrain_props_05_d_slod",
"h4_islandx_terrain_props_05_e",
"h4_islandx_terrain_props_05_e_lod",
"h4_islandx_terrain_props_05_e_slod",
"h4_islandx_terrain_props_05_f",
"h4_islandx_terrain_props_05_f_lod",
"h4_islandx_terrain_props_05_f_slod",
"h4_islandx_terrain_props_06_a",
"h4_islandx_terrain_props_06_a_lod",
"h4_islandx_terrain_props_06_a_slod",
"h4_islandx_terrain_props_06_b",
"h4_islandx_terrain_props_06_b_lod",
"h4_islandx_terrain_props_06_b_slod",
"h4_islandx_terrain_props_06_c",
"h4_islandx_terrain_props_06_c_lod",
"h4_islandx_terrain_props_06_c_slod",
"h4_mph4_terrain_01",
"h4_mph4_terrain_01_long_0",
"h4_mph4_terrain_02",
"h4_mph4_terrain_03",
"h4_mph4_terrain_04",
"h4_mph4_terrain_05",
"h4_mph4_terrain_06",
"h4_mph4_terrain_06_strm_0",
"h4_mph4_terrain_lod",
"h4_mph4_terrain_occ_00",
"h4_mph4_terrain_occ_01",
"h4_mph4_terrain_occ_02",
"h4_mph4_terrain_occ_03",
"h4_mph4_terrain_occ_04",
"h4_mph4_terrain_occ_05",
"h4_mph4_terrain_occ_06",
"h4_mph4_terrain_occ_07",
"h4_mph4_terrain_occ_08",
"h4_mph4_terrain_occ_09",
"h4_boatblockers",
"h4_islandx",
"h4_islandx_disc_strandedshark",
"h4_islandx_disc_strandedshark_lod",
"h4_islandx_disc_strandedwhale",
"h4_islandx_disc_strandedwhale_lod",
"h4_islandx_props",
"h4_islandx_props_lod",
"h4_islandx_sea_mines",
"h4_mph4_island",
"h4_mph4_island_long_0",
"h4_mph4_island_strm_0",
"h4_aa_guns",
"h4_aa_guns_lod",
"h4_beach",
"h4_beach_bar_props",
"h4_beach_lod",
"h4_beach_party",
"h4_beach_party_lod",
"h4_beach_props",
"h4_beach_props_lod",
"h4_beach_props_party",
"h4_beach_props_slod",
"h4_beach_slod",
"h4_islandairstrip",
"h4_islandairstrip_doorsclosed",
"h4_islandairstrip_doorsclosed_lod",
"h4_islandairstrip_doorsopen",
"h4_islandairstrip_doorsopen_lod",
"h4_islandairstrip_hangar_props",
"h4_islandairstrip_hangar_props_lod",
"h4_islandairstrip_hangar_props_slod",
"h4_islandairstrip_lod",
"h4_islandairstrip_props",
"h4_islandairstrip_propsb",
"h4_islandairstrip_propsb_lod",
"h4_islandairstrip_propsb_slod",
"h4_islandairstrip_props_lod",
"h4_islandairstrip_props_slod",
"h4_islandairstrip_slod",
"h4_islandxcanal_props",
"h4_islandxcanal_props_lod",
"h4_islandxcanal_props_slod",
"h4_islandxdock",
"h4_islandxdock_lod",
"h4_islandxdock_props",
"h4_islandxdock_props_2",
"h4_islandxdock_props_2_lod",
"h4_islandxdock_props_2_slod",
"h4_islandxdock_props_lod",
"h4_islandxdock_props_slod",
"h4_islandxdock_slod",
"h4_islandxdock_water_hatch",
"h4_islandxtower",
"h4_islandxtower_lod",
"h4_islandxtower_slod",
"h4_islandxtower_veg",
"h4_islandxtower_veg_lod",
"h4_islandxtower_veg_slod",
"h4_islandx_barrack_hatch",
"h4_islandx_barrack_props",
"h4_islandx_barrack_props_lod",
"h4_islandx_barrack_props_slod",
"h4_islandx_checkpoint",
"h4_islandx_checkpoint_lod",
"h4_islandx_checkpoint_props",
"h4_islandx_checkpoint_props_lod",
"h4_islandx_checkpoint_props_slod",
"h4_islandx_maindock",
"h4_islandx_maindock_lod",
"h4_islandx_maindock_props",
"h4_islandx_maindock_props_2",
"h4_islandx_maindock_props_2_lod",
"h4_islandx_maindock_props_2_slod",
"h4_islandx_maindock_props_lod",
"h4_islandx_maindock_props_slod",
"h4_islandx_maindock_slod",
"h4_islandx_mansion",
"h4_islandx_mansion_b",
"h4_islandx_mansion_b_lod",
"h4_islandx_mansion_b_side_fence",
"h4_islandx_mansion_b_slod",
"h4_islandx_mansion_entrance_fence",
"h4_islandx_mansion_guardfence",
"h4_islandx_mansion_lights",
"h4_islandx_mansion_lockup_01",
"h4_islandx_mansion_lockup_01_lod",
"h4_islandx_mansion_lockup_02",
"h4_islandx_mansion_lockup_02_lod",
"h4_islandx_mansion_lockup_03",
"h4_islandx_mansion_lockup_03_lod",
"h4_islandx_mansion_lod",
"h4_islandx_mansion_office",
"h4_islandx_mansion_office_lod",
"h4_islandx_mansion_props",
"h4_islandx_mansion_props_lod",
"h4_islandx_mansion_props_slod",
"h4_islandx_mansion_slod",
"h4_islandx_mansion_vault",
"h4_islandx_mansion_vault_lod",
"h4_island_padlock_props",
-- "h4_mansion_gate_broken",
"h4_mansion_gate_closed",
"h4_mansion_remains_cage",
"h4_mph4_airstrip",
"h4_mph4_airstrip_interior_0_airstrip_hanger",
"h4_mph4_beach",
"h4_mph4_dock",
"h4_mph4_island_lod",
"h4_mph4_island_ne_placement",
"h4_mph4_island_nw_placement",
"h4_mph4_island_se_placement",
"h4_mph4_island_sw_placement",
"h4_mph4_mansion",
"h4_mph4_mansion_b",
"h4_mph4_mansion_b_strm_0",
"h4_mph4_mansion_strm_0",
"h4_mph4_wtowers",
"h4_ne_ipl_00",
"h4_ne_ipl_00_lod",
"h4_ne_ipl_00_slod",
"h4_ne_ipl_01",
"h4_ne_ipl_01_lod",
"h4_ne_ipl_01_slod",
"h4_ne_ipl_02",
"h4_ne_ipl_02_lod",
"h4_ne_ipl_02_slod",
"h4_ne_ipl_03",
"h4_ne_ipl_03_lod",
"h4_ne_ipl_03_slod",
"h4_ne_ipl_04",
"h4_ne_ipl_04_lod",
"h4_ne_ipl_04_slod",
"h4_ne_ipl_05",
"h4_ne_ipl_05_lod",
"h4_ne_ipl_05_slod",
"h4_ne_ipl_06",
"h4_ne_ipl_06_lod",
"h4_ne_ipl_06_slod",
"h4_ne_ipl_07",
"h4_ne_ipl_07_lod",
"h4_ne_ipl_07_slod",
"h4_ne_ipl_08",
"h4_ne_ipl_08_lod",
"h4_ne_ipl_08_slod",
"h4_ne_ipl_09",
"h4_ne_ipl_09_lod",
"h4_ne_ipl_09_slod",
"h4_nw_ipl_00",
"h4_nw_ipl_00_lod",
"h4_nw_ipl_00_slod",
"h4_nw_ipl_01",
"h4_nw_ipl_01_lod",
"h4_nw_ipl_01_slod",
"h4_nw_ipl_02",
"h4_nw_ipl_02_lod",
"h4_nw_ipl_02_slod",
"h4_nw_ipl_03",
"h4_nw_ipl_03_lod",
"h4_nw_ipl_03_slod",
"h4_nw_ipl_04",
"h4_nw_ipl_04_lod",
"h4_nw_ipl_04_slod",
"h4_nw_ipl_05",
"h4_nw_ipl_05_lod",
"h4_nw_ipl_05_slod",
"h4_nw_ipl_06",
"h4_nw_ipl_06_lod",
"h4_nw_ipl_06_slod",
"h4_nw_ipl_07",
"h4_nw_ipl_07_lod",
"h4_nw_ipl_07_slod",
"h4_nw_ipl_08",
"h4_nw_ipl_08_lod",
"h4_nw_ipl_08_slod",
"h4_nw_ipl_09",
"h4_nw_ipl_09_lod",
"h4_nw_ipl_09_slod",
"h4_se_ipl_00",
"h4_se_ipl_00_lod",
"h4_se_ipl_00_slod",
"h4_se_ipl_01",
"h4_se_ipl_01_lod",
"h4_se_ipl_01_slod",
"h4_se_ipl_02",
"h4_se_ipl_02_lod",
"h4_se_ipl_02_slod",
"h4_se_ipl_03",
"h4_se_ipl_03_lod",
"h4_se_ipl_03_slod",
"h4_se_ipl_04",
"h4_se_ipl_04_lod",
"h4_se_ipl_04_slod",
"h4_se_ipl_05",
"h4_se_ipl_05_lod",
"h4_se_ipl_05_slod",
"h4_se_ipl_06",
"h4_se_ipl_06_lod",
"h4_se_ipl_06_slod",
"h4_se_ipl_07",
"h4_se_ipl_07_lod",
"h4_se_ipl_07_slod",
"h4_se_ipl_08",
"h4_se_ipl_08_lod",
"h4_se_ipl_08_slod",
"h4_se_ipl_09",
"h4_se_ipl_09_lod",
"h4_se_ipl_09_slod",
"h4_sw_ipl_00",
"h4_sw_ipl_00_lod",
"h4_sw_ipl_00_slod",
"h4_sw_ipl_01",
"h4_sw_ipl_01_lod",
"h4_sw_ipl_01_slod",
"h4_sw_ipl_02",
"h4_sw_ipl_02_lod",
"h4_sw_ipl_02_slod",
"h4_sw_ipl_03",
"h4_sw_ipl_03_lod",
"h4_sw_ipl_03_slod",
"h4_sw_ipl_04",
"h4_sw_ipl_04_lod",
"h4_sw_ipl_04_slod",
"h4_sw_ipl_05",
"h4_sw_ipl_05_lod",
"h4_sw_ipl_05_slod",
"h4_sw_ipl_06",
"h4_sw_ipl_06_lod",
"h4_sw_ipl_06_slod",
"h4_sw_ipl_07",
"h4_sw_ipl_07_lod",
"h4_sw_ipl_07_slod",
"h4_sw_ipl_08",
"h4_sw_ipl_08_lod",
"h4_sw_ipl_08_slod",
"h4_sw_ipl_09",
"h4_sw_ipl_09_lod",
"h4_sw_ipl_09_slod",
"h4_underwater_gate_closed",
"h4_islandx_placement_01",
"h4_islandx_placement_02",
"h4_islandx_placement_03",
"h4_islandx_placement_04",
"h4_islandx_placement_05",
"h4_islandx_placement_06",
"h4_islandx_placement_07",
"h4_islandx_placement_08",
"h4_islandx_placement_09",
"h4_islandx_placement_10",
"h4_mph4_island_placement"
}
CreateThread(function()
    for i = #requestedIpl, 1, -1 do
        RequestIpl(requestedIpl[i])
        requestedIpl[i] = nil
    end
    requestedIpl = nil
end)
CreateThread(function()
    while true do
        SetRadarAsExteriorThisFrame()
        SetRadarAsInteriorThisFrame(`h4_fake_islandx`, vec(4700.0, -5145.0), 0, 0)
        Wait(0)
    end
end)
CreateThread(function()
    SetDeepOceanScaler(0.0)
    local islandLoaded = false
    local islandCoords = vector3(4840.571, -5174.425, 2.0)
    while true do
        local pCoords = GetEntityCoords(PlayerPedId())
        if #(pCoords - islandCoords) < 2000.0 then
            if not islandLoaded then
                islandLoaded = true
                Citizen.InvokeNative(0x9A9D1BA639675CF1, "HeistIsland", 1)
                Citizen.InvokeNative(0xF74B1FFA4A15FBEA, 1) -- island path nodes (from Disquse)
                SetScenarioGroupEnabled('Heist_Island_Peds', 1)
                -- SetAudioFlag('PlayerOnDLCHeist4Island', 1)
                SetAmbientZoneListStatePersistent('AZL_DLC_Hei4_Island_Zones', 1, 1)
                SetAmbientZoneListStatePersistent('AZL_DLC_Hei4_Island_Disabled_Zones', 0, 1)
            end
        else
            if islandLoaded then
                islandLoaded = false
                Citizen.InvokeNative(0x9A9D1BA639675CF1, "HeistIsland", 0)
                Citizen.InvokeNative(0xF74B1FFA4A15FBEA, 0)
                SetScenarioGroupEnabled('Heist_Island_Peds', 0)
                -- SetAudioFlag('PlayerOnDLCHeist4Island', 0)
                SetAmbientZoneListStatePersistent('AZL_DLC_Hei4_Island_Zones', 0, 0)
                SetAmbientZoneListStatePersistent('AZL_DLC_Hei4_Island_Disabled_Zones', 1, 0)
            end
        end
        Wait(5000)
    end
end)
Citizen.CreateThread(function()
    while true do
        local pCoords = GetEntityCoords(GetPlayerPed(-1))       
            local distance1 = GetDistanceBetweenCoords(pCoords.x, pCoords.y, pCoords.z, 4840.571, -5174.425, 2.0, false)
            if distance1 < 2000.0 then
            Citizen.InvokeNative("0x9A9D1BA639675CF1", "HeistIsland", true)  -- load the map and removes the city
            Citizen.InvokeNative("0x5E1460624D194A38", true) -- load the minimap/pause map and removes the city minimap/pause map
            else
            Citizen.InvokeNative("0x9A9D1BA639675CF1", "HeistIsland", false)
            Citizen.InvokeNative("0x5E1460624D194A38", false)
            end
        Citizen.Wait(5000)
    end
end)
Citizen.CreateThread(function()
  SetDeepOceanScaler(0.0)
end)
local inCasino = false
local spinningObject = nil
local spinningCar = nil
local carOnShow = `drafter`
Citizen.CreateThread(function()
    Wait(10000)
    RequestIpl('vw_casino_main')
    RequestIpl('vw_dlc_casino_door')
    RequestIpl('hei_dlc_casino_door')
    RequestIpl("hei_dlc_windows_casino")
    RequestIpl("vw_casino_penthouse")
    SetIplPropState(274689, "Set_Pent_Tint_Shell", true, true)
    SetInteriorEntitySetColor(274689, "Set_Pent_Tint_Shell", 3)
    -- RequestIpl("hei_dlc_windows_casino_lod")
    -- RequestIpl("vw_casino_carpark")
    -- RequestIpl("vw_casino_garage")
    -- RequestIpl("hei_dlc_casino_aircon")
    -- RequestIpl("hei_dlc_casino_aircon_lod")
    -- RequestIpl("hei_dlc_casino_door")
    -- RequestIpl("hei_dlc_casino_door_lod")
    -- RequestIpl("hei_dlc_vw_roofdoors_locked")
    -- RequestIpl("vw_ch3_additions")
    -- RequestIpl("vw_ch3_additions_long_0")
    -- RequestIpl("vw_ch3_additions_strm_0")
    -- RequestIpl("vw_dlc_casino_door")
    -- RequestIpl("vw_dlc_casino_door_lod")
    -- RequestIpl("vw_casino_billboard")
    -- RequestIpl("vw_casino_billboard_lod(1)")
    -- RequestIpl("vw_casino_billboard_lod")
    -- RequestIpl("vw_int_placement_vw")
    -- RequestIpl("vw_dlc_casino_apart")
    local interiorID = GetInteriorAtCoords(1100.000, 220.000, -50.000)
    
    if IsValidInterior(interiorID) then
      RefreshInterior(interiorID)
    end
 
    
end)
--TELEPORT
key_to_teleport = 38
positions = {
    --[[
    {{Teleport1 X, Teleport1 Y, Teleport1 Z, Teleport1 Heading}, {Teleport2 X, Teleport 2Y, Teleport 2Z, Teleport2 Heading}, {Red, Green, Blue}, "Text for Teleport"}
    ]]
    {{925.0, 47.0, 80.00, 0}, {1090.00, 207.00, -49.9, 358},{255,0,0}, "Cassino Diamond"}, -- Outside the Sheriff's Station
    --{{1086.00, 215.0, -50.00, 312}, {964.2912597, 58.9096641, 111.65295562744, 52},{255,0,0}, "penthouse"},
}
local player = GetPlayerPed(-1)
Citizen.CreateThread(function ()
    while true do
        Citizen.Wait(5)
        local player = GetPlayerPed(-1)
        local playerLoc = GetEntityCoords(player)
        for _,location in ipairs(positions) do
            teleport_text = location[4]
            loc1 = {
                x=location[1][1],
                y=location[1][2],
                z=location[1][3],
                heading=location[1][4]
            }
            loc2 = {
                x=location[2][1],
                y=location[2][2],
                z=location[2][3],
                heading=location[2][4]
            }
            Red = location[3][1]
            Green = location[3][2]
            Blue = location[3][3]
            DrawMarker(2, loc1.x, loc1.y, loc1.z+1.0, 0, 0, 0, 0, 0, 0, 0.25, 0.2, 0.1, Red, Green, Blue, 200, 0, 0, 0, 1)
            DrawMarker(2, loc2.x, loc2.y, loc2.z+1.0, 0, 0, 0, 0, 0, 0, 0.25, 0.2, 0.1, Red, Green, Blue, 200, 0, 0, 0, 1)
            if CheckPos(playerLoc.x, playerLoc.y, playerLoc.z, loc1.x, loc1.y, loc1.z, 2) then
                DrawText3Ds(loc1.x, loc1.y, loc1.z + 1.2, '[E] Casino')
                if IsControlJustReleased(1, key_to_teleport) then
                    DoScreenFadeOut(500)
                    Wait(500)
                    SetEntityCoords(player, loc2.x, loc2.y, loc2.z)
                    SetEntityHeading(player, loc2.heading)
                    DoScreenFadeIn(500)
                    enterCasino(false)
                    Citizen.Wait(1)
                    enterCasino(true)
                    scanned = true
                    scanwait = 200
                end
            elseif CheckPos(playerLoc.x, playerLoc.y, playerLoc.z, loc2.x, loc2.y, loc2.z, 2) then
                DrawText3Ds(loc2.x, loc2.y, loc2.z + 1.2, '[E] Çık')
                if IsControlJustReleased(1, key_to_teleport) then
                    DoScreenFadeOut(500)
                    Wait(500)
                    SetEntityCoords(player, loc1.x, loc1.y, loc1.z)
                    SetEntityHeading(player, loc1.heading)
                    DoScreenFadeIn(500)
                    enterCasino(false)
                    Citizen.Wait(1)
                    enterCasino(false)
                    scanned = false
                    scanwait = 200
                end
            end           
        end
    end
end)
function CheckPos(x, y, z, cx, cy, cz, radius)
    local t1 = x - cx
    local t12 = t1^2
    local t2 = y-cy
    local t21 = t2^2
    local t3 = z - cz
    local t31 = t3^2
    return (t12 + t21 + t31) <= radius^2
end
--END TELEPORT
function DrawText3Ds(x, y, z, text)
    SetTextScale(0.35, 0.35)
    SetTextFont(4)
    SetTextProportional(1)
    SetTextColour(255, 255, 255, 215)
    SetTextEntry("STRING")
    SetTextCentre(true)
    AddTextComponentString(text)
    SetDrawOrigin(x,y,z, 0)
    DrawText(0.0, 0.0)
    local factor = (string.len(text)) / 370
    DrawRect(0.0, 0.0+0.0125, 0.017+ factor, 0.03, 0, 0, 0, 75)
    ClearDrawOrigin()
end
-- CAR FOR WINS
function drawCarForWins()
    if DoesEntityExist(spinningCar) then
      DeleteEntity(spinningCar)
    end
    RequestModel(carOnShow)
    while not HasModelLoaded(carOnShow) do
        Citizen.Wait(0)
    end
    SetModelAsNoLongerNeeded(carOnShow)
    spinningCar = CreateVehicle(carOnShow, 1100.0, 220.0, -51.0 + 0.05, 0.0, 0, 0)
    Wait(0)
    SetVehicleDirtLevel(spinningCar, 0.0)
    SetVehicleOnGroundProperly(spinningCar)
    Wait(0)
    FreezeEntityPosition(spinningCar, 1)
end
-- END CAR FOR WINS
function enterCasino(pIsInCasino, pFromElevator, pCoords, pHeading)
    if pIsInCasino == inCasino then return end
    inCasino = pIsInCasino
    if DoesEntityExist(spinningCar) then
      DeleteEntity(spinningCar)
    end
    spinMeRightRoundBaby()
    showDiamondsOnScreenBaby()
    playSomeBackgroundAudioBaby()
end
 
function spinMeRightRoundBaby()
    Citizen.CreateThread(function()
        while inCasino do
        if not spinningObject or spinningObject == 0 or not DoesEntityExist(spinningObject) then
          spinningObject = GetClosestObjectOfType(1100.0, 220.0, -51.0, 10.0, -1561087446, 0, 0, 0)
          drawCarForWins()
        end
        if spinningObject ~= nil and spinningObject ~= 0 then
          local curHeading = GetEntityHeading(spinningObject)
          local curHeadingCar = GetEntityHeading(spinningCar)
          if curHeading >= 360 then
            curHeading = 0.0
            curHeadingCar = 0.0
          elseif curHeading ~= curHeadingCar then
            curHeadingCar = curHeading
          end
          SetEntityHeading(spinningObject, curHeading + 0.075)
          SetEntityHeading(spinningCar, curHeadingCar + 0.075)
        end
        Wait(0)
      end
      spinningObject = nil
    end)
end
 
-- Casino Screens
local Playlists = {
    "CASINO_DIA_PL", -- diamonds
    "CASINO_SNWFLK_PL", -- snowflakes
    "CASINO_WIN_PL", -- win
    "CASINO_HLW_PL", -- skull
}
 
-- Render
function CreateNamedRenderTargetForModel(name, model)
    local handle = 0
    if not IsNamedRendertargetRegistered(name) then
        RegisterNamedRendertarget(name, 0)
    end
    if not IsNamedRendertargetLinked(model) then
        LinkNamedRendertarget(model)
    end
    if IsNamedRendertargetRegistered(name) then
        handle = GetNamedRendertargetRenderId(name)
    end
 
    return handle
end
-- render tv
function showDiamondsOnScreenBaby()
    Citizen.CreateThread(function()
      local model = GetHashKey("vw_vwint01_video_overlay")
      local timeout = 21085 -- 5000 / 255
 
      local handle = CreateNamedRenderTargetForModel("CasinoScreen_01", model)
 
      RegisterScriptWithAudio(0)
      SetTvChannel(-1)
      SetTvVolume(0)
      SetScriptGfxDrawOrder(4)
      SetTvChannelPlaylist(2, "CASINO_DIA_PL", 0)
      SetTvChannel(2)
      EnableMovieSubtitles(1)
 
    function doAlpha()
        Citizen.SetTimeout(timeout, function()
        SetTvChannelPlaylist(2, "CASINO_DIA_PL", 0)
        SetTvChannel(2)
        doAlpha()
        end)
    end
    doAlpha()
 
    Citizen.CreateThread(function()
    while inCasino do
      SetTextRenderId(handle)
      DrawTvChannel(0.5, 0.5, 1.0, 1.0, 0.0, 255, 255, 255, 255)
      SetTextRenderId(GetDefaultScriptRendertargetRenderId())
      Citizen.Wait(0)
    end
    SetTvChannel(-1)
    ReleaseNamedRendertarget(GetHashKey("CasinoScreen_01"))
    SetTextRenderId(GetDefaultScriptRendertargetRenderId())
    end)
   end)
end
 
function playSomeBackgroundAudioBaby()
    Citizen.CreateThread(function()
      local function audioBanks()
        while not RequestScriptAudioBank("DLC_VINEWOOD/CASINO_GENERAL", false, -1) do
          Citizen.Wait(0)
        end
        while not RequestScriptAudioBank("DLC_VINEWOOD/CASINO_SLOT_MACHINES_01", false, -1) do
          Citizen.Wait(0)
        end
        while not RequestScriptAudioBank("DLC_VINEWOOD/CASINO_SLOT_MACHINES_02", false, -1) do
          Citizen.Wait(0)
        end
        while not RequestScriptAudioBank("DLC_VINEWOOD/CASINO_SLOT_MACHINES_03", false, -1) do
          Citizen.Wait(0)
        end
      end
      audioBanks()
      while inCasino do
        if not IsStreamPlaying() and LoadStream("casino_walla", "DLC_VW_Casino_Interior_Sounds") then
          PlayStreamFromPosition(1111, 230, -47)
        end
        if IsStreamPlaying() and not IsAudioSceneActive("DLC_VW_Casino_General") then
          StartAudioScene("DLC_VW_Casino_General")
        end
        Citizen.Wait(1000)
      end
      if IsStreamPlaying() then
        StopStream()
      end
      if IsAudioSceneActive("DLC_VW_Casino_General") then
        StopAudioScene("DLC_VW_Casino_General")
      end
    end)
end