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.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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' 
  

http://vk.com/the_kenix

Вопросы задавайте на форуме, не пишите мне в личку.

Please don't pm me.

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.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Do what I said, temporary comment out the "addBan" function, then you can test.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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 ) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

http://vk.com/the_kenix

Вопросы задавайте на форуме, не пишите мне в личку.

Please don't pm me.

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.

http://vk.com/the_kenix

Вопросы задавайте на форуме, не пишите мне в личку.

Please don't pm me.

Posted

Yeah, that's right, wrote it on a hurry.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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