Jump to content

Redownload and re-read xml file?


[PXG]Blue

Recommended Posts

Is it possible to redownload and re-read an xml file on clientside?

Here is my current code but it doesn't work:

  
  
winvis = 0 
  
  
function closeWin() 
if source == acceptbtn then 
guiSetVisible(newswin, false) 
winvis = 0 
showCursor(false,false) 
removeEventHandler("onClientFileDownloadComplete", root, dlDone) 
  
end 
end 
  
function showNews() 
if winvis == 0 then 
fileDelete("news.xml") 
news = downloadFile("news.xml") 
addEventHandler("onClientFileDownloadComplete", root, dlDone) 
end 
  
end 
addCommandHandler("news", showNews,false,false) 
  
  
  
function dlDone(file,success) 
if ( source == resourceRoot ) then 
if ( success ) then 
if ( file == "news.xml" ) then 
local xml = xmlLoadFile( "news.xml" ) 
local content = xmlNodeGetValue( xml ) 
xmlUnloadFile(xml) 
guiSetText(newsmemo, content) 
guiSetVisible(newswin, true) 
showCursor(true,true) 
elseif winvis == 1 then 
guiSetVisible(newswin, false) 
showCursor(false,false) 
end 
end 
end 
end 
  
  
  
  
  
  
  
  
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
    downloadFile("news.xml") 
  
local xml = xmlLoadFile( "news.xml" ) 
local content = xmlNodeGetValue( xml ) 
xmlUnloadFile(xml) 
        newswin = guiCreateWindow(16, 198, 255, 376, "", false) 
        guiWindowSetSizable(newswin, false) 
        guiSetAlpha(newswin, 0.66) 
  
        newsmemo = guiCreateMemo(9, 23, 236, 261, content, false, newswin) 
        guiMemoSetReadOnly(newsmemo, true) 
        acceptbtn = guiCreateButton(9, 294, 236, 72, "Got it!", false, newswin) 
        guiSetFont(acceptbtn, "default-bold-small") 
        guiSetProperty(acceptbtn, "NormalTextColour", "FFAAAAAA")     
        guiSetVisible(newswin,false) 
        addEventHandler ( "onClientGUIClick", acceptbtn, closeWin, false ) 
    end 
) 
  
  

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