Noki Posted April 17, 2014 Share Posted April 17, 2014 Hey, I'm not the best with tables... at all. So, say I have a table that contains people's serials. I want to know what type of loop I'd use, and how I would detect if their serial matches any one of them from the table. I need to know the table layout as well. I don't care about efficiency by the way. local allowedSerials = { {"5y7rwfbh54ywgbvfgvnwe45gnaevhrt5"} -- Note, these aren't real serials, just examples for the sake of it {"nregaau3brquq34hqvgr85rfa348t585t"} } for k, v in ipairs (allowdSerials) do -- code end function checkForSerial() sourceSerial = getPlayerSerial(source); if (sourceSerial ~= allowedSerials[1]) then kickPlayer(source, "You ain't allowed nigga"); end end addEventHandler("onPlayerJoin", root, checkForSerial) That's what I suppose it would look like... I'm not sure. Any help would be appreciated. Thanks. Link to comment
iPrestege Posted April 17, 2014 Share Posted April 17, 2014 Hello , local allowedSerials = { ['xxxxxxxxxxxxxxxxxxxxxxxxx'] = true, ['xxxxxxxxxxxxxxxxxxxxxxxxx'] = true, ['xxxxxxxxxxxxxxxxxxxxxxxxx'] = true, } addEventHandler ( 'onPlayerConnect',root, function ( _,_,_,iSerial ) if not allowedSerials [ iSerial ] then cancelEvent ( true,'You are not allowed :O' ) end end ) Try that. Link to comment
Noki Posted April 17, 2014 Author Share Posted April 17, 2014 Forgot all about table returns... Thanks Prestege. 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