Jump to content

Help with command...


MatXpl

Recommended Posts

Posted

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 ?

MTA:SA scripts/gamemodes/misc:

http://www.mtasa.xn.pl

Posted

wtf? i don't get you, you post 1 line of code and expect to solve your problem?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

MTA:SA scripts/gamemodes/misc:

http://www.mtasa.xn.pl

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

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