ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Server functions
  3. addAccount

Function

addAccount

Creates a new account on the server. The password is stored as a secure hash, never in plain text.

Syntax

account addAccount(string name, string password)

Arguments

namestring
Account name.
passwordstring
Password.

Differences from MTA:SA

  • These MTA:SA arguments are not here: bool allowCaseVariations = false

In MTA:SA

addAccount(string name, string pass, bool allowCaseVariations = false)

Returns

The account, or false (name taken, empty password, bad name; the reason is logged).

Example

Registering and logging in with commands.

addCommandHandler("register", function(player, cmd, name, password)
    if not name or not password then
        outputChatBox("Użycie: /register <login> <hasło>", player)
        return
    end
    local account = addAccount(name, password)
    if account then
        logIn(player, account, password)
        outputChatBox("Konto utworzone, jesteś zalogowany.", player, 0, 255, 0)
    else
        outputChatBox("Nie udało się: nazwa zajęta albo nieprawidłowa.", player, 255, 0, 0)
    end
end)

See also