setAccountSerial | Multi Theft Auto: Wiki Skip to content

setAccountSerial

Client-side
Server-side
Shared

Added in 1.6.0 r23232

This function sets the serial number for a specified player account. It allows administrators to update or assign a new serial to registered accounts.

OOP Syntax Help! I don't understand this!

  • Method: account:setSerial(...)
  • Variable: .serial

Syntax

bool setAccountSerial ( account theAccount, string serial )
Required Arguments
  • theAccount: The account element to set the serial for.
  • serial: A valid 32-character hexadecimal string representing the new serial number.

Returns

  • bool: result

Returns true if the serial was successfully set, false otherwise.

Code Examples

server
-- Advanced example: Administrative command system
local function changePlayerSerial(player, newSerial)
local account = getPlayerAccount(player)
if (account and not isGuestAccount(account)) then
if (setAccountSerial(account, newSerial)) then
outputChatBox("Serial number updated successfully!", player, 0, 255, 0)
return true
else
outputChatBox("Failed to update serial number. Invalid format!", player, 255, 0, 0)
return false
end
else
outputChatBox("You must be logged into a registered account.", player, 255, 0, 0)
return false
end
end
-- Command to set a player's account serial
addCommandHandler("setserial", function(player, cmd, targetPlayer, newSerial)
if (not targetPlayer or not newSerial) then
outputChatBox("Usage: /setserial <player> <32-char-hex-serial>", player)
return
end
local target = getPlayerFromName(targetPlayer)
if (target) then
if (string.len(newSerial) == 32 and string.match(newSerial, "^[A-Fa-f0-9]+$")) then
changePlayerSerial(target, newSerial)
else
outputChatBox("Serial must be 32 hexadecimal characters!", player, 255, 0, 0)
end
else
outputChatBox("Player not found!", player, 255, 0, 0)
end
end)