sckatchof Posted October 5, 2012 Posted October 5, 2012 hello guys , why this script don't work ? local xmlFile = nil local xmlNode = nil local yearday, hour function openFile( ) local time = getRealTime( ) yearday = time.yearday hour = time.hour local fileName = ( "TNSlogs/%04d-%02d-%02d/%02d.html" ):format( time.year + 1900, time.month + 1, time.monthday, time.hour ) xmlFile = xmlLoadFile( fileName ) if not xmlFile then xmlFile = xmlCreateFile( fileName, "html" ) local head = xmlCreateChild( xmlFile, "head" ) local title = xmlCreateChild( head, "title" ) xmlNodeSetValue( title, ( "TNS MTA :: Client Logs :: %04d-%02d-%02d" ):format( time.year + 1900, time.month + 1, time.monthday ) ) local style = xmlCreateChild( head, "style" ) xmlNodeSetAttribute( style, "type", "text/css" ) xmlNodeSetValue( style, "body { font-family: Tahoma; font-size: 0.8em; background: #000000; } p { padding: 0; margin: 0; } .v1 { color: #AAAAAA; } .v2 { color: #DDDDDD; } .v3 { white-space:pre; }" ) xmlNode = xmlCreateChild( xmlFile, "body" ) xmlSaveFile( xmlFile ) else xmlNode = xmlFindChild( xmlFile, "body", 0 ) end end addEventHandler( "onClientResourceStart", getResourceRootElement( ), function( ) openFile( ) end )
scratcher911 Posted October 5, 2012 Posted October 5, 2012 change getResourceRootElement( ) to resourceRoot
sckatchof Posted October 5, 2012 Author Posted October 5, 2012 change getResourceRootElement( ) to resourceRoot thnx for help but sell don't work .
Castillo Posted October 5, 2012 Posted October 5, 2012 What exactly doesn't work? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Jaysds1 Posted October 7, 2012 Posted October 7, 2012 here's how the html file would look after the script runs: > > >"TNS MTA :: Client Logs :: 2012-11-7"> ="text/css">body{ font-family: Tahoma; font-size: 0.8em; background: #000000; } p{ padding: 0; margin: 0; } .v1{ color: #AAAAAA; } .v2{ color: #DDDDDD; } .v3{ white-space:pre; } > > > >> try this: local xmlFile = nil local xmlNode = nil local yearday, hour local time = getRealTime( ) yearday = time.yearday hour = time.hour local fileName = ( "TNSlogs/%04d-%02d-%02d/%02d.html" ):format( time.year + 1900, time.month + 1, time.monthday, hour )--already defined hour as year.hour xmlFile = xmlLoadFile( fileName ) if not xmlFile then xmlFile = xmlCreateFile( fileName, "html" ) local head = xmlCreateChild( xmlFile, "head" ) local title = xmlCreateChild( head, "title" ) xmlNodeSetValue( title, ( "TNS MTA :: Client Logs :: %04d-%02d-%02d" ):format( time.year + 1900, time.month + 1, time.monthday ) ) local style = xmlCreateChild( head, "style" ) xmlNodeSetAttribute( style, "type", "text/css" ) xmlNodeSetValue( style, "body { font-family: Tahoma; font-size: 0.8em; background: #000000; } p { padding: 0; margin: 0; } .v1 { color: #AAAAAA; } .v2 { color: #DDDDDD; } .v3 { white-space:pre; }" ) xmlNode = xmlCreateChild( xmlFile, "body" ) xmlSaveFile( xmlFile ) else xmlNode = xmlFindChild( xmlFile, "body", 0 ) end What exactly doesn't work? He's trying to make a webpage using xml. My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
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