Skip to content

Commit cbfd71c

Browse files
committed
setAccountSerial
1 parent b9307cb commit cbfd71c

File tree

4 files changed

+96
-1
lines changed

4 files changed

+96
-1
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
-- Advanced example: Administrative command system
2+
local function changePlayerSerial(player, newSerial)
3+
local account = getPlayerAccount(player)
4+
if (account and not isGuestAccount(account)) then
5+
if (setAccountSerial(account, newSerial)) then
6+
outputChatBox("Serial number updated successfully!", player, 0, 255, 0)
7+
return true
8+
else
9+
outputChatBox("Failed to update serial number. Invalid format!", player, 255, 0, 0)
10+
return false
11+
end
12+
else
13+
outputChatBox("You must be logged into a registered account.", player, 255, 0, 0)
14+
return false
15+
end
16+
end
17+
18+
-- Command to set a player's account serial
19+
addCommandHandler("setserial", function(player, cmd, targetPlayer, newSerial)
20+
if (not targetPlayer or not newSerial) then
21+
outputChatBox("Usage: /setserial <player> <32-char-hex-serial>", player)
22+
return
23+
end
24+
25+
local target = getPlayerFromName(targetPlayer)
26+
if (target) then
27+
if (string.len(newSerial) == 32 and string.match(newSerial, "^[A-Fa-f0-9]+$")) then
28+
changePlayerSerial(target, newSerial)
29+
else
30+
outputChatBox("Serial must be 32 hexadecimal characters!", player, 255, 0, 0)
31+
end
32+
else
33+
outputChatBox("Player not found!", player, 255, 0, 0)
34+
end
35+
end)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
-- Advanced example: Administrative command system
2+
local function changePlayerSerial(player, newSerial)
3+
local account = player.account
4+
if (account and not account.guest) then
5+
if (account:setSerial(newSerial)) then
6+
player:outputChat("Serial number updated successfully!", 0, 255, 0)
7+
return true
8+
else
9+
player:outputChat("Failed to update serial number. Invalid format!", 255, 0, 0)
10+
return false
11+
end
12+
else
13+
player:outputChat("You must be logged into a registered account.", 255, 0, 0)
14+
return false
15+
end
16+
end
17+
18+
-- Command to set a player's account serial
19+
addCommandHandler("setserial", function(player, cmd, targetPlayer, newSerial)
20+
if (not targetPlayer or not newSerial) then
21+
player:outputChat("Usage: /setserial <player> <32-char-hex-serial>")
22+
return
23+
end
24+
25+
local target = Player(targetPlayer)
26+
if (target) then
27+
if (newSerial:len() == 32 and newSerial:match("^[A-Fa-f0-9]+$")) then
28+
changePlayerSerial(target, newSerial)
29+
else
30+
player:outputChat("Serial must be 32 hexadecimal characters!", 255, 0, 0)
31+
end
32+
else
33+
player:outputChat("Player not found!", 255, 0, 0)
34+
end
35+
end)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
server:
2+
name: setAccountSerial
3+
version:
4+
added: 1.6.0 r23232
5+
description: This function sets the serial number for a specified player account. It allows administrators to update or assign a new [[serial]] to registered accounts.
6+
oop:
7+
element: account
8+
method: setSerial
9+
variable: serial
10+
parameters:
11+
- name: theAccount
12+
type: account
13+
description: The account element to set the serial for.
14+
- name: serial
15+
type: string
16+
description: A valid 32-character hexadecimal string representing the new serial number.
17+
returns:
18+
values:
19+
- type: bool
20+
name: result
21+
description: Returns true if the serial was successfully set, false otherwise.
22+
examples:
23+
- path: examples/setAccountSerial-1.lua
24+
- path: examples/setAccountSerial_OOP-1.lua
25+
oop: true

web/src/pages/reference/[func].astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ let funcSyntaxes = parseFunctionSyntaxes(func.id, func.data);
251251
<>
252252
<h5>Optional Arguments</h5>
253253
<p><strong>NOTE</strong>: When using <a href="/reference/Optional_Arguments">optional arguments</a>, you might need to supply all arguments before the one you wish to use.</p>
254-
<ul style="margin-top: 0;">
254+
<ul>
255255
{syntax.parameters
256256
.filter((param: any) => param.default)
257257
.map((param: any) => (

0 commit comments

Comments
 (0)