Alla fine mi sono scervellato ed ho trovato una risposta. Allora ci sono alcuni domini verificati tipo www.youtube.com e www.google.com (google.it non funge) che non hanno bisogno di richiedere il permesso per essere caricati sul browser perché sono appunto sicuri per cosi dire... Tutti gli altri domini hanno bisogno di ricevere il permesso. Comunque alla fine ho risolto così.
N.B Ho aggiunto anche un comando per caricare url direttamente in game
local webBrowser = createBrowser(1200, 675, false)
local requestedURL = ""
function LoadURL(command, url)
url = "http://"..url
loadBrowserURL(webBrowser, url)
if isBrowserDomainBlocked(url, true) then
outputChatBox(url.." is blocked! Now the browser add it to whitelist")
requestedURL = url
requestBrowserDomains({url}, true)
showCursor(true)
return
else
outputChatBox(url.." is not blocked!")
end
end
addCommandHandler("url", LoadURL)
function drawBrowser()
local x, y = 110.7, 1024.15
dxDrawMaterialLine3D(x, y, 23.25, x, y, 14.75, webBrowser, 18.2, tocolor(255, 255, 255, 255), x, y+1, 19)
end
addEventHandler("onClientPreRender", root, drawBrowser)
function whitelistChanged(whitelistedURLs)
showCursor(false)
for i, v in pairs(whitelistedURLs) do
if requestedURL == v then
loadBrowserURL(webBrowser, requestedURL)
requestedURL = ""
else
outputChatBox(url.." failed to add to whitelist!")
end
end
end
addEventHandler("onClientBrowserWhitelistChange", root, whitelistChanged)
Però sfortunatamente ho trovato un altro problema, che non ho notato giocando in locale. Se siamo in tanti nel server, il borwser viene caricato solo a chi ha digitato /url e non da tutti.. Suggerimenti?