Ted Claberling

How to setPlayerNick to Registered Nick?

Recommended Posts

Hi,
I am using a login panel that player must give a username and password to it and Register then he/she can login.but my problem is his NickName in tab is what he set in MTA Settings
i want it to be that name that he Registered with.
( my login panel use xml for save datas...)

Share this post


Link to post

You need to modify the default scoreboard resource in order to replace the name shown by the actual name of the account used by the player.

Share this post


Link to post
20 minutes ago, Galactix said:

You need to modify the default scoreboard resource in order to replace the name shown by the actual name of the account used by the player.

can you explain more?
i need to add some code lines or i need to change some configs?

 

Share this post


Link to post
function setNickToAccount()
  local account = getPlayerAccount(source)
  local accountName = getAccountName(account)
  setPlayerName(source, accountName)
end
addEventHandler("onPlayerLogin", setNickToAccount)

Put this in any script and you should have the result expected.

Edited by Galactix
  • Like 1

Share this post


Link to post
44 minutes ago, Galactix said:

function setNickToAccount
  local account= getPlayerAccount(source)
  local accountName = getAccountName(account)
  setPlayerName(source, accountName)
end
addEventHandler("onPlayerLogin", getRootElement(), setNickToAccount)

Put this in any script and you should have the result expected.

expected near local error


function setNickToAccount
    local account = getPlayerAccount(source)
    local accountName = getAccountName(account)
    setPlayerName(source, accountName)
  end
  addEventHandler("onPlayerLogin", getRootElement(), setNickToAccount)
 
  addEventHandler("onPlayerChangeNick", getRootElement(), 
    function() 
        cancelEvent(); 
    end 
);

also it is whole the code

Edited by Ted Claberling

Share this post


Link to post
function setNickToAccount()
  local account = getPlayerAccount(source)
  local accountName = getAccountName(account)
  setPlayerName(source, accountName)
end
addEventHandler("onPlayerLogin", setNickToAccount)

 

Share this post


Link to post
14 minutes ago, Galactix said:

function setNickToAccount()
  local account = getPlayerAccount(source)
  local accountName = getAccountName(account)
  setPlayerName(source, accountName)
end
addEventHandler("onPlayerLogin", setNickToAccount)

 

Bad Arugment Error

Edited by Ted Claberling

Share this post


Link to post

You are adding event handler wrong, change the last line to addEventHandler("onPlayerLogin", root, setNickToAccount), please look at addEventHandler page on wiki, it explains why you use an element at argument 2.

  • Like 1

Share this post


Link to post
2 minutes ago, kieran said:

You are adding event handler wrong, change the last line to addEventHandler("onPlayerLogin", root, setNickToAccount), please look at addEventHandler page on wiki, it explains why you use an element at argument 2.

tnx it fixed <3

Share this post


Link to post

You seem like a new scripter, so one more thing...  Check IIYAMA's topic where he explains the element tree, it is very useful. :)

 

  • Like 1

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.