Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions client/cursor.lua
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -19,15 +19,15 @@ 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
nX = GetControlNormal(0, 239) * screenWidth
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
Expand Down
26 changes: 5 additions & 21 deletions client/dui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

27 changes: 7 additions & 20 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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,
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
16 changes: 6 additions & 10 deletions client/tv.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
TelevisionsLocal = {}
local TelevisionsLocal = {}

function SetChannel(index)
TriggerServerEvent("ptelevision:event", CURRENT_SCREEN, "ptv_status", {
Expand All @@ -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
Expand Down Expand Up @@ -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.'},
Expand Down Expand Up @@ -219,8 +215,8 @@ end)

RegisterCommand('tv', function()
OpenTVMenu()
end)
end, false)

RegisterCommand("broadcast", function(source, args, raw)
RegisterCommand('broadcast', function()
BroadcastMenu()
end)
end, false)