Jump to content

changenick to PlayerAccount


monamour

Recommended Posts

Posted (edited)

hello everyone,

am trying to make script which change playernick to his accountname after he login ( making player having same nick as his account name if he log in)

iv'e tried this but it did not worked: 

addEventHandler ( 'onPlayerLogin', getRootElement ( ),
    function (, changnick )
    localgetPlayerAccount(theCurrentAccount)
then
    setPlayerName ( sPlayerElement, thecurrentaccount )

 

i know there are many mistakes in this script but am just new and i hope to learn

please help me to fix it

Edited by monamour
  • Moderators
Posted (edited)
addEventHandler ( "onPlayerLogin", root,
function (_, theCurrentAccount )
	setPlayerName ( source, getAccountName(theCurrentAccount) )
end)

 


https://wiki.multitheftauto.com/wiki/GetAccountName

 
  1. string getAccountName ( account theAccount )

 

 


https://wiki.multitheftauto.com/wiki/OnPlayerLogin

Parameters

 
  1.  
  • thePreviousAccount: The account the player was logged into before
  • theCurrentAccount: The account the player logged into just now

 

Source

The source of this event is the player element that just logged in.

Edited by IIYAMA

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   ?

 

  Useful functions  3x 

  Tutorials  4x 

 

  • Moderators
Posted

Show me the lua file and the meta.xml file.

 

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   ?

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted (edited)
12 minutes ago, IIYAMA said:

Show me the lua file and the meta.xml file.

 

meta.xml:

<meta>
    <info name="changenick" author="Gamesnert" type="script" version="0.9.0" description="This resource change nick to account when player login"/>
    
    <script src="changenick_s.lua" type="server"/>
</meta>

 

Lua:

addEventHandler ( "onPlayerLogin", root,

function (_, theCurrentAccount )

setPlayerName ( source, getAccountName(theCurrentAccount) )

end)

Edit : am sorry but it works now , ive forgot to upgrade the Resource 

Thank you very much to help me with this script , i really appreciate it 

i will upload it to community and give you credit for it if you dont mind

Edited by monamour
  • Moderators
Posted
19 hours ago, pa3ck said:

@Pirulax he just said he got it working.. on Sunday.. 

I know, but i just gave him tips, if he asks for help in the future.

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