Jump to content

[SOLVED] getAccounts()


cheez3d

Recommended Posts

I have a little problem with this code right here.

What I'm trying to do is get this script go trough all the accounts that are on the server and get the string contained by the "name" data for each account. I want this for a name checker. If the name already exists in one of the server's accounts then the player will have to choose other name. But I can't get this script working.

I can't find a way to get the account name to check the data for form getAccounts().

I hope you understand what im trying to accomplish.

Alright then. Here's the code. Any help would be appreciated.

  
addEvent("checkIfNameTaken",true) 
addEventHandler("checkIfNameTaken",getRootElement(),function() 
    for i,account in ipairs (getAccounts()) do 
        checkedAccountName = getAccountData(getAccount(account),"name") 
        if checkedAccountName == thisAccountName then 
            triggerClientEvent("showErrorOutputNameTaken",getRootElement()) 
        end 
    end 
end 
) 

Edited by Guest
Link to comment

getAccounts() returns a table with accounts, you are trying to getAccount() an account.

addEvent("checkIfNameTaken", true) 
addEventHandler("checkIfNameTaken", root, 
    function(thisAccountName) 
        for _,account in ipairs(getAccounts()) do 
            if (tostring(getAccountData(account, "name")) == thisAccountName) then 
                triggerClientEvent("showErrorOutputNameTaken", root) 
                break 
            end 
        end 
    end 
) 

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