Jump to content

Help with different account functions


Recommended Posts

Well me and another scripter have been trying to make a different account system as the standard MTA one is bugged. We made it all and it worked fine to begin with but now it just gives lots of the same error on the same line. We can't work out what is wrong.

  
_getClientAccount = getClientAccount 
function getClientAccount(source) 
    if xml then 
        local count = 0 
        local account = xmlFindSubNode(xml,"account",count) 
        local name = getClientName(source) 
        while (xmlNodeGetAttribute(account,"name") ~= name or false) do 
            count = count + 1 
            account = xmlFindSubNode(xml,"account",count) 
        end 
        if xmlNodeGetAttribute(account,"name") == name then 
            return account 
        end 
    end 
    return false 
end  

The line with the error on:

while (xmlNodeGetAttribute(account,"name") ~= name or false) do 

with this error

Bad argument @ 'xmlNodeGetAttribute'

Link to comment

I'm pretty sure I know why: It loops, but does not detect when to stop except if the node is found it needs. If it doesn't find the correct node, it'll give an error.

EDIT: Hmmm... Didn't read well... Gotta read a bit better... =/

EDIT2: I see it! (I think =/)

It's in these lines:

local count = 0 
local account = xmlFindSubNode(xml,"account",count) 
local name = getClientName(source) 

3 lines, entirely different. Except for 1 point: A word you should avoid using if you want it to work with loops: ... The only word all 3 lines have! :P

Link to comment

i have used xml to make a account system, really i think you shoudl learn sql or make a sql account system, i have moved on to sql for my fuel script and its faster, only problem you cannot add new columbs to the table :( well when i tried it wouldnt let me and with sql u dont have to loop ither

Link to comment

use a sql data browser to see whats in the table and add columns if your just using it for your server, google sql data browser then open the registry.db which can be found in the mta folder :) thats if you want another bash at it, when i was learning it i gave up then churchill gave me the data browser link and its soo much easier lol :D

Link to comment
XML works fine and lagless for me! (it only reads & writes at the start & end, the rest is just tablework. And it's easy to edit ^^)

do you store in a table them write the table to sql ? before the server shutsdown and load it in to a table when the server starts?

No SQL, only XML. :D

I just use my own save/load engine. It only costs 0.5 secs at start and 0.5 secs at stop. Then you have lag-free limitless editable XML saving! ^^

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