Gamesnert Posted July 12, 2008 Share Posted July 12, 2008 (edited) Hi again all, Another problem... Now about an "emergency saving system" for mabako's map editor. (since it won't save now and then, I made this just in case ) The problem is: I let it look where the script has gone wrong, and print that in the server screen. For some reason, the script below gave the last possible error: "Error: Not all necessary variables could be saved! Save aborted!" Now if you watch closely, I already wanted to check what was wrong, and put xmlSaveFile just in front of the error. I look in the file, and I see... No errors..? What is quite strange, because it DOES return false, and DOES give the error in the server window. Can anyone see what I did do wrong? (probably something stupid again... ) function saveVehicleLocation(thePlayer) if (isPlayerInVehicle(thePlayer)) then local vehicle=getPlayerOccupiedVehicle(thePlayer) local model=getVehicleID(vehicle) local x,y,z=getElementPosition(vehicle) local rx,ry,rz=getVehicleRotation(vehicle) rz=(360-rz) local xmlFile=xmlLoadFile("vehicles.xml") if xmlFile then local newVehicleLine=xmlCreateSubNode(xmlFile,"vehicle") if newVehicleLine then local sucMod=xmlNodeSetAttribute(newVehicleLine,"model",model) local sucX=xmlNodeSetAttribute(newVehicleLine,"posX",x) local sucY=xmlNodeSetAttribute(newVehicleLine,"posY",y) local sucZ=xmlNodeSetAttribute(newVehicleLine,"posZ",z) local sucRX=xmlNodeSetAttribute(newVehicleLine,"rotX",rx) local sucRY=xmlNodeSetAttribute(newVehicleLine,"rotY",ry) local sucRZ=xmlNodeSetAttribute(newVehicleLine,"rotZ",rz) if (sucMod and sucX and sucY and sucZ and secRX and sucRY and sucRZ) then xmlSaveFile(xmlFile) return true else xmlSaveFile(xmlFile) outputDebugString("Error: Not all necessary variables could be saved! Save aborted!") return false end else outputDebugString("Error: New vehicle line was not created!") end else outputDebugString("Error: File could not be opened!") return false end else return nil end end A final note: This code is being called by another resource, my commands part. Although I don't think there should be any problem in there, I post it just to be sure: call(getResourceFromName("total-war-XMLdb"),"saveVehicleLocation",thePlayer) And the reason for the strange resource name? That's just so not the ENTIRE gamemode has to start over by 1 change, but only the section XMLdb for example. Edited July 13, 2008 by Guest Link to comment
DutchCaffeine Posted July 12, 2008 Share Posted July 12, 2008 Do you have in your meta.xml the next line: <export function="function_name" /> Link to comment
Gamesnert Posted July 13, 2008 Author Share Posted July 13, 2008 Well if I didn't, I wouldn't see this in the server window eh? "Error: Not all necessary variables could be saved! Save aborted!" Link to comment
Phat Looser Posted July 13, 2008 Share Posted July 13, 2008 I think, after working through it, that I have the solution of the problem. When you call a script in LUA, it has the bug that LUA thinks this function is somewhat loaded INSIDE the script that calls it, which means you would have to put your XML file in the resource which calls the function. Since this is a theory of mine, which I developed after a few tests, I would like to hear your result. This disabled my anticheat, by the way. It made it impossible to work correctly with multiple resources. Link to comment
Gamesnert Posted July 13, 2008 Author Share Posted July 13, 2008 Although it did look like that was the solution, it wasn't... There HAS to be something with "if (sucMod and sucX and sucY and sucZ and secRX and sucRY and sucRZ) then"(or the places where they're defined) I think... The rest works perfectly! It saves the file correctly and everything... Only wrong message... (and it only saved because I added that to test which var was wrong ... NONE... ) Link to comment
Phat Looser Posted July 13, 2008 Share Posted July 13, 2008 "and secRX and" trivial, after I looked through it without the intention to save the world. You even copied and pasted this mistake twice without seeing it. Link to comment
Gamesnert Posted July 13, 2008 Author Share Posted July 13, 2008 I knew it would be something stupid... Thanks... 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