SetAccountSerial: Difference between revisions
Jump to navigation
Jump to search
(Created page with "{{server function}} __NOTOC__ {{New feature/item|3.0161|1.6.0|23232|This function sets the serial number for a specified player account. It allows administrators to update or assign a new 32-character hexadecimal serial identifier to registered accounts.}} ==Syntax== <syntaxhighlight lang="lua"> bool setAccountSerial ( account theAccount, string serial ) </syntaxhighlight> ===Required Arguments=== *'''theAccount:''' The account element to set the serial for *'''serial:...") |
No edit summary |
||
Line 1: | Line 1: | ||
{{server function}} | {{server function}} | ||
__NOTOC__ | __NOTOC__ | ||
{{New feature/item|3.0161|1.6.0|23232|This function sets the serial number for a specified player account. It allows administrators to update or assign a | {{New feature/item|3.0161|1.6.0|23232|This function sets the serial number for a specified player account. It allows administrators to update or assign a [[serial]] to registered accounts.}} | ||
==Syntax== | ==Syntax== |
Revision as of 08:02, 26 July 2025
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
Returns true if the serial was successfully set, false otherwise.
Example
-- Simple example: Set a serial for a player's account local player = getPlayerFromName("John") local account = getPlayerAccount(player) local newSerial = "A1B2C3D4E5F6789012345678901234AB" if setAccountSerial(account, newSerial) then outputChatBox("Serial updated successfully!") else outputChatBox("Failed to update serial!") end
-- Advanced example: Administrative command system 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)
See Also
- addAccount
- copyAccountData
- getAccount
- getAccountData
- getAccountName
- getAccountPlayer
- getAccountSerial
- getAccounts
- getAccountsBySerial
- getAllAccountData
- getPlayerAccount
- isGuestAccount
- logIn
- logOut
- removeAccount
- setAccountData
- setAccountPassword
- getAccountByID
- getAccountID
- getAccountIP
- getAccountsByData
- getAccountsByIP
- setAccountName