Jump to content

Help with command...


MatXpl

Recommended Posts

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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...