Jump to content

Tables containing serials


Noki

Recommended Posts

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

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

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