kevenvz Posted April 1, 2013 Share 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> Link to comment
Castillo Posted April 1, 2013 Share 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 ) Link to comment
kevenvz Posted April 1, 2013 Author Share Posted April 1, 2013 Thank you solidsnake! It works, problem solved! Link to comment
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