Kazafka Posted January 14, 2020 Share Posted January 14, 2020 (edited) This is the dumbest question I've ever asked on this forum, but I have problem even not only with this. So, how can I add scripts from different folders in my meta.xml? And in these scripts, how can I load xml files from different folders, too? Any idea? If yes, please, show me example I know, that I would use xml = xmlLoadFile("filename.xml") But how to load xml in different folders? Same <script src="script.Lua" type="server"/> But how to tell MTA to load script from different folder? Edited January 14, 2020 by VaporZ Link to comment
Bilal135 Posted January 14, 2020 Share Posted January 14, 2020 (edited) <file src="folder/filename.xml"/> xml = xmlLoadFile("folder/filename.xml") Edited January 14, 2020 by Bilal135 Link to comment
Kazafka Posted January 14, 2020 Author Share Posted January 14, 2020 1 minute ago, Bilal135 said: <file src="folder/filename.xml"/> didn't helped bro Link to comment
Kazafka Posted January 14, 2020 Author Share Posted January 14, 2020 Tryin' to do something Gimme a second... Link to comment
Moderators Patrick Posted January 14, 2020 Moderators Share Posted January 14, 2020 I think you can't do that, but you can export functions. Wiki: https://wiki.multitheftauto.com/wiki/Call Example: -- CLIENT function print_msg(msg) outputChatBox(msg) end <meta> <script src="client.Lua" type="client"/> <export function="print_msg" type="client"/> </meta> After it you can call this 'print_msg' function from other resources: -- CLIENT exports.FIRST_RESOURCE_NAME:print_msg("called from other resource") Link to comment
Kazafka Posted January 14, 2020 Author Share Posted January 14, 2020 2 minutes ago, stPatrick said: I think you can't do that, but you can export functions. Wiki: https://wiki.multitheftauto.com/wiki/Call Example: -- CLIENT function print_msg(msg) outputChatBox(msg) end <meta> <script src="client.Lua" type="client"/> <export function="print_msg" type="client"/> </meta> After it you can call this 'print_msg' function from other resources: -- CLIENT exports.FIRST_RESOURCE_NAME:print_msg("called from other resource") But, how do I load a xml file, wich is in another folder, from a script, that is in default resource folder? Link to comment
Bilal135 Posted January 14, 2020 Share Posted January 14, 2020 Lol I thought you were trying to load a file from a different folder within the same script. Link to comment
Kazafka Posted January 14, 2020 Author Share Posted January 14, 2020 <meta> <!-- Blah blah blah (info) and this: --> <script src="cars.Lua" type="client"/> <script src="bank.Lua" type="client"/> <script src="fshop.Lua" type="server"/> <script src="gunshop.Lua" type="server"/> <file src="VaporCars/shops.xml"/> <file src="VaporCars/saved.xml"/> <file src="Bank/accounts.xml"/> <file src="Bank/atms.xml"/> <file src="Gunshop/prices.xml"/> </meta> This? Is this possible? Just now, Bilal135 said: Lol I thought you were trying to load a file from a different folder within the same script. Kinda. Link to comment
Moderators Patrick Posted January 14, 2020 Moderators Share Posted January 14, 2020 (edited) So, you want to load a xml file with xmlLoadFile from other resource? Enter the full path, from the root resource folder. ( start path with : ) xmlLoadFile(":OTHER_RESOURCE_NAME/SUBFOLDER/file.xml") Edited January 14, 2020 by stPatrick 1 Link to comment
Bilal135 Posted January 14, 2020 Share Posted January 14, 2020 (edited) Probably create an export function that returns the desired xml file. @stPatrick oh I didn’t know that was even possible Edited January 14, 2020 by Bilal135 Link to comment
Kazafka Posted January 14, 2020 Author Share Posted January 14, 2020 (edited) 8 minutes ago, stPatrick said: So, you want to load a xml file with xmlLoadFile from other resource? Enter the full path, from the root resource folder. ( start path with : ) xmlLoadFile(":OTHER_RESOURCE_NAME/SUBFOLDER/file.xml") NAAAH! I want to load xml file in subfolder, but with script, that is in the same folder, as meta.xml! Aaaaand this: xml = xmlLoadFile("VaporCars/saved.xml") Doesn't work! "[...] Now you know!" ~ BELL BIV DEVOE - Poison Edited January 14, 2020 by VaporZ Link to comment
Bilal135 Posted January 14, 2020 Share Posted January 14, 2020 If you have added that in meta.xml, what does the debugscript output? Link to comment
Kazafka Posted January 14, 2020 Author Share Posted January 14, 2020 16 minutes ago, Bilal135 said: If you have added that in meta.xml, what does the debugscript output? Moving into another topic Link to comment
Kazafka Posted January 14, 2020 Author Share Posted January 14, 2020 1 minute ago, Felix5k said: try loadstring Another topic. More subfolder stuff, I guess. Link to comment
MIKI785 Posted January 15, 2020 Share Posted January 15, 2020 Is it server or client? If it's on the server, there is no need to declare the files in meta.xml for it to work. However, the resource that does the loading needs access to the general.ModifyOtherObjects permission to be able to read files located in other resources. Link to comment
Bilal135 Posted January 15, 2020 Share Posted January 15, 2020 1 hour ago, MIKI785 said: Is it server or client? If it's on the server, there is no need to declare the files in meta.xml for it to work. However, the resource that does the loading needs access to the general.ModifyOtherObjects permission to be able to read files located in other resources. His problem was solved in this topic. 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