diff --git a/client/cursor.lua b/client/cursor.lua index 7f86cd8..36d84eb 100644 --- a/client/cursor.lua +++ b/client/cursor.lua @@ -1,7 +1,7 @@ local scale = 1.5 local screenWidth = math.floor(1920 / scale) local screenHeight = math.floor(1080 / scale) -shouldDraw = false +local shouldDraw = false function SetInteractScreen(bool) if (not shouldDraw and bool) then @@ -19,7 +19,7 @@ function SetInteractScreen(bool) local minY, maxY = ((h - (h / 2)) / 2), (h - (h / 4)) local totalY = minY - maxY - RequestTextureDictionary('fib_pc') + lib.requestStreamedTextureDict('fib_pc') -- Update controls while active while shouldDraw do @@ -27,7 +27,7 @@ function SetInteractScreen(bool) nY = GetControlNormal(0, 240) * screenHeight DisableControlAction(0, 1, true) -- Disable looking horizontally DisableControlAction(0, 2, true) -- Disable looking vertically - DisablePlayerFiring(PlayerPedId(), true) -- Disable weapon firing + DisablePlayerFiring(cache.ped, true) -- Disable weapon firing DisableControlAction(0, 142, true) -- Disable aiming DisableControlAction(0, 106, true) -- Disable in-game mouse controls -- Update mouse position when changed diff --git a/client/dui.lua b/client/dui.lua index 7abcd78..4b972e3 100644 --- a/client/dui.lua +++ b/client/dui.lua @@ -12,28 +12,12 @@ function CreateNamedRenderTargetForModel(name, model) return handle end -function RequestTextureDictionary(dict) - RequestStreamedTextureDict(dict) - while not HasStreamedTextureDictLoaded(dict) do Wait(0) end - return dict -end - -function LoadModel(model) - if not IsModelInCdimage(model) then return end - RequestModel(model) - while not HasModelLoaded(model) do Wait(0) end - return model -end - function RenderScaleformTV(renderTarget, scaleform, entity) - SetTextRenderId(renderTarget) -- set render target - Set_2dLayer(4) - SetScriptGfxDrawBehindPausemenu(1) - --DrawRect(0.5, 0.5, 1.0, 0.5, 255, 0, 0, 255); -- WOAH! - local coords = GetEntityCoords(entity) - local rot = GetEntityRotation(entity) + SetTextRenderId(renderTarget) + SetScriptGfxDrawOrder(4) + SetScriptGfxDrawBehindPausemenu(true) DrawSprite("ptelevision_b_dict", "ptelevision_b_txd", 0.5, 0.5, 1.0, 1.0, 0.0, 255, 255, 255, 255) - SetTextRenderId(GetDefaultScriptRendertargetRenderId()) -- reset - SetScriptGfxDrawBehindPausemenu(0) + SetTextRenderId(GetDefaultScriptRendertargetRenderId()) + SetScriptGfxDrawBehindPausemenu(false) end diff --git a/client/main.lua b/client/main.lua index e44f02f..892378b 100644 --- a/client/main.lua +++ b/client/main.lua @@ -37,20 +37,9 @@ local height = 720 local sfHandle = nil local txdHasBeenSet = false - -function loadScaleform(scaleform) - local scaleformHandle = RequestScaleformMovie(scaleform) - - while not HasScaleformMovieLoaded(scaleformHandle) do - scaleformHandle = RequestScaleformMovie(scaleform) - Citizen.Wait(0) - end - return scaleformHandle -end - function ShowScreen(data) CURRENT_SCREEN = data - sfHandle = loadScaleform(sfName) + sfHandle = lib.requestScaleformMovie(sfName) runtimeTxd = 'ptelevision_b_dict' local txd = CreateRuntimeTxd('ptelevision_b_dict') @@ -105,7 +94,7 @@ function ShowScreen(data) SetVolume(coords, modelData.DefaultVolume) end while duiObj do - local pcoords = GetEntityCoords(PlayerPedId()) + local pcoords = GetEntityCoords(cache.ped) local dist = #(coords - pcoords) SendDuiMessage(duiObj, json.encode({ setVolume = true, @@ -129,7 +118,7 @@ end function GetClosestScreen() local objPool = GetGamePool('CObject') local closest = {dist = -1} - local pcoords = GetEntityCoords(PlayerPedId()) + local pcoords = GetEntityCoords(cache.ped) for i=1, #objPool do local entity = objPool[i] local model = GetEntityModel(entity) @@ -165,9 +154,9 @@ Citizen.CreateThread(function() local wait = 2500 for i=1, #Locations do local data = Locations[i] - local dist = #(GetEntityCoords(PlayerPedId()) - v3(data.Position)) + local dist = #(GetEntityCoords(cache.ped) - v3(data.Position)) if not Locations[i].obj and dist < 20.0 then - LoadModel(data.Model) + lib.requestModel(data.Model) Locations[i].obj = CreateObject(data.Model, data.Position.x, data.Position.y, data.Position.z) SetEntityHeading(Locations[i].obj, data.Position.w) FreezeEntityPosition(Locations[i].obj, true) @@ -207,11 +196,9 @@ RegisterNetEvent("ptelevision:requestSync", function(coords, data) end end) - - -RegisterNUICallback("pageLoaded", function(cb) +RegisterNUICallback("pageLoaded", function(data, cb) waitForLoad = false - if cb then cb() end + cb(1) end) AddEventHandler('onResourceStop', function(name) diff --git a/client/tv.lua b/client/tv.lua index b599e26..ac1deec 100644 --- a/client/tv.lua +++ b/client/tv.lua @@ -1,4 +1,4 @@ -TelevisionsLocal = {} +local TelevisionsLocal = {} function SetChannel(index) TriggerServerEvent("ptelevision:event", CURRENT_SCREEN, "ptv_status", { @@ -20,8 +20,8 @@ function GetChannelList() channel = status.channel end for index,value in pairs(Channels) do - table.insert(channel_list, {index = index, url = value.url}) - table.insert(menu_list, "Channel #" .. index .. " (".. value.name ..")") + channel_list[#channel_list+1] = {index = index, url = value.url} + menu_list[#menu_list+1] = "Channel #" .. index .. " (".. value.name ..")" if channel ~= nil and channel == index then current = #channel_list end @@ -95,10 +95,6 @@ function OpenTVMenu() SetChannel(ChannelList.list[scrollIndex].index) end end, - onSelected = function(selected, scrollIndex, args) - end, - onClose = function(keyPressed) - end, options = { {label = 'Videos', description = 'Play a video or stream on the screen.'}, {label = 'Web Browser', description = 'Access the web via your TV.'}, @@ -219,8 +215,8 @@ end) RegisterCommand('tv', function() OpenTVMenu() -end) +end, false) -RegisterCommand("broadcast", function(source, args, raw) +RegisterCommand('broadcast', function() BroadcastMenu() -end) \ No newline at end of file +end, false) \ No newline at end of file