N3xT Posted July 8, 2018 Share Posted July 8, 2018 (edited) 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 July 8, 2018 by N3xT Link to comment
Moderators IIYAMA Posted July 8, 2018 Moderators Share Posted July 8, 2018 Why don't you use this instead? https://wiki.multitheftauto.com/wiki/DownloadFile fetchRemote has afaik not access to those files inside of a resource. Public web folder is required! 1 Link to comment
N3xT Posted July 8, 2018 Author Share Posted July 8, 2018 I'm not trying to download anything, just want to access a .map file using fetchRemote so I could read it on the client side. Link to comment
Moderators IIYAMA Posted July 8, 2018 Moderators Share Posted July 8, 2018 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. 1 Link to comment
N3xT Posted July 8, 2018 Author Share Posted July 8, 2018 Thanks, already knew that but my problem is I don't know what's the correct path to access the resources using fetchRemote XD. Link to comment
Moderators IIYAMA Posted July 8, 2018 Moderators Share Posted July 8, 2018 (edited) 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 July 8, 2018 by IIYAMA 1 Link to comment
N3xT Posted July 8, 2018 Author Share Posted July 8, 2018 Quote resource.ResourceName.http: If enabled, the resource will be accessible from http://server_ip:22005/ResourceName/ I tried this but the URL redirect me to the resourcebrowser. Link to comment
Moderators IIYAMA Posted July 8, 2018 Moderators Share Posted July 8, 2018 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
N3xT Posted July 8, 2018 Author Share Posted July 8, 2018 (edited) Admin group, I'll try this 1 min I tried to stop the resourcemanager, still redirecting me . Edited July 8, 2018 by N3xT Link to comment
Moderators IIYAMA Posted July 8, 2018 Moderators Share Posted July 8, 2018 》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. Link to comment
N3xT Posted July 8, 2018 Author Share Posted July 8, 2018 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 IIYAMA Posted July 8, 2018 Moderators Share Posted July 8, 2018 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? 1 Link to comment
Addlibs Posted July 8, 2018 Share Posted July 8, 2018 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
N3xT Posted July 9, 2018 Author Share Posted July 9, 2018 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
Moderators IIYAMA Posted July 9, 2018 Moderators Share Posted July 9, 2018 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.) Link to comment
N3xT Posted July 9, 2018 Author Share Posted July 9, 2018 (edited) 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 July 9, 2018 by N3xT 1 Link to comment
Moderators IIYAMA Posted July 9, 2018 Moderators Share Posted July 9, 2018 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). 1 Link to comment
N3xT Posted July 9, 2018 Author Share Posted July 9, 2018 (edited) 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 July 9, 2018 by N3xT Link to comment
Moderators IIYAMA Posted July 9, 2018 Moderators Share Posted July 9, 2018 (edited) @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 July 9, 2018 by IIYAMA 1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now