ระบบบัญชี (Accounts)

ภาพรวม

ฟังก์ชันสำหรับจัดการบัญชีเงินของผู้เล่น

ที่อยู่ไฟล์

source/client/services/accounts.lua

ฟังก์ชัน

GetAccount

ดึงข้อมูลบัญชีตามชื่อที่ระบุ

พารามิเตอร์
ประเภท
คำอธิบาย

name

string|string[]

ชื่อบัญชีเดี่ยว หรือ array ของชื่อบัญชี

ค่าที่ส่งกลับ:

  • ClientAccount - ถ้าส่ง name เป็น string

  • table<string, ClientAccount> - ถ้าส่ง name เป็น array

  • nil - ถ้าไม่พบบัญชี

-- ตัวอย่างการดึงบัญชีเดียว
local bankAccount = AFUCore.GetAccount('bank')
if bankAccount then
    print(string.format('%s: $%d', bankAccount.label, bankAccount.money))
end

-- ตัวอย่างการดึงหลายบัญชี
local accounts = AFUCore.GetAccount({'bank', 'black_money'})
for name, account in pairs(accounts) do
    print(string.format('%s: $%d', account.label, account.money))
end

GetMoney

ดึงจำนวนเงินสดของผู้เล่น

ค่าที่ส่งกลับ: number - จำนวนเงินสด

-- ตัวอย่างการใช้งาน
local cash = AFUCore.GetMoney()
print('เงินสด: $' .. cash)

GetAccountMoney

ดึงจำนวนเงินในบัญชีที่ระบุ

พารามิเตอร์
ประเภท
คำอธิบาย

name

string|string[]

ชื่อบัญชีเดี่ยว หรือ array ของชื่อบัญชี

ค่าที่ส่งกลับ:

  • number - จำนวนเงินในบัญชี (ถ้าส่ง name เป็น string)

  • table<string, number> - ตารางของจำนวนเงินในแต่ละบัญชี (ถ้าส่ง name เป็น array)

  • nil - ถ้าไม่พบบัญชี

-- ตัวอย่างการดึงเงินบัญชีเดียว
local bankMoney = AFUCore.GetAccountMoney('bank')
print('เงินในธนาคาร: $' .. bankMoney)

-- ตัวอย่างการดึงเงินหลายบัญชี
local moneyTable = AFUCore.GetAccountMoney({'bank', 'black_money'})
for account, money in pairs(moneyTable) do
    print(string.format('%s: $%d', account, money))
end