CowTurbo Posted March 12, 2011 Share Posted March 12, 2011 So the problems are that, XMLs wont gonna save/get files. Its like loads, everythings seems to work, saves files, unloads.. and notepad++ says, its change by other program, do you wanna reload it ? I press yes, and its still same. Same is that, it wont gonna load characters. Do no which code put here, but i will put character creating one. function createChar(skin,colred,colgreen,colblue,charactername,age) root = getResourceConfig("characters.xml") local accountName = getAccountName (getPlayerAccount(source)) outputChatBox ( accountName ) -- if not(getCharacterCount (accountName) == nil) or (getCharacterCount (accountName) <= tostring(3)) then if not (checkCharacterNameIsFake(charactername) == "FAKE") then outputChatBox ( "ITS NOT FAIKE" ) outputChatBox ( findPlayerIndexByName (tostring(accountName))) local playerRoot = xmlFindChild (root,"player",findPlayerIndexByName (tostring(accountName))) local newCharacter = xmlCreateChild (root,"character") xmlNodeSetAttribute (newCharacter,"name",charactername) xmlNodeSetAttribute (newCharacter,"skin",skin) xmlNodeSetAttribute (newCharacter,"r",colred) xmlNodeSetAttribute (newCharacter,"g",colgreen) xmlNodeSetAttribute (newCharacter,"b",colblue) xmlNodeSetAttribute (newCharacter,"age",age) xmlNodeSetAttribute (newCharacter,"x",1768.71) xmlNodeSetAttribute (newCharacter,"y",-1950.13) xmlNodeSetAttribute (newCharacter,"z",14.10) xmlNodeSetAttribute (newCharacter,"i",0) xmlNodeSetAttribute (newCharacter,"d",0) xmlNodeSetAttribute (newCharacter,"money",1500) xmlNodeSetAttribute (newCharacter,"bank",500) outputChatBox ( "NEW CHAR CREATED" ) local newVehicle = xmlCreateChild (newCharacter,"vehicle") xmlNodeSetAttribute (newVehicle,"name", "BMX") xmlNodeSetAttribute (newVehicle,"id", 0) local playerIndex = findPlayerIndexByName (tostring(accountName)) local playerNode = xmlFindChild (root,"player",playerIndex) local character = xmlNodeGetChildren (playerNode) triggerClientEvent ("hideCharCrWind",source) triggerClientEvent ("showInfo",source,"Well done! You character have created sucefully! Select character now, and start playing!") if (character[3]) then triggerClientEvent (source,"OpenCharacterSelectWindow",source,accountName,xmlNodeGetAttribute(character[1],"name"),xmlNodeGetAttribute(character[2],"name"),xmlNodeGetAttribute(character[3],"name")) elseif (character[2]) then triggerClientEvent (source,"OpenCharacterSelectWindow",source,accountName,xmlNodeGetAttribute(character[1],"name"),xmlNodeGetAttribute(character[2],"name")) elseif (character[1]) then triggerClientEvent (source,"OpenCharacterSelectWindow",source,accountName,xmlNodeGetAttribute(character[1],"name")) else triggerClientEvent (source,"OpenCharacterSelectWindow",source,accountName) end else triggerClientEvent ("showInfo",source,"Error, this character name is already in use.") end -- else -- triggerClientEvent ("showInfo",source,"Error, the character max is 3 characters!\nYou have: 3 characters!\nYou can't add new ones any more!") --end xmlSaveFile (root) xmlUnloadFile (root) end addEvent ("createNewCharacter",true) addEventHandler ("createNewCharacter",getRootElement(), createChar ) Plz, help someone, its 5000+ code This problem comed, when i stoped developting one day, it were just standing on the resource folder. I wasnt got time for script, and now when i started it again, it wont gonna work ( maybe i fucked up something before let it stand ? ) Link to comment
Moderators Citizen Posted March 12, 2011 Moderators Share Posted March 12, 2011 And there is no error ? Try to put some outputChatBox to found the problem. And if you replace getResourceConfig by xmlLoadFile ? Link to comment
CowTurbo Posted March 12, 2011 Author Share Posted March 12, 2011 no error already tryed, outputChatBox thing, seems it goes on until end correctly. Same thing with xmlLoadFile Link to comment
ChaseOquinn Posted March 12, 2011 Share Posted March 12, 2011 Is the xml file client side or server side? Link to comment
CowTurbo Posted March 12, 2011 Author Share Posted March 12, 2011 "characters.xml" type="server" /> in meta.xml Link to comment
Moderators Citizen Posted March 12, 2011 Moderators Share Posted March 12, 2011 I have a question if your function is used to create a new character, why you don't use XmlCreateChild ? It replace the current charater of the player ? You use some function like findPlayerIndexByName could you give us and explain those functions Link to comment
CowTurbo Posted March 12, 2011 Author Share Posted March 12, 2011 "mR|TurboCow" /> "TurboCow" skin="28" r="255" g="100" b="0" age="15" x="1768" y="-1950" z="14" i="0" d="0" money="1500" bank="100" /> This my characters.xml function findPlayerIndexByName (accountName) root = xmlLoadFile("characters.xml") local allPlayers = xmlNodeGetChildren (root) local k = -1 for i,v in ipairs (allPlayers) do k = k+1 if (xmlNodeGetAttribute (v,"name") == accountName) then return k end end xmlUnloadFile (root) end And this the findPlayerIndexByName function, i think you will understand what it does. Link to comment
Castillo Posted March 12, 2011 Share Posted March 12, 2011 maybe use getResourceConfig ("characters.xml") instead of xmlLoadFile. Link to comment
JasperNL=D Posted March 12, 2011 Share Posted March 12, 2011 Uhm, i don't see a bug in the code, but the XML seems bugged. It needs to be this (i suppose) <players> <player name="mR|TurboCow"> <character name="TurboCow" skin="28" r="255" g="100" b="0" age="15" x="1768" y="-1950" z="14" i="0" d="0" money="1500" bank="100" /> </player> </players> But it looks like if this doesn't matter for this script. Link to comment
Moderators Citizen Posted March 12, 2011 Moderators Share Posted March 12, 2011 maybe use getResourceConfig ("characters.xml") instead of xmlLoadFile. Lol, he used this function in his 1st post Link to comment
Castillo Posted March 13, 2011 Share Posted March 13, 2011 Oh, my bad, i suposed he was using xmlLoadFile Link to comment
CowTurbo Posted March 13, 2011 Author Share Posted March 13, 2011 Now it loads characters, but the create new char isnt working, eny help more ? Link to comment
CowTurbo Posted March 14, 2011 Author Share Posted March 14, 2011 Bug is figured out! Thx jasper! That was what the problem was, i fucked up that before.. Link to comment
Castillo Posted March 14, 2011 Share Posted March 14, 2011 Please, don't double-triple post, use the f** "EDIT" button. Link to comment
CowTurbo Posted March 15, 2011 Author Share Posted March 15, 2011 then no one wont read it 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