Chronic Posted July 11, 2014 Share Posted July 11, 2014 Hey guys, I'm having a problem with xmlLoadFile --top of the script xmlClientSettingsFile = xmlLoadFile ( "files/settings.xml" ) if xmlClientSettingsFile then outputChatBox ( "File Loaded" ) elseif not xmlClientSettingsFile then xmlClientSettingsFile = xmlCreateFile ( "files/settings.xml", "settings" ) if xmlClientSettingsFile then outputChatBox ( "Works dawg" ) else outputChatBox ( "Nope" ) end end The file exists in my MTA\mods\deathmatch folder, but it doesn't load for some reason. It always creates a new file at line 6, but still outputs "Nope" at line 9 Link to comment
koeno100 Posted July 11, 2014 Share Posted July 11, 2014 1. Is your script clientside or serverside (Regarding your script I guess clientside?) 2. Where does it create a file, clientside or serverside? Link to comment
Den. Posted July 11, 2014 Share Posted July 11, 2014 I think to actually create an xml file successfully you need to use xmlCreateFile in conjunction with xmlSaveFile, so like this: xmlClientSettingsFile = xmlLoadFile ( "files/settings.xml" ) if xmlClientSettingsFile then outputChatBox ( "File Loaded" ) elseif not xmlClientSettingsFile then xmlClientSettingsFile = xmlCreateFile ( "files/settings.xml", "settings" ) if xmlClientSettingsFile then outputChatBox ( "Works dawg" ) --Complete your work on the file here. xmlSaveFile(xmlClientSettingsFile) --Save it permanently. xmlUnloadFile(xmlClientSettingsFile) --Unload it from memory when you are done. else outputChatBox ( "Nope" ) end end If you are using xmlCreateFile server-side then the file will be saved in [MTA directory]/server/resources/[your resource/path here]. If you are using it client-side then it will be saved on the client's computer, in [MTA directory]/mods/deathmatch/resources/[your resource/path here] Link to comment
Chronic Posted July 11, 2014 Author Share Posted July 11, 2014 Yes it's saved to /mods/deathmatch/resources[my resource/path here] (client-side) The file is there, but it doesn't load, even if it creates a new one. Link to comment
Wei Posted July 11, 2014 Share Posted July 11, 2014 xmlClientSettingsFile = xmlLoadFile ( "files/settings.xml" ) if xmlClientSettingsFile then outputChatBox ( "File Loaded" ) else xmlClientSettingsFile = xmlCreateFile ( "files/settings.xml", "settings" ) end if xmlClientSettingsFile then outputChatBox ( "Works dawg" ) else outputChatBox ( "Nope" ) end You checked the xmlClientSettingsFile inside else only function, that is why it didn't check Link to comment
Chronic Posted July 11, 2014 Author Share Posted July 11, 2014 xmlClientSettingsFile = xmlLoadFile ( "files/settings.xml" ) if xmlClientSettingsFile then outputChatBox ( "File Loaded" ) else xmlClientSettingsFile = xmlCreateFile ( "files/settings.xml", "settings" ) end if xmlClientSettingsFile then outputChatBox ( "Works dawg" ) else outputChatBox ( "Nope" ) end You checked the xmlClientSettingsFile inside else only function, that is why it didn't check Thanks, it works 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