Jump to content

Login problem


CTCCoco

Recommended Posts

I use the command and have an error. In the console I see " Bad argument @ 'LogIn' - Line 23 "

What's the problem? Thanks.

function loginPlayer ( source, commandName, password )
  -- local registrado = getAccount( getPlayerName(thePlayer), password)
 if ( password ~= "" and password ~= nil ) then
local logueado = logIn( source, getPlayerName(source), password )
if ( logueado ) then
   outputChatBox( "Gracias " ..getPlayerName(source) ..", te has logueado con éxito.", source )
else
    outputChatBox ( "Ha ocurrido un error. Porfavor pide ayuda a un admin.", source )
end
 else
 outputChatBox ( "Usa /loguearse <contrasena>.", source )
 end
end
addCommandHandler("loguearse", loginPlayer) -- Lo añade el comando

Link to comment

logIn doesn't take the player's name as the second parameter as it seems. Look into getAccount for the account I suppose as you did in the example but commented it out.

I suppose you could do this...

if(logIn(source, getAccount(getPlayerName(source)), password)) then
outputChatBox( "Gracias " ..getPlayerName(source) ..", te has logueado con éxito.", source )
else
outputChatBox ( "Ha ocurrido un error. Porfavor pide ayuda a un admin.", source )
end

However I'm not sure as it is fairly confusing without proper documentation.

Edited by Guest
Link to comment
This doesn't work yet only work the register but thanks for try help me ..

Tell us what exactly is going wrong.

Stil the logIn Function ?

Now I have:

function loginPlayer ( thePlayer, commandName, password1 )
     if ( password1 ) then
     --[[local playerName = getPlayerName(thePlayer)
     local targetPlayer = getPlayerName ( playerName )--]]
     local targetAccount = getPlayerAccount ( thePlayer )
	-- Checking if the player actually exists
     if(logIn(thePlayer, targetAccount, password1)) then
         outputChatBox( "Gracias " ..getPlayerName(thePlayer) ..", te has logueado con éxito.", thePlayer )
     else
         outputChatBox ( "Ha ocurrido un error. Porfavor pide ayuda a un admin.", thePlayer )
     end
     else
     outputChatBox ( "Usa /loguearse <contrasena>.", thePlayer )
     end
end
addCommandHandler("loguearse", loginPlayer) -- Lo añade el comando

Its only detect the account "guest" because its the default account. How I can put the nick of the player in the logIn fuction? ( getPlayerName and getPlayerFromName doesn't work ).

Please help me an thanks.

Link to comment
....

Its only detect the account "guest" because its the default account. How I can put the nick of the player in the logIn fuction? ( getPlayerName and getPlayerFromName doesn't work ).

Please help me an thanks.

logIn function asks you for 3 arguments.

- thePlayer: The player to log into an account

- theAccount: The account to log the player into

- thePassword: The password needed to sign into this account

getPlayerAccount gives you account that player is currently using.. What's the point of logging into the same account which is also guest account? Think about it. What you want is get an already created account of the players. Look at the accounts function and what do you see there? Oh, there is getAccount function, I wonder what does it do?

This function returns an account for a specific user.

Do you think you may use this function? Is it what you want?

local ACCOUNT = getAccount( getPlayerName( player ) );
logIn( player, ACCOUNT, password );

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