Jump to content

Clientside fetchRemote


N3xT

Recommended Posts

Hey, so I'm trying to use fetchRemote on the client side how to access a text file from the resources using fetchRemote?

what's the path to access them?, Thanks in advance.

Edited by N3xT
Link to comment
  • Moderators

Ah oke, well you need a public web folder in that case.

 


 

But keep in mind that a .map file is XML. And to read XML you need a file in order to use this function:

https://wiki.multitheftauto.com/wiki/XmlLoadFile

 

Don't make it harder than it is already.

 

@N3xT

The most secure thing you can do is to read the map file serverside. Convert it to a table format. Send it to clientside with triggerClientEvent and do what you want to do.

 

 

  • Like 1
Link to comment
  • Moderators

As I said before.That path can't be accessed, because it isn't public.

MTA is the serving the files based on the meta.xml. And FetchRemote is for public web files only.

Edit.

 

Hmm I might be wrong about that.

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

 

Check out the html meta.xml tag.

<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)

 

@N3xT

More info about the path: https://wiki.multitheftauto.com/wiki/Resource_Web_Access

Edited by IIYAMA
  • Like 1
Link to comment
  • Moderators
6 minutes ago, N3xT said:

I tried this but the URL redirect me to the resourcebrowser.

To which group did you add it?

 

And what happens if you stop the web browser resource? (Afaik it isn't required)

Link to comment
1 hour ago, IIYAMA said:

》This works as with other ACL rights - You can enable it just for Admin users, or any other group of users you wish. 《

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

 

You might have to add it to the *.user group instead. Else it will indeed reconnect you.

 

 

I've added resource.*.http along with user.* still redirecting me to the resource browser, I don't know if this is a bug or I'm doing it wrong xd.

Link to comment
  • Moderators
21 minutes ago, N3xT said:

I've added resource.*.http along with user.* still redirecting me to the resource browser, I don't know if this is a bug or I'm doing it wrong xd.

Hmmmm, interesting.

At the moment I do not have much time to test it. But in the future I might need to build an API for my server, so I am interesting in it too. Tomorrow or the day after that, I will write a test resource for this. So if you haven't figured out your issue by then, I will send you this test resource.(If it works xd) Of course I will be here for questions/support.

Hang in there, Oke? :-({|=

 

 

 

  • Like 1
Link to comment

As far as I'm aware, you need to add a trailing slash after the resource name to prevent it from redirecting to resource browser. E.g. http://serverip:port/runcode will redirect to http://serverip:port/resourcebrowser/, but http://serverip:port/runcode/ won't redirect.

All client-downloadable files from meta.xml are cached into the resource-cache/http-client-files on the server which are accessible through http://serverip:port/resourcename/filename.ext but only those which were added in the meta.xml and thus consequently copied to http-client-files by the server. Files not in meta.xml or those which cache="false" option cannot be downloaded through a web browser nor through fetchRemote as they are not located in the http-client-files directory.

Link to comment
12 hours ago, MrTasty said:

As far as I'm aware, you need to add a trailing slash after the resource name to prevent it from redirecting to resource browser. E.g. http://serverip:port/runcode will redirect to http://serverip:port/resourcebrowser/, but http://serverip:port/runcode/ won't redirect.

All client-downloadable files from meta.xml are cached into the resource-cache/http-client-files on the server which are accessible through http://serverip:port/resourcename/filename.ext but only those which were added in the meta.xml and thus consequently copied to http-client-files by the server. Files not in meta.xml or those which cache="false" option cannot be downloaded through a web browser nor through fetchRemote as they are not located in the http-client-files directory.

Okay, this works only with client files there’s no way to access server files? 

Link to comment
20 minutes ago, IIYAMA said:

Hmm, I didn't know you were using the file dynamic.

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

See heading

》Parsed files 《

 

You can also build an API, which just reads the file and writes the web output. (With the given example you can already build it.)

I'm working on a multigamemode, so I'm trying to cache the map files in the server

If the map is already cached/exist I'll use fetchRemote to read the map and build the objects, markers, etc..

 

but I don't know how to access the map file, Ex:

fetchRemote ( "http://serverip/multigamemode/yama.map" )

 

Edited by N3xT
  • Like 1
Link to comment
  • Moderators
2 minutes ago, N3xT said:

I'm working on a multigamemode, so I'm trying to cache the map files in the server

If the map is already cached/exist I'll use fetchRemote to read the map and build the objects, markers, etc..

 

but I can't access to the map file, Ex: 


fetchRemote ( "http://serverip/multigamemode/yama.map" )

 

Ah oke, still the same issue. I thought @MrTasty his input solved your issue.

Coming back on that one (as I said before).

  • Like 1
Link to comment
Quote

GTX: server sided files are NOT downloaded from web server. You should use Apache Alias which points at your resource-cache/http-client-cache and your web server. That's what I used. (If you're using different servers to host web site and MTA server then you can't do that)

2

I asked a friend ( @Mirage2287 ) who told me to use fetchRemote in the first place, He told me I should use alias and nginx.

I think this is the solution.

 

Edited by N3xT
Link to comment
  • Moderators

@N3xT

Working

 

    <acl name="Default">
        <right name="general.http" access="false"></right>
      	
      	<!-- add here -->
        <right name="resource.api-test.http" access="true"></right>
      	<!-- ------- -->
      
        <right name="general.ModifyOtherObjects" access="false"></right>
        <right name="command.start" access="false"></right>

 

https://files.fm/f/rtbmngd3

 

 


 

And if that file cache problem comes up:

https://wiki.multitheftauto.com/wiki/FileRead

https://wiki.multitheftauto.com/wiki/HttpWrite

Edited by IIYAMA
  • Like 1
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...