1LoL1

Expected account

Recommended Posts

my acc: LOL
if i use /tst LOL its working but when i use /tst LOL5666 etc.. i have warning..
 

function TST(player, command, accountName)
local account = getAccount(accountName)
local player = getAccountPlayer(account)
if player then

Bad argument @ 'getAccountPlayer' [Expected account at argument 1, got boolean]

How to check account if exist? Please help me anyone

Share this post


Link to post
function TST(player, command, accountName)
  assert(type(accountName) == 'string', 'Expected string @ TST:accountName, got "'..type(accountName)..'"')
  local account = getAccount(accountName)
  assert(account, 'Unable to get account @ TST:account, got "'..type(account)..'"')
  local player = getAccountPlayer(account)
  assert(player, 'Unable to get player from account @ TST:account, got "'..type(player)..'"')
  if player then

Try this for debugging

Share this post


Link to post

Unable to get account @ TST:account, got "boolean"

i used /tst noob and this error

example:
LOL = online
ShayF = offline

/tst LOL work

/tst ShayF then nothing because account is not on on the server

Edited by 1LoL1

Share this post


Link to post

@1LoL1 cause getAccountPlayer expects an 'account' element but getAccount returns false cause it didn't find the account.

All you need to do is add a check, for example:

if account then
  -- continue here
end

Next time you use a function check the wiki page for it, it explains exactly what it will return and what it returns in case there's a mistake. In your case it didn't find the account so it returned false.

Hope this helps.

Share this post


Link to post
2 hours ago, Tails said:

@1LoL1 cause getAccountPlayer expects an 'account' element but getAccount returns false cause it didn't find the account.

All you need to do is add a check, for example:


if account then
  -- continue here
end

Next time you use a function check the wiki page for it, it explains exactly what it will return and what it returns in case there's a mistake. In your case it didn't find the account so it returned false.

Hope this helps.

ok this works thanks for help
 

function TST(player, command, accountName)
local account = getAccount(accountName)
if account then
local player = getAccountPlayer(account)
if player then

 

Edited by 1LoL1

Share this post


Link to post

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.