addAccount | Multi Theft Auto: Wiki Skip to content

addAccount

Client-side
Server-side
Shared

Pair: removeAccount

This function adds an account to the list of registered accounts of the current server.

  • Minimal account name/password length is 1 character.
  • Account name/password can not be equal to *****.
  • Account names are case-sensitive if allowCaseVariations is true.
  • Maximum account password length was 30 characters until version 1.5.4-11138. Currently there is no upper limit.

OOP Syntax Help! I don't understand this!

Syntax

account|false addAccount ( string name, string pass, [ bool allowCaseVariations = false ] )
Required Arguments
  • name: The name of the account you wish to make, this normally is the player's name.
  • pass: The password to set for this account for future logins.
Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.

  • allowCaseVariations (default: false): Whether the username is case sensitive (if this is set to true, usernames "Bob" and "bob" will refer to different accounts).

Returns

  • account|false: result

Returns an account or false if the account already exists or an error occured.

Code Examples

server

This enables players to register on your server by using /register <password> in the chat window.

function registerPlayer ( source, commandName, password )
-- Check if the password field is blank or not (only blank if they didnt enter one)
if ( password and #password > 0 ) then
--Attempt to add the account, and save its value in a var
local accountAdded = addAccount(getPlayerName(source), password)
if ( accountAdded ) then
-- Tell the user all is done
outputChatBox ( "Thank you " .. getPlayerName(source) .. ", you're now registed, you can login with /login", source )
else
-- There was an error making the account, tell the user
outputChatBox ( "Error creating account, contact the server admin", source )
end
else
-- There was an error in the syntax, tell the user the correct syntax.
outputChatBox ( "Error creating account, correct syntax: /register <password>", source )
end
end
addCommandHandler ( "register", registerPlayer ) -- add the command handler

Changelog

  • 1.5.4-11138The 30-character password length limit has been removed.