..:D&G:.. Posted April 20, 2016 Share Posted April 20, 2016 So I store player's account names into a JSON table like this: "[[user1, User2]]" and I want to check if the player's account name is in the table, something like... local theTable = fromJSON(owners) if isPlayerAccountInTable(thePlayer, theTable) then Thanks Link to comment
Arsilex Posted April 21, 2016 Share Posted April 21, 2016 local theTable = fromJSON(owners) function isPlayerAccountInTable(thePlayer, theTable) local account = getPlayerAccount ( thePlayer ) if account then local accountName = getAccountName ( account ) if accountName then for i, k in ipairs(theTable) do if k == accountName then return true end end else outputChatBox("Cannot get account name") end else outputChatBox("Cannot get player's account") end return false end if isPlayerAccountInTable(getPlayerFromName("Arsilex"), theTable) then outputChatBox("Account found") end Link to comment
..:D&G:.. Posted April 21, 2016 Author Share Posted April 21, 2016 Lol I forgot I can use "ipairs".. Thanks a lot! Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now