goofie88 Posted January 29, 2013 Share Posted January 29, 2013 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
Castillo Posted January 29, 2013 Share Posted January 29, 2013 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
Kenix Posted January 29, 2013 Share Posted January 29, 2013 [ "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
goofie88 Posted January 29, 2013 Author Share Posted January 29, 2013 @Solidsnake14: thanks for help Solidsnake14 but unfortunately this didn't help me, i'mstill getting bans. @Kenix: thanks for your explanation, really appreciated Link to comment
Castillo Posted January 29, 2013 Share Posted January 29, 2013 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
goofie88 Posted January 29, 2013 Author Share Posted January 29, 2013 I doesn't even output anything because when I log in I get immediately banned Link to comment
Castillo Posted January 29, 2013 Share Posted January 29, 2013 Do what I said, temporary comment out the "addBan" function, then you can test. Link to comment
goofie88 Posted January 29, 2013 Author Share Posted January 29, 2013 Here's what I get: No matchs found. Your serial: A314BF0A3A7A553CA3269B3CDD6E93D2 Comparing to serial: 4BF0A3A7A553CA3269B3CA21DD6E93D2 Link to comment
Castillo Posted January 29, 2013 Share Posted January 29, 2013 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
Kenix Posted January 29, 2013 Share Posted January 29, 2013 (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 January 29, 2013 by Guest Link to comment
goofie88 Posted January 29, 2013 Author Share Posted January 29, 2013 Wow that's awesome man works like a charm now Edit: Kenix thanks for helping your code also worked ;D Link to comment
Kenix Posted January 29, 2013 Share Posted January 29, 2013 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. Link to comment
Castillo Posted January 29, 2013 Share Posted January 29, 2013 Yeah, that's right, wrote it on a hurry. Link to comment
goofie88 Posted January 29, 2013 Author Share Posted January 29, 2013 I see, i'll use Kenix code then Thanks guys 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