Jump to content

Question


Calculador

Recommended Posts

Good morning, I have a question about the following function: 

loadBrowserURL

I want to use a remote website hosted on my resource, and I put the URL as indicated by the wiki for this purpose, but it does not work, it appears as if the link was damaged. I wanted to ask if it is strictly necessary for some type of port to be open or any additional requirement for this URL to load.

For more understanding, what i want to do:

 loadBrowserURL(source, "http://mta/resource/page.html")

But this does not work.

Thanks in advance.

Link to comment
  • Moderators
9 minutes ago, Calculador said:

But this does not work.

Did you send over the file to clientside?

  • <file /> A client-side file. Generally these are images, .txd, .col, .dff or .xml files. They'll be downloaded by clients when the resources is started (or on join)
    • src: client-side file name (can be path too eg. "images/image.png")
    • download: Whether or not to be sent to the client automatically (optional). Default is "true". Using "false" will mean they are not sent on resource start but could later be used by downloadFile.

 

Or did you let the server host it?

<html />

  • src: The filename for the HTTP file (can be a path)
  • default: The html file is one that is shown by default when visiting /resourceName/ on the server. Only one html can be default, the rest are ignored. (true/false)
  • raw: The html file is not parsed by the Lua interpreter and is treated as binary data. Must be used for binary files (images mainly) (true/false)

 

 

https://wiki.multitheftauto.com/wiki/Meta.xml

You must first do one of those two, to make it accessible.

Link to comment

@IIYAMA  

What I tried to do at the beginning was to try thus example of the wiki:

local browser = guiGetBrowser(guiCreateBrowser(200, 200, 400, 200, true, false, false))

addEventHandler("onClientBrowserCreated", browser,
    function ()
        loadBrowserURL(source, "http://mta/local/page.html") --Containing <span id="nick"></span> somewhere in the file
    end)

--The page has to load first
addEventHandler("onClientBrowserDocumentReady", browser,
    function ()
        executeBrowserJavascript(source, "document.getElementById('nick').innerHTML = '" .. getPlayerName(localPlayer) .. "'");
    end)

But my file of html does not work.

In the meta i did put this:

 <html src='page.html' default='true' />

 

Link to comment
  • Moderators
2 minutes ago, Calculador said:

@IIYAMA 

So how could the local server do it and be read by the URL?

Did you read the wiki page I send you?

 

It explains you very well which URL you have to use.

Heading #Specifying_a_file_in_the_meta

https://wiki.multitheftauto.com/wiki/Resource_Web_Access#Specifying_a_file_in_the_meta

 

Try it and if it doesn't work, come back with the updated code.

Link to comment

Thanks, this work without the tag "html" in the meta. 

But  I came up another question about the section "Resource Web Access": 


In the example that propose so that through a button made in html a message is sent on the server,  could be executed only with a host that has availability to open the website in that way, or it could also be locally ?

 

Link to comment
  • Moderators
1 hour ago, Calculador said:

"Resource Web Access": 


In the example that propose so that through a button made in html a message is sent on the server,  could be executed only with a host that has availability to open the website in that way, or it could also be locally ?

This section is for making your server a website.

 

 

But yes you can also do it locally.

 

Which starts with:

local webBrowser = createBrowser(screenWidth, screenHeight, true, false)

element createBrowser ( int width, int height, bool isLocal [, bool transparent = false ] )

 

URL root

http://mta/local/

 

 

ALL the assets in the meta.xml:

	<file src="index.html" />
	<file src="js/main.js" />
	<file src="css/reset.css" />
	<file src="css/master.css" />

html, css, js, images, etc.

 

Edited by IIYAMA
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...