Jump to content

How to setPlayerNick to Registered Nick?


Recommended Posts

Posted

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

Posted
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?

 

Posted (edited)
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
Posted (edited)
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
Posted
function setNickToAccount()
  local account = getPlayerAccount(source)
  local accountName = getAccountName(account)
  setPlayerName(source, accountName)
end
addEventHandler("onPlayerLogin", setNickToAccount)

 

Posted (edited)
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
Posted

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

Posted

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

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