.:HyPeX:. Posted January 30, 2014 Share Posted January 30, 2014 Should this work, if i got table like this? teams = {teamACL = {'name' = "", tag = ""}, teamACL2 = -- etc, } for v, i in ipairs(teams) do if string.find(newnick, v.tag) then if isObjectInACLGroup("user." ..(getAccountName(getPlayerAccount(player)), aclGetGroup(v)) then local team = getTeamFromName(v.name) if team then setPlayerTeam(player, team) else outputChatBox("Team wasnt found!", getRootElement()) end else kickPlayer(player, "You must be in the ACL group and logged in!") outputChatBox("Player ".. getPlayerNametagText(player).."#ffffff was kicked for trying to fake team "..v.name, getRootElement()) end end Also, could i make a account saving with json like this? local JsonCreate = toJSON(teams) setAccountData(account, "teams", JsonCreate) Thanks in advance, HyPeX. Link to comment
xXMADEXx Posted January 30, 2014 Share Posted January 30, 2014 I haven't tried this, but it should work: local teams = { teamACL = { name = "", tag = "" }, teamACL2 = { name = "Team 2", tag = "[2]" } } -- Note: Make sure that "player" and "newnick" are defined by now for i, v in pairs(teams) do if string.find(newnick, v.tag) then if isObjectInACLGroup("user." ..(getAccountName(getPlayerAccount(player)), aclGetGroup(v)) then local team = getTeamFromName(v.name) if team then setPlayerTeam(player, team) setAccountData ( getPlayerAccount ( player ), "team", v.name ) break else outputChatBox("Team wasn't found!", getRootElement()) end else kickPlayer(player, "You must be in the ACL group and logged in!") outputChatBox("Player ".. getPlayerNametagText(player).."#ffffff was kicked for trying to fake team "..v.name, getRootElement()) end end end Link to comment
.:HyPeX:. Posted January 30, 2014 Author Share Posted January 30, 2014 Yeah just wanted to know if v was inside teams and not teams itself. About the second part, any idea? (JSON one) oh and edit: im using the setAccountData just for saving teams variable. Link to comment
xXMADEXx Posted January 30, 2014 Share Posted January 30, 2014 Yeah just wanted to know if v was inside teams and not teams itself.About the second part, any idea? (JSON one) oh and edit: im using the setAccountData just for saving teams variable. V is returning the table that is inside of the "teams" table. For example, if you did this: for i, v in pairs ( teams ) do print ( tostring ( i ) ) end It would output: teamACL teamACL2 to the console. If you did this: for i, v in pairs ( teams ) do for i, v in pairs ( v ) do print ( v ) end end It would output: "" "" "Team 2" "[2]" to the console, if it makes scenes, sorry if i'm not clear enough. Link to comment
.:HyPeX:. Posted January 30, 2014 Author Share Posted January 30, 2014 Yeah just wanted to know if v was inside teams and not teams itself.About the second part, any idea? (JSON one) oh and edit: im using the setAccountData just for saving teams variable. V is returning the table that is inside of the "teams" table. For example, if you did this: for i, v in pairs ( teams ) do print ( tostring ( i ) ) end It would output: teamACL teamACL2 to the console. If you did this: for i, v in pairs ( teams ) do for i, v in pairs ( v ) do print ( v ) end end It would output: "" "" "Team 2" "[2]" to the console, if it makes scenes, sorry if i'm not clear enough. Yeah, it was in the end as i thought, thanks for the help! 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