Jump to content

String


Recommended Posts

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

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 by Guest
Link to comment
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
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
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
  • Moderators

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

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