BorderLine Posted May 30, 2013 Share Posted May 30, 2013 Hi everyone. I was make this simple script to community.. But i have a error badArgumento logI. At argument 2. got string "05b..(my serial)".. how fix it? Thanks for your time function autoLogin() cSerial = getPlayerSerial ( source ) local account = getAccount ( cSerial, cSerial ) if ( account ~= false ) then logIn ( source, cSerial, cSerial ) outputChatBox("Logged in successfully",source,255,255,255) else addAccount ( cSerial, cSerial ) setTimer( logIn, 2000, 1, source, cSerial, cSerial) outputChatBox("Registered and logged in successfully",source,255,255,255) end end addEventHandler ( "onPlayerJoin", getRootElement(), autoLogin ) Link to comment
xXMADEXx Posted May 30, 2013 Share Posted May 30, 2013 You cannot get an account from the serial. account getAccount ( string username, [ string password ] ) Link to comment
BorderLine Posted May 30, 2013 Author Share Posted May 30, 2013 You cannot get an account from the serial. account getAccount ( string username, [ string password ] ) Read the code again. That isnt the problem. If getSerial return a string, and login, account name dont read string, how make it? That is my problem. Link to comment
Moderators IIYAMA Posted May 30, 2013 Moderators Share Posted May 30, 2013 (edited) You may not able to use the same password as the login name. Try this: function autoLogin() local cSerial = getPlayerSerial ( source ) local pass_1 = sha256 (cSerial ) local account = getAccount ( tostring(cSerial),pass_1) if account then logIn ( source, tostring(cSerial),pass_1) outputChatBox("Logged in successfully",source,255,255,255) else local pass_2 = sha256 (cSerial ) addAccount ( tostring(cSerial), pass_2) setTimer(function() if isElement(source) then logIn ( source, tostring(cSerial),pass_2) end end,2000,1) outputChatBox("Registered and logged in successfully",source,255,255,255) end end addEventHandler ( "onPlayerJoin", root, autoLogin ) Edited May 30, 2013 by Guest Link to comment
iPrestege Posted May 30, 2013 Share Posted May 30, 2013 You may not able to use the same password as the login name.Try this: function autoLogin() local cSerial = getPlayerSerial ( source ) local pass_1 = sha256 (cSerial ) local account = getAccount ( tostring(cSerial),pass_1) if account then logIn ( source, tostring(cSerial),pass_1) outputChatBox("Logged in successfully",source,255,255,255) else local pass_2 = sha256 (cSerial ) addAccount ( tostring(cSerial), pass_2) setTimer(function() if isElement(source) then logIn ( source, tostring(cSerial),pass_2) end end) outputChatBox("Registered and logged in successfully",source,255,255,255) end end addEventHandler ( "onPlayerJoin", root, autoLogin ) Where's the timer values? Link to comment
Moderators IIYAMA Posted May 30, 2013 Moderators Share Posted May 30, 2013 @#Mr.Pres[T]ege thx updated Link to comment
BorderLine Posted May 30, 2013 Author Share Posted May 30, 2013 Dont work, Debugscript dont show messages. And when i join only showme Registered and logged in successfully msg. Link to comment
Moderators IIYAMA Posted May 30, 2013 Moderators Share Posted May 30, 2013 And when i join only showme Registered and logged in successfully msg. if that works, WHAT THE ... DOESN'T WORK! Link to comment
Castillo Posted May 30, 2013 Share Posted May 30, 2013 function autoLogin ( ) local cSerial = getPlayerSerial ( source ) local pass = sha256 ( cSerial ) local account = getAccount ( tostring ( cSerial ), pass ) if ( account ) then logIn ( source, account, pass ) outputChatBox ( "Logged in successfully", source, 255, 255, 255 ) else local account = addAccount ( tostring ( cSerial ), pass ) logIn ( source, account, pass ) outputChatBox ( "Registered and logged in successfully", source, 255, 255, 255 ) end end addEventHandler ( "onPlayerJoin", root, autoLogin ) logIn requires an account, not an username. bool logIn ( player thePlayer, account theAccount, string thePassword ) Link to comment
Moderators IIYAMA Posted May 30, 2013 Moderators Share Posted May 30, 2013 aha lol O_o but then there should be an error. Link to comment
BorderLine Posted May 30, 2013 Author Share Posted May 30, 2013 line 10.. bad argument on second argument, got boolean Link to comment
Castillo Posted May 30, 2013 Share Posted May 30, 2013 function autoLogin ( ) local cSerial = getPlayerSerial ( source ) local pass = sha256 ( cSerial ) local account = getAccount ( tostring ( cSerial ), pass ) if ( account ) then logIn ( source, account, pass ) outputChatBox ( "Logged in successfully", source, 255, 255, 255 ) else local account = addAccount ( tostring ( cSerial ), pass ) if ( account ) then logIn ( source, account, pass ) outputChatBox ( "Registered and logged in successfully", source, 255, 255, 255 ) else outputChatBox ( "Failed to register!", source ) end end end addEventHandler ( "onPlayerJoin", root, autoLogin ) Use that and see if it outputs: "Failed to register!". Link to comment
BorderLine Posted May 30, 2013 Author Share Posted May 30, 2013 "failed to register". can be the problem pass is too long? Link to comment
Castillo Posted May 30, 2013 Share Posted May 30, 2013 The script is added to acl.xml? Link to comment
BorderLine Posted May 30, 2013 Author Share Posted May 30, 2013 yup. in admin group. resource.autologin Link to comment
Moderators IIYAMA Posted May 30, 2013 Moderators Share Posted May 30, 2013 if it is because it is to big you can also create your own password protection. addEventHandler ( "onPlayerJoin", root, function ( ) -- autoLogin local cSerial = getPlayerSerial ( source ) if cSerial then -- no bugs? local pass = cSerial .. "X" -- fill this in X<------------------------------------------ local account = getAccount ( tostring ( cSerial ), pass ) if ( account ) then logIn ( source, account, pass ) outputChatBox ( "Logged in successfully", source, 255, 255, 255 ) else local account = addAccount ( tostring ( cSerial ), pass ) if ( account ) then logIn ( source, account, pass ) outputChatBox ( "Registered and logged in successfully", source, 255, 255, 255 ) else outputChatBox ( "Failed to register!", source ) end end end end) Link to comment
BorderLine Posted May 30, 2013 Author Share Posted May 30, 2013 same. "Failes to register". I do this cus serial is unique. IP change, nick change. Another data is unique? to change the serial. 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