Jump to content

Somehow not working


goofie88

Recommended Posts

Posted

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) 
  

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

Posted
[ "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' 
  

Posted

@Solidsnake14: thanks for help Solidsnake14 but unfortunately this didn't help me, i'mstill getting bans.

@Kenix: thanks for your explanation, really appreciated

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

Posted

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 ) 

Posted (edited)
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
Posted

No problem. Good luck.

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

Remember. If you use Solidsnake14's code.

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