Jump to content

Help Needed - Get account name


maky55

Recommended Posts

Posted

Hello, scripting newb here! I'm trying to make a test script that output True or False depending if the user is on the specified account (2kjoe2k), here is the script:

 

function getPlayerAccountName(playerSource, commandName)
    
    local accname = getAccountName(getPlayerAccount(playerSource))
            
    if accname == "2kjoe2k" then
    
        outputChatBox("True")
    else
        outputChatBox("False")
    end
end
addCommandHandler("test", getPlayerAccountName)

It's probably because I'm a newb but I can't get it to work. It doesn't post anything to chat and I get no errors with debugscript 3.

Can anyone help?

Thanks.

Posted

Yea... the command "test" cannot be used in MTA, your code looks fine and will work as soon as you change the command to something else, like "myaccount".

  • Like 1
Posted
4 minutes ago, pa3ck said:

Yea... the command "test" cannot be used in MTA, your code looks fine and will work as soon as you change the command to something else, like "myaccount".

Thank you, I can't believe I didn't think to change the name of the command!

 

 

Posted

Who would actually think that the problem might be with the command name..? I found out the hard way as well... :) You're welcome.

  • Like 2
Posted

I wasted hours fixing a completely perfect script of mine until I just went YOLO and changed the command because there was nothing else left to do :) Fun times... (not)

  • Like 1

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