GrubaS Posted March 14, 2015 Share Posted March 14, 2015 Hello, guys i want make script, if player with serial "XXXXXXXXXXXXXXX" then he can use the command /test i want make it in xml bcz i'll decompile server-side server-side: function test1(source) local serial = getPlayerSerial(source) local rNode = xmlLoadFile("serials.xml") xmlNodeGetValue (xmlFindChild ( rNode, "Serial"), ""..serial.."" ) if rNode then outputChatBox("#00ff00test", r, g, b, thePlayer, true) end addCommandHandler("test", test1) addEventHandler ( "onPlayerJoin", getRootElement(), test1) Link to comment
Addlibs Posted March 14, 2015 Share Posted March 14, 2015 You forgot to end the 'if' statement initialised on line 5. Link to comment
GrubaS Posted March 15, 2015 Author Share Posted March 15, 2015 lua working but what about XML? "41EF67910EADFD0C8F6528FFDA695DA3" /> Link to comment
Addlibs Posted March 15, 2015 Share Posted March 15, 2015 > >41EF67910EADFD0C8F6528FFDA695DA3>> Link to comment
GrubaS Posted March 15, 2015 Author Share Posted March 15, 2015 debug: Bad Argument @ 'xmlFindChild' [Expected number at armugent 3, got none] Bad Argument @ 'xmlNodeGetValue' [Expected xml node at argument 1, got boolean Link to comment
Addlibs Posted March 15, 2015 Share Posted March 15, 2015 function test1(source) local serial = getPlayerSerial(source) local rNode = xmlLoadFile("serials.xml") for i, v in ipairs(xmlNodeGetChildren(rNode)) do --loop through all child nodes (all nodes) local value = xmlNodeGetValue(v) --get the node's value (the text between both markup nodes i.e. Value) if value then --If value found outputChatBox(value, 255, 0, 0, source, true) --output to chatbox. end end end addCommandHandler("test", test1) addEventHandler ( "onPlayerJoin", getRootElement(), test1) Notice: The above code will output all serials from the XML to a player who joins - I do not recommend using it on an open server. 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