Jump to content

XML problem


Recommended Posts

Why this dont upload "clans.xml"?

Server side:

function createclan() 
local clan = getElementData ( source, "clan" ) 
setAccountData ( getPlayerAccount(source), "Clan", getElementData ( source, "clan" ) ) 
  local root = xmlLoadFile ("clans.xml") 
  local clanroot = xmlFindChild (root,"clans",0) 
  if (clanroot) then 
     xmlNodeSetAttribute (clanroot,"clan", clan) 
end 
end 
addEvent ( "createclan", true ) 
addEventHandler ( "createclan", root, createclan ) 
  

clans.xml:


  

Edited by Guest
Link to comment

function createclan() 
local clan = getElementData ( source, "clan" ) 
setAccountData ( getPlayerAccount(source), "Clan", getElementData ( source, "clan" ) ) 
  local root = xmlLoadFile ("clans.xml") 
  local clanroot = xmlFindChild (root,"clans",0) 
  if (clanroot) then 
     xmlNodeSetAttribute (clanroot,"clan", clan) 
    end 
        xmlSaveFile( clanroot ) 
        xmlUnloadFile ( clanroot ) 
end 
addEvent ( "createclan", true ) 
addEventHandler ( "createclan", root, createclan ) 
  
Link to comment
function createclan() 
local clan = getElementData ( source, "clan" ) 
setAccountData ( getPlayerAccount(source), "Clan", getElementData ( source, "clan" ) ) 
  local root = xmlLoadFile ("clans.xml") 
  local clanroot = xmlFindChild (root,"clans",0) 
  if (clanroot) then 
     xmlNodeSetAttribute (clanroot,"clan", clan) 
    end 
        xmlSaveFile( clanroot ) 
        xmlUnloadFile ( clanroot ) 
end 
addEvent ( "createclan", true ) 
addEventHandler ( "createclan", root, createclan ) 
  

Nothing happens

Link to comment

Client side:

function createclan() 
if ( source == GUIEditor_Button[2] ) then 
local clan = guiGetText ( GUIEditor_Edit[1] ) 
setElementData ( localPlayer, "clan", clan) 
 triggerServerEvent ( "createclan",localPlayer) 
end 
end 
addEventHandler ( "onClientGUIClick", root, createclan ) 

Link to comment

:lol: Sorry forget something try this now :

function createclan() 
    local clan = getElementData ( source, "clan" ) 
    if not isGuestAccount ( getPlayerAccount(source) ) then 
        setAccountData ( getPlayerAccount(source), "Clan", getElementData ( source, "clan" ) ) 
    end  
    local root = xmlLoadFile ("clans.xml") 
    local clanroot = xmlFindChild (root,"clans",0) 
    if (clanroot) then 
        xmlNodeSetAttribute (clanroot,"clan", clan) 
    else 
    clanroot = xmlCreateChild(root, "clans") 
    xmlNodeSetAttribute (clanroot,"clan", clan) 
    end 
    xmlSaveFile( clanroot ) 
    xmlUnloadFile ( clanroot ) 
end 
addEvent ( "createclan", true ) 
addEventHandler ( "createclan", root, createclan ) 

Link to comment
:lol: Sorry forget something try this now :

function createclan() 
    local clan = getElementData ( source, "clan" ) 
    if not isGuestAccount ( getPlayerAccount(source) ) then 
        setAccountData ( getPlayerAccount(source), "Clan", getElementData ( source, "clan" ) ) 
    end  
    local root = xmlLoadFile ("clans.xml") 
    local clanroot = xmlFindChild (root,"clans",0) 
    if (clanroot) then 
        xmlNodeSetAttribute (clanroot,"clan", clan) 
    else 
    clanroot = xmlCreateChild(root, "clans") 
    xmlNodeSetAttribute (clanroot,"clan", clan) 
    end 
    xmlSaveFile( clanroot ) 
    xmlUnloadFile ( clanroot ) 
end 
addEvent ( "createclan", true ) 
addEventHandler ( "createclan", root, createclan ) 

Nothing happens.

Link to comment
  
  
  
function createclan() 
    local xml = xmlLoadFile ("clans.xml") 
    local clan = getElementData ( source, "clan" ) 
    if not isGuestAccount ( getPlayerAccount(source) ) then 
        setAccountData ( getPlayerAccount(source), "Clan", getElementData ( source, "clan" ) ) 
    end  
    local clanroot   
    if (not xml) then 
        xmlFile = xmlCreateFile(xml, "settings")     
        clanroot = xmlCreateChild(xml, "clans") 
        xmlNodeSetAttribute (clanroot,"clan", clan)  
    else 
        clanroot = xmlFindChild (xml,"clans",0) 
        if clanroot then 
            xmlNodeSetAttribute (clanroot,"clan", clan) 
        else 
            clanroot = xmlCreateChild(xml, "clans") 
            xmlNodeSetAttribute (clanroot,"clan", clan)  
        end 
    end 
    xmlSaveFile( xml ) 
    xmlUnloadFile ( xml ) 
end 
addEvent ( "createclan", true ) 
addEventHandler ( "createclan", root, createclan ) 
  
  

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