1LoL1 Posted March 4, 2019 Posted March 4, 2019 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
ShayF2 Posted March 4, 2019 Posted March 4, 2019 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
1LoL1 Posted March 4, 2019 Author Posted March 4, 2019 (edited) 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 March 4, 2019 by 1LoL1
Tails Posted March 5, 2019 Posted March 5, 2019 @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.
1LoL1 Posted March 5, 2019 Author Posted March 5, 2019 (edited) 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 March 5, 2019 by 1LoL1
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