MatXpl Posted December 31, 2010 Share Posted December 31, 2010 Hi! I need help... I wont to find xml child by index number in command, example: instructionsnode = xmlFindChild ( xmll, ""..nick.."", 0 ) and When i put in console command 2 or in chatbox /command 2 then 2 = index ( xmll, ""..nick.."", 0 ) How can i do this ? Link to comment
Castillo Posted December 31, 2010 Share Posted December 31, 2010 wtf? i don't get you, you post 1 line of code and expect to solve your problem? Link to comment
MatXpl Posted December 31, 2010 Author Share Posted December 31, 2010 function load ( player ) local nick = getPlayerNametagText(player) local xmll = xmlLoadFile("data/ovners.xml") instructionsnode = xmlFindChild ( xmll, ""..nick.."", 0 ) end addCommandHandler ( "command", player, load ) And i wont to select index of xmlFindChild ( xmll, ""..nick.."", Index number ) and if i chat /command 1 then index number = 1 how can i do this ? Link to comment
Remp Posted January 1, 2011 Share Posted January 1, 2011 function load ( player, command, index ) index = tonumber(index) -- anything passed from a command is a string, so convert to number if not index then -- if its not a valid number return outputChatBox("Please enter a valid index.", player) -- tell the player and end the function end local nick = getPlayerNametagText(player) local xmll = xmlLoadFile("data/ovners.xml") instructionsnode = xmlFindChild ( xmll, nick, index ) end addCommandHandler ( "command", player, load ) you also don't need to do ""..nick.."", you can just do 'nick' 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