mirror of
https://github.com/Michatec/ptelevision.git
synced 2026-03-31 23:46:30 +02:00
Update v1.1.1
This commit is contained in:
@@ -70,33 +70,14 @@ function ShowScreen(data)
|
|||||||
|
|
||||||
PopScaleformMovieFunctionVoid()
|
PopScaleformMovieFunctionVoid()
|
||||||
Citizen.CreateThread(function()
|
Citizen.CreateThread(function()
|
||||||
|
TriggerServerEvent("ptelevision:requestSync", data.coords)
|
||||||
local tvObj = data.entity
|
local tvObj = data.entity
|
||||||
|
|
||||||
local _, status = GetTelevision(data.coords)
|
|
||||||
local _, lstatus = GetTelevisionLocal(data.coords)
|
|
||||||
local screenModel = Config.Models[data.model]
|
local screenModel = Config.Models[data.model]
|
||||||
if status and status["ptv_status"] then
|
|
||||||
local status = status["ptv_status"]
|
|
||||||
Citizen.Wait(1000)
|
|
||||||
if status.type == "play" and lstatus then
|
|
||||||
if (status.channel and Channels[status.channel]) then
|
|
||||||
PlayVideo({url = Channels[status.channel].url, channel = status.channel})
|
|
||||||
elseif (status.url) then
|
|
||||||
local time
|
|
||||||
if (lstatus.start_time) then
|
|
||||||
time = math.floor((GetGameTimer() - lstatus.start_time) / 1000)
|
|
||||||
end
|
|
||||||
PlayVideo({url = status.url, time = time})
|
|
||||||
end
|
|
||||||
elseif (status.type == "browser") then
|
|
||||||
PlayBrowser({ url = status.url })
|
|
||||||
end
|
|
||||||
end
|
|
||||||
while duiObj do
|
while duiObj do
|
||||||
if (tvObj and sfHandle ~= nil and HasScaleformMovieLoaded(sfHandle)) then
|
if (tvObj and sfHandle ~= nil and HasScaleformMovieLoaded(sfHandle)) then
|
||||||
local pos = GetEntityCoords(tvObj)
|
local pos = GetEntityCoords(tvObj)
|
||||||
local scale = screenModel.Scale
|
local scale = screenModel.Scale
|
||||||
local offset = GetOffsetFromEntityInWorldCoords(tvObj, -1.02, -0.055, 1.04)
|
local offset = GetOffsetFromEntityInWorldCoords(tvObj, screenModel.Offset.x, screenModel.Offset.y, screenModel.Offset.z)
|
||||||
local hz = GetEntityHeading(tvObj)
|
local hz = GetEntityHeading(tvObj)
|
||||||
DrawScaleformMovie_3dNonAdditive(sfHandle, offset.x, offset.y, offset.z, 0.0, -hz, 0.0, 2.0, 2.0, 2.0, scale * 1, scale * (9/16), 1, 2)
|
DrawScaleformMovie_3dNonAdditive(sfHandle, offset.x, offset.y, offset.z, 0.0, -hz, 0.0, 2.0, 2.0, 2.0, scale * 1, scale * (9/16), 1, 2)
|
||||||
end
|
end
|
||||||
@@ -162,18 +143,63 @@ Citizen.CreateThread(function()
|
|||||||
local data = GetClosestScreen()
|
local data = GetClosestScreen()
|
||||||
if (data and not duiObj) then
|
if (data and not duiObj) then
|
||||||
ShowScreen(data)
|
ShowScreen(data)
|
||||||
elseif ((not data or #(vec3(CURRENT_SCREEN.coords) - vec3(data.coords)) > 0.01 ) and duiObj) then
|
elseif ((not data or #(v3(CURRENT_SCREEN.coords) - v3(data.coords)) > 0.01 ) and duiObj) then
|
||||||
HideScreen()
|
HideScreen()
|
||||||
end
|
end
|
||||||
Citizen.Wait(wait)
|
Citizen.Wait(wait)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
Citizen.CreateThread(function()
|
||||||
|
while true do
|
||||||
|
local wait = 2500
|
||||||
|
local locations = Config.Locations
|
||||||
|
for i=1, #locations do
|
||||||
|
local data = locations[i]
|
||||||
|
local dist = #(GetEntityCoords(PlayerPedId()) - v3(data.Position))
|
||||||
|
if not locations[i].obj and dist < 20.0 then
|
||||||
|
LoadModel(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)
|
||||||
|
elseif locations[i].obj and dist > 20.0 then
|
||||||
|
DeleteEntity(locations[i].obj)
|
||||||
|
locations[i].obj = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Citizen.Wait(wait)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
RegisterNetEvent("ptelevision:requestUpdate", function(data)
|
RegisterNetEvent("ptelevision:requestUpdate", function(data)
|
||||||
Televisions = data.Televisions
|
Televisions = data.Televisions
|
||||||
Channels = data.Channels
|
Channels = data.Channels
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
RegisterNetEvent("ptelevision:requestSync", function(coords, data)
|
||||||
|
local tvObj = data.entity
|
||||||
|
|
||||||
|
local _, status = GetTelevision(coords)
|
||||||
|
local screenModel = Config.Models[data.model]
|
||||||
|
if status and status["ptv_status"] then
|
||||||
|
local update_time = status.update_time
|
||||||
|
local status = status["ptv_status"]
|
||||||
|
Citizen.Wait(1000)
|
||||||
|
if status.type == "play" then
|
||||||
|
if (status.channel and Channels[status.channel]) then
|
||||||
|
PlayVideo({url = Channels[status.channel].url, channel = status.channel})
|
||||||
|
elseif (status.url) then
|
||||||
|
local time = math.floor((data.current_time - update_time) / 1000)
|
||||||
|
PlayVideo({url = status.url, time = time})
|
||||||
|
end
|
||||||
|
elseif (status.type == "browser") then
|
||||||
|
PlayBrowser({ url = status.url })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RegisterNUICallback("pageLoaded", function()
|
RegisterNUICallback("pageLoaded", function()
|
||||||
waitForLoad = false
|
waitForLoad = false
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ end
|
|||||||
|
|
||||||
function GetTelevisionLocal(coords)
|
function GetTelevisionLocal(coords)
|
||||||
for k,v in pairs(TelevisionsLocal) do
|
for k,v in pairs(TelevisionsLocal) do
|
||||||
if #(vec3(v.coords) - vec3(coords)) < 0.01 then
|
if #(v3(v.coords) - v3(coords)) < 0.01 then
|
||||||
return k, v
|
return k, v
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -180,7 +180,7 @@ RegisterNetEvent("ptelevision:event", function(data, index, key, value)
|
|||||||
Televisions = data
|
Televisions = data
|
||||||
local data = Televisions[index]
|
local data = Televisions[index]
|
||||||
local screen = CURRENT_SCREEN
|
local screen = CURRENT_SCREEN
|
||||||
if (screen and #(vec3(screen.coords) - vec3(data.coords)) < 0.001) then
|
if (screen and #(v3(screen.coords) - v3(data.coords)) < 0.001) then
|
||||||
local index, data = GetTelevision(screen.coords)
|
local index, data = GetTelevision(screen.coords)
|
||||||
if (index) then
|
if (index) then
|
||||||
local event = value
|
local event = value
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ function SetTelevision(coords, key, value, update)
|
|||||||
Televisions[index][key] = value
|
Televisions[index][key] = value
|
||||||
end
|
end
|
||||||
Televisions[index].coords = coords
|
Televisions[index].coords = coords
|
||||||
|
Televisions[index].update_time = os.time()
|
||||||
if (update) then
|
if (update) then
|
||||||
TriggerClientEvent("ptelevision:event", -1, Televisions, index, key, value)
|
TriggerClientEvent("ptelevision:event", -1, Televisions, index, key, value)
|
||||||
end
|
end
|
||||||
@@ -52,6 +53,12 @@ function SetChannel(source, data)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
RegisterNetEvent("ptelevision:requestSync", function(coords)
|
||||||
|
local _source = source
|
||||||
|
local index, data = GetTelevision(coords)
|
||||||
|
TriggerClientEvent("ptelevision:requestSync", _source, coords, {current_time = os.time()})
|
||||||
|
end)
|
||||||
|
|
||||||
RegisterNetEvent("ptelevision:event", function(data, key, value)
|
RegisterNetEvent("ptelevision:event", function(data, key, value)
|
||||||
local _source = source
|
local _source = source
|
||||||
Config.Events.ScreenInteract(_source, data, key, value, function()
|
Config.Events.ScreenInteract(_source, data, key, value, function()
|
||||||
@@ -74,29 +81,8 @@ RegisterNetEvent("ptelevision:requestUpdate", function()
|
|||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
AddEventHandler('onResourceStop', function(name)
|
|
||||||
if name == GetCurrentResourceName() then
|
|
||||||
for i=1, #Locations do
|
|
||||||
local data = Locations[i]
|
|
||||||
if (DoesEntityExist(Locations[i].obj)) then
|
|
||||||
DeleteEntity(Locations[i].obj)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
AddEventHandler('playerDropped', function(reason)
|
AddEventHandler('playerDropped', function(reason)
|
||||||
local _source = source
|
local _source = source
|
||||||
SetChannel(_source, nil)
|
SetChannel(_source, nil)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
Citizen.CreateThread(function()
|
|
||||||
Citizen.Wait(1000)
|
|
||||||
local locations = Config.Locations
|
|
||||||
for i=1, #locations do
|
|
||||||
local data = locations[i]
|
|
||||||
local obj = CreateObject(data.Model, data.Position.x, data.Position.y, data.Position.z, true)
|
|
||||||
SetEntityHeading(obj, data.Position.w)
|
|
||||||
table.insert(Locations, {data = data, obj = obj})
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
Televisions = {}
|
Televisions = {}
|
||||||
|
|
||||||
|
function v3(coord)
|
||||||
|
return vector3(coord.x, coord.y, coord.z), coord.w
|
||||||
|
end
|
||||||
|
|
||||||
function DumpArray(obj, seen)
|
function DumpArray(obj, seen)
|
||||||
if type(obj) ~= 'table' then return obj end
|
if type(obj) ~= 'table' then return obj end
|
||||||
if seen and seen[obj] then return seen[obj] end
|
if seen and seen[obj] then return seen[obj] end
|
||||||
@@ -12,7 +16,7 @@ end
|
|||||||
|
|
||||||
function GetTelevision(coords)
|
function GetTelevision(coords)
|
||||||
for k,v in pairs(Televisions) do
|
for k,v in pairs(Televisions) do
|
||||||
if #(vec3(v.coords) - vec3(coords)) < 0.01 then
|
if #(v3(v.coords) - v3(coords)) < 0.01 then
|
||||||
return k, v
|
return k, v
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user