Engine Class
UserService
*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่
สรุป
วิธีการ
GetUserInfosByUserIdsAsync(userIds: {any}):{any} |
GetUserFromGlobalUserIdAsync(userId: number):User |
เอกสารอ้างอิงเกี่ยวกับ API
วิธีการ
GetUserInfosByUserIdsAsync
พารามิเตอร์
ส่งค่ากลับ
ตัวอย่างโค้ด
ตัวอย่าง UserService:GetUserInfosByUserIdsAsync
local UserService = game:GetService("UserService")
local success, result = pcall(function()
return UserService:GetUserInfosByUserIdsAsync({ 156, 1, 735878936 })
end)
if success then
for _, userInfo in ipairs(result) do
print("Id:", userInfo.Id)
print("ชื่อผู้ใช้:", userInfo.Username)
print("ชื่อแสดง:", userInfo.DisplayName)
end
else
-- เกิดข้อผิดพลาด
endGetUserFromGlobalUserIdAsync
พารามิเตอร์
ส่งค่ากลับ
ตัวอย่างโค้ด
ดึงผู้ใช้จาก Global User Id แบบ Asynchronous
local UserService = game:GetService("UserService")
local user = UserService:GetUserFromGlobalUserIdAsync(globalUserId)
print(user.Id) -- รหัสผู้ใช้โดเมนสำหรับประสบการณ์นี้
print(user.DomainType) -- Enum.DomainType.EXPERIENCE
print(user.DomainId) -- รหัสจักรวาลปัจจุบัน