Fix change dui functions

This commit is contained in:
Jim Shield
2025-04-14 21:58:38 +01:00
parent bd1be5e953
commit 56ef3b75b2

View File

@@ -1,5 +1,5 @@
if gameName ~= "rdr3" then
--[[
--[[
DUI Module (Experimental)
--------------------------
This module handles the creation, modification, and removal of custom DUI (Display UI)
@@ -50,21 +50,17 @@ if gameName ~= "rdr3" then
--- DuiSelect({ name = "logo", texn = "logoTex", texd = "someTxd", size = { x = 512, y = 256 } })
--- ```
function DuiSelect(data)
local imagePreview = ""
for k, v in pairs(duiList[data.name]) do
if v.tex.texn == data.texn and duiList[data.name][k] then
imagePreview = "<center>- Current Image -<br>" ..
"<img src="..duiList[data.name][k].url.." width=150px><br>" ..
"Size: ["..math.floor(data.size.x)..", "..math.floor(data.size.y).."]<br><br>"
end
end
local dialog = exports['qb-input']:ShowInput({
header = imagePreview..Loc[Config.Lan].menu["dui_new"],
submitText = Loc[Config.Lan].menu["dui_change"],
inputs = { { type = 'text', isRequired = true, name = 'url', text = Loc[Config.Lan].menu["dui_url"] } }
local imagePreview = "![test]("..data.url..")"
--local imagePreview = "<center>- Current Image -<br>" ..
-- "<img src="..data.url.." width=150px><br>" ..
-- "Size: ["..math.floor(data.size.x)..", "..math.floor(data.size.y).."]<br><br>"
local dialog = createInput(imagePreview, {
{ type = "text", text = "dui_url", name = "url", isRequired = true },
})
if dialog and dialog.url then
data.url = dialog.url
if dialog then
data.url = dialog.url or dialog[1]
-- Scan URL for valid image extension and banned words.
local searchList = { "png", "jpg", "jpeg", "gif", "webp", "bmp" }
local banList = { "porn" }
@@ -115,18 +111,15 @@ if gameName ~= "rdr3" then
--- If no URL is provided, resets to the preset value.
RegisterNetEvent(getScript()..":Server:ChangeDUI", function(data)
if not data.url then
for k, v in pairs(duiList[data.name]) do
debugPrint("^6Bridge^7: ^2Preset: ^6"..tostring(data.preset).."^7")
data.url = data.preset
else
for k, v in pairs(Locations[data.name].duiList) do
if v.tex.texn == data.texn then
debugPrint("^6Bridge^7: ^2Preset: ^6"..tostring(duiList[data.name][k].preset).."^7")
data.url = duiList[data.name][k].preset
Locations[data.name].duiList[k].url = data.url
end
end
end
for k, v in pairs(duiList[data.name]) do
if v.tex.texn == data.texn then
duiList[data.name][k].url = data.url
end
end
debugPrint("^6Bridge^7: ^3DUI^2 Sending new DUI to all players^7 - ^6"..data.url.."^7")
TriggerClientEvent(getScript()..":Client:ChangeDUI", -1, data)
end)
@@ -134,9 +127,9 @@ if gameName ~= "rdr3" then
--- Server event handler to clear DUI settings.
RegisterNetEvent(getScript()..":Server:ClearDUI", function(data)
if data.url == "-" then
for k, v in pairs(duiList[data.name]) do
for k, v in pairs(Locations[data.name].duiList) do
if v.tex.texn == data.texn then
duiList[data.name][k].url = "-"
Locations[data.name].duiList[k].url = "-"
end
end
end
@@ -165,4 +158,4 @@ if gameName ~= "rdr3" then
end)
end
end
end