SetAccountSerial
Jump to navigation
Jump to search
Syntax
bool setAccountSerial ( account theAccount, string serial )
OOP Syntax Help! I don't understand this!
- Method: account:setSerial(...)
- Variable: .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