<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ciber</id>
	<title>Multi Theft Auto: Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ciber"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/wiki/Special:Contributions/Ciber"/>
	<updated>2026-05-02T15:58:05Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetAccountName&amp;diff=49336</id>
		<title>SetAccountName</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetAccountName&amp;diff=49336"/>
		<updated>2016-09-28T17:30:20Z</updated>

		<summary type="html">&lt;p&gt;Ciber: Testing wikibot reading&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function is used to change existing [[account]]s name.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool setAccountName ( element player, string oldAccount, string newAccount )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''player''': The player who called the function.&lt;br /&gt;
* '''oldAccount''': The account you want to change.&lt;br /&gt;
* '''newAccount''': The name you wanna to apply old account on it.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if account was successfully changed, ''false'' if the old account does not exist/ the new account exist.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
setAccountName = function ( plr, old, new )&lt;br /&gt;
	if old and new then&lt;br /&gt;
		local oldAccount, newAccount, newPass = getAccount ( old ), getAccount ( new ), &amp;quot;mta&amp;quot;..math.random(10000,100000)&lt;br /&gt;
		if oldAccount and not newAccount then&lt;br /&gt;
			if addAccount ( new, newPass ) then&lt;br /&gt;
				local newAccount = getAccount ( new )&lt;br /&gt;
				local player = getAccountPlayer ( oldAccount )&lt;br /&gt;
				for index, value in pairs ( getAllAccountData ( oldAccount ) ) do&lt;br /&gt;
					setAccountData ( newAccount, index, value )&lt;br /&gt;
				end&lt;br /&gt;
				for index, value in ipairs ( aclGroupList ( ) ) do&lt;br /&gt;
					if isObjectInACLGroup ( &amp;quot;user.&amp;quot;..old, value ) then&lt;br /&gt;
						aclGroupAddObject ( value, &amp;quot;user.&amp;quot;..new )&lt;br /&gt;
						aclGroupRemoveObject ( value, &amp;quot;user.&amp;quot;..old )&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
				if player then&lt;br /&gt;
					logOut ( player )&lt;br /&gt;
					logIn ( player, newAccount, newPass )				&lt;br /&gt;
					if plr == player then&lt;br /&gt;
						outputChatBox ( &amp;quot;* Your new account and password: [ &amp;quot;..new..&amp;quot; ] [ &amp;quot;..newPass..&amp;quot; ].&amp;quot;, player, 255, 255, 0, true )&lt;br /&gt;
					else&lt;br /&gt;
						outputChatBox ( &amp;quot;* Your new account and password: [ &amp;quot;..new..&amp;quot; ] [ &amp;quot;..newPass..&amp;quot; ].&amp;quot;, player, 255, 255, 0, true )&lt;br /&gt;
						outputChatBox ( &amp;quot;* New account and password: [ &amp;quot;..new..&amp;quot; ] [ &amp;quot;..newPass..&amp;quot; ].&amp;quot;, plr, 255, 255, 0, true )&lt;br /&gt;
					end&lt;br /&gt;
				else&lt;br /&gt;
					outputChatBox ( &amp;quot;* New account and password: [ &amp;quot;..new..&amp;quot; ] [ &amp;quot;..newPass..&amp;quot; ].&amp;quot;, plr, 255, 255, 0, true )&lt;br /&gt;
				end&lt;br /&gt;
				setTimer ( removeAccount, 100, 1, oldAccount )&lt;br /&gt;
				return true&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return false&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example will change account name.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;addCommandHandler ( &amp;quot;chgAccName&amp;quot;, function ( player, _, old, new )&lt;br /&gt;
	setAccountName ( player, old, new )&lt;br /&gt;
end )&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Author==&lt;br /&gt;
Created By 3NAD.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Ciber</name></author>
	</entry>
</feed>