kevenvz Posted April 1, 2013 Posted April 1, 2013 Hello there MTA scripters, I need a bit help, I got this code but it don't say what it needs to say. I want a script that if you start the resource you see the text that are displayed in the xml file. Server: soundeffect = {} soundXML = xmlLoadFile( "commands.xml" ) addEventHandler ( "onResourceStart", resourceRoot, function ( ) for index,node in pairs ( xmlNodeGetChildren ( soundXML ) ) do if xmlNodeGetName ( node ) == "command" then soundeffect[xmlNodeGetAttribute(node,"sound")] = node outputChatBox(node) end end) Commands.xml: <commands> <command name="shit" sound="eat.mp3" /> <command name="kaas" sound="kaas.mp3" /> </commands>
Castillo Posted April 1, 2013 Posted April 1, 2013 soundeffect = { } addEventHandler ( "onResourceStart", resourceRoot, function ( ) local soundXML = xmlLoadFile( "commands.xml" ) if ( soundXML ) then for _, node in pairs ( xmlNodeGetChildren ( soundXML ) ) do if ( xmlNodeGetName ( node ) == "command" ) then soundeffect [ xmlNodeGetAttribute ( node, "name" ) ] = xmlNodeGetAttribute ( node, "sound" ) outputChatBox ( xmlNodeGetAttribute ( node, "name" ) ..": ".. xmlNodeGetAttribute ( node, "sound" ) ) end end end end ) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
kevenvz Posted April 1, 2013 Author Posted April 1, 2013 Thank you solidsnake! It works, problem solved!
Castillo Posted April 1, 2013 Posted April 1, 2013 You're welcome. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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