Jump to content

Help Please, XML


GrubaS

Recommended Posts

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

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