Jump to content

XMLS Wont gonna load. :S


CowTurbo

Recommended Posts

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 :S

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 ? :S )

Link to comment
  • Moderators

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
    "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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...