blip_info support preview imgs

This commit is contained in:
Jim Shield
2024-02-08 18:37:14 +00:00
committed by GitHub
parent f8e3f64907
commit 4d1b2abd3d

View File

@@ -14,7 +14,7 @@ function loadModel(model)
else else
if not HasModelLoaded(model) then if not HasModelLoaded(model) then
if Config.System.Debug then print("^6Bridge^7: ^2Loading Model^7: '^6"..model.."^7'") end if Config.System.Debug then print("^6Bridge^7: ^2Loading Model^7: '^6"..model.."^7'") end
while not HasModelLoaded(model) and time > 0 do time -= 1 RequestModel(model) Wait(0) end while not HasModelLoaded(model) and time > 0 do time -= 1 RequestModel(model) print(time) Wait(0) end
if not HasModelLoaded(model) then time = 500 print("^6Bridge^7: ^3LoadModel^7: ^2Timed out loading model ^7'^6"..model.."^7'") end if not HasModelLoaded(model) then time = 500 print("^6Bridge^7: ^3LoadModel^7: ^2Timed out loading model ^7'^6"..model.."^7'") end
end end
end end
@@ -58,7 +58,8 @@ function playAnim(animDict, animName, duration, flag, ped)
end end
function stopAnim(animDict, animName, ped) function stopAnim(animDict, animName, ped)
StopAnimTask(ped and ped or PlayerPedId(), animName, animDict) StopAnimTask(ped or PlayerPedId(), animDict, animName, 0.5)
StopAnimTask(ped or PlayerPedId(), animName, animDict, 0.5)
unloadAnimDict(animDict) unloadAnimDict(animDict)
end end
@@ -227,8 +228,9 @@ function ensureNetToVeh(vehNetID)
return vehicle return vehicle
end end
local previewTxd = CreateRuntimeTxd(GetCurrentResourceName()..'previewTxd')
function makeBlip(data) function makeBlip(data)
local blip = AddBlipForCoord(data.coords) local blip = AddBlipForCoord(vec3(data.coords.x, data.coords.y, data.coords.z))
SetBlipAsShortRange(blip, true) SetBlipAsShortRange(blip, true)
SetBlipSprite(blip, data.sprite or 106) SetBlipSprite(blip, data.sprite or 106)
SetBlipColour(blip, data.col or 5) SetBlipColour(blip, data.col or 5)
@@ -238,8 +240,23 @@ function makeBlip(data)
BeginTextCommandSetBlipName('STRING') BeginTextCommandSetBlipName('STRING')
AddTextComponentString(tostring(data.name)) AddTextComponentString(tostring(data.name))
EndTextCommandSetBlipName(blip) EndTextCommandSetBlipName(blip)
if GetResourceState("blip_info"):find("start") or GetResourceState("blip-info"):find("start") or GetResourceState("blipinfo"):find("start") then
if data.preview then
local txname = tostring('preview'..keyGen()..keyGen())
if data.preview:find("http") then
local newTxt = CreateDui(data.preview, 512, 256)
local duihandle = GetDuiHandle(newTxt)
while not GetDuiHandle(newTxt) do Wait(0) end
CreateRuntimeTextureFromDuiHandle(previewTxd, txname, duihandle)
else
CreateRuntimeTextureFromImage(previewTxd, txname, data.preview)
end
exports["blip_info"]:SetBlipInfoImage(blip, GetCurrentResourceName()..'previewTxd', txname)
exports["blip_info"]:SetBlipInfoTitle(blip, data.name, false)
end
end
if Config.System.Debug then print("^6Bridge^7: ^6Blip ^2created for location^7: '^6"..data.name.."^7'") end if Config.System.Debug then print("^6Bridge^7: ^6Blip ^2created for location^7: '^6"..data.name.."^7'") end
return blip return blip
end end
function makeEntityBlip(data) function makeEntityBlip(data)
@@ -254,6 +271,21 @@ function makeEntityBlip(data)
BeginTextCommandSetBlipName('STRING') BeginTextCommandSetBlipName('STRING')
AddTextComponentString(tostring(data.name)) AddTextComponentString(tostring(data.name))
EndTextCommandSetBlipName(blip) EndTextCommandSetBlipName(blip)
if GetResourceState("blip_info"):find("start") or GetResourceState("blip-info"):find("start") or GetResourceState("blipinfo"):find("start") then
if data.preview then
local txname = tostring('preview'..keyGen()..keyGen())
if data.preview:find("http") then
local newTxt = CreateDui(data.preview, 512, 256)
local duihandle = GetDuiHandle(newTxt)
while not GetDuiHandle(newTxt) do Wait(0) end
CreateRuntimeTextureFromDuiHandle(previewTxd, txname, duihandle)
else
CreateRuntimeTextureFromImage(previewTxd, txname, data.preview)
end
exports["blip_info"]:SetBlipInfoImage(blip, GetCurrentResourceName()..'previewTxd', txname)
exports["blip_info"]:SetBlipInfoTitle(blip, data.name, false)
end
end
if Config.System.Debug then print("^6Bridge^7: ^6Blip ^2created for Entity^7: '^6"..data.name.."^7'") end if Config.System.Debug then print("^6Bridge^7: ^6Blip ^2created for Entity^7: '^6"..data.name.."^7'") end
return blip return blip
end end