Jump to content

Somehow not working


goofie88

Recommended Posts

hi i have a big problem, get ban when adding second serial for some reason, here is code

  
local accounts = 
    { 
        [ "goofie88" ] = "A314BF0A3A7A553CA3269B3CDD6E93D2" or "4BF0A3A7A553CA3269B3CA21DD6E93D2" 
    } 
  
  
  
function seriousProblem( _, account ) 
        local accountName = getAccountName ( account ) 
        local serial = getPlayerSerial ( source ) 
        if ( accounts [ accountName ] and accounts [ accountName ] ~= serial ) then 
            addBan ( nil, nil, serial, source) 
        end 
    end 
addEventHandler ( "onPlayerLogin", root, seriousProblem) 
  

Link to comment
local accounts = 
    { 
        [ "goofie88" ] = 
            { 
                "A314BF0A3A7A553CA3269B3CDD6E93D2", 
                "4BF0A3A7A553CA3269B3CA21DD6E93D2" 
            } 
    } 
  
function seriousProblem( _, account ) 
    local accountName = getAccountName ( account ) 
    local serial = getPlayerSerial ( source ) 
    if ( accounts [ accountName ] ) then 
        if ( type ( accounts [ accountName ] ) == "string" and accounts [ accountName ] ~= serial ) then 
            addBan ( nil, nil, serial, source ) 
        elseif ( type ( accounts [ accountName ] ) == "table" ) then 
            for _, serial_ in ipairs ( accounts [ accountName ] ) do 
                if ( serial_ ~= serial ) then 
                    addBan ( nil, nil, serial, source ) 
                    break 
                end 
            end 
        end 
    end 
end 
addEventHandler ( "onPlayerLogin", root, seriousProblem ) 

Try that instead.

Link to comment
[ "goofie88" ] = "A314BF0A3A7A553CA3269B3CDD6E93D2" or "4BF0A3A7A553CA3269B3CA21DD6E93D2" 

It's nonsense. Because value of this index will be always( You can understand what i mean if you read all ). Operator 'or' working only if your value is 'nil' or 'false'.

For example

  
print( true or false ) -- true 
print( false or true ) -- true 
print( 1 == 1 ) -- true 
print( 'something' and true or false ) -- true 
print( true and 'something' or false ) -- 'something' 
  

Link to comment
local accounts = 
    { 
        [ "goofie88" ] = 
            { 
                "A314BF0A3A7A553CA3269B3CDD6E93D2", 
                "4BF0A3A7A553CA3269B3CA21DD6E93D2" 
            } 
    } 
  
function seriousProblem( _, account ) 
    local accountName = getAccountName ( account ) 
    local serial = getPlayerSerial ( source ) 
    if ( accounts [ accountName ] ) then 
        if ( type ( accounts [ accountName ] ) == "string" and accounts [ accountName ] ~= serial ) then 
            addBan ( nil, nil, serial, source ) 
        elseif ( type ( accounts [ accountName ] ) == "table" ) then 
            for _, serial_ in ipairs ( accounts [ accountName ] ) do 
                if ( serial_ ~= serial ) then 
                    outputChatBox ( "No matchs found." ) 
                    outputChatBox ( "Your serial: ".. serial ) 
                    outputChatBox ( "Comparing to serial: ".. serial_ ) 
                    addBan ( nil, nil, serial, source ) 
                    break 
                end 
            end 
        end 
    end 
end 
addEventHandler ( "onPlayerLogin", root, seriousProblem ) 

See what it outputs to chat, you may want to comment out the 'addBan' to test it.

Link to comment

I think that I found my problem, try this one:

local accounts = 
    { 
        [ "goofie88" ] = 
            { 
                "A314BF0A3A7A553CA3269B3CDD6E93D2", 
                "4BF0A3A7A553CA3269B3CA21DD6E93D2" 
            } 
    } 
  
function seriousProblem ( _, account ) 
    local accountName = getAccountName ( account ) 
    local serial = getPlayerSerial ( source ) 
    if ( accounts [ accountName ] ) then 
        if ( type ( accounts [ accountName ] ) == "string" and accounts [ accountName ] ~= serial ) then 
            addBan ( nil, nil, serial, source ) 
        elseif ( type ( accounts [ accountName ] ) == "table" ) then 
            for _, serial_ in ipairs ( accounts [ accountName ] ) do 
                if ( serial_ == serial ) then 
                    return 
                end 
  
                addBan ( nil, nil, serial, source ) 
            end 
        end 
    end 
end 
addEventHandler ( "onPlayerLogin", root, seriousProblem ) 

Link to comment
local accounts = 
    { 
        [ "goofie88" ] = 
            { 
                "A314BF0A3A7A553CA3269B3CDD6E93D2", 
                "4BF0A3A7A553CA3269B3CA21DD6E93D2" 
            } 
    } 
  
function seriousProblem ( _, account ) 
    local accountName = getAccountName ( account ) 
    local serial = getPlayerSerial ( source ) 
    if ( accounts [ accountName ] ) then 
        if ( type ( accounts [ accountName ] ) == "string" and accounts [ accountName ] ~= serial ) then 
            addBan ( nil, nil, serial, source ) 
        elseif ( type ( accounts [ accountName ] ) == "table" ) then 
            local bFound = false 
            for _, serial_ in ipairs ( accounts [ accountName ] ) do 
                if ( serial_ == serial ) then 
                    bFound = true 
                end 
            end 
            if not bFound then 
                addBan ( nil, nil, serial, source ) 
            end 
        end 
    end 
end 
addEventHandler ( "onPlayerLogin", root, seriousProblem ) 

It's correct.

I think that I found my problem, try this one:
local accounts = 
    { 
        [ "goofie88" ] = 
            { 
                "A314BF0A3A7A553CA3269B3CDD6E93D2", 
                "4BF0A3A7A553CA3269B3CA21DD6E93D2" 
            } 
    } 
  
function seriousProblem ( _, account ) 
    local accountName = getAccountName ( account ) 
    local serial = getPlayerSerial ( source ) 
    if ( accounts [ accountName ] ) then 
        if ( type ( accounts [ accountName ] ) == "string" and accounts [ accountName ] ~= serial ) then 
            addBan ( nil, nil, serial, source ) 
        elseif ( type ( accounts [ accountName ] ) == "table" ) then 
            for _, serial_ in ipairs ( accounts [ accountName ] ) do 
                if ( serial_ == serial ) then 
                    return 
                end 
  
                addBan ( nil, nil, serial, source ) 
            end 
        end 
    end 
end 
addEventHandler ( "onPlayerLogin", root, seriousProblem ) 

It's incorrect. Because if 1st iteration fails player will be banned. Need check all table. If you don't get it then just make a very big table with serials and test it.

Edited by Guest
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...