AWAY FROM US - Documentation
  • 📄คู่มือการใช้งาน ( Document )
  • 🌍การใช้งานเว็บไซต์
    • วิธีการสมัครสมาชิก
    • ลืมรหัสผ่านทำยังไง ?
    • เปลี่ยน IP ที่ผูกยังไง ?
    • สถานะของทรัพยากรณ์ดูยังไง ?
  • ☄️AFUCore
    • ⚙️Configuration (ตั้งค่า)
      • Events ของอาชีพ
      • เฟรมเวิร์ค (Framework)
      • คลังไอเทม (Inventory)
      • การแจ้งเตือน (Notifications)
      • ผู้เล่น (Players)
      • อาวุธ (Weapons)
      • ดีบัค (Debug)
      • ทึกฐานข้อมูล (Queries)
    • Client
      • PlayerData
        • ข้อมูลผู้เล่น (PlayerData)
      • Functions
        • ระบบบัญชี (Accounts)
        • ระบบไอเทม (Item System)
        • ระบบอาชีพ (Job System)
        • ระบบการแจ้งเตือน (Notification System)
      • Game
    • Common
      • Faker
      • Math
      • Logger
      • String
      • Table System
      • Config
      • Timeout
    • Shared
    • Server
      • Command
      • OneSync
      • Item
      • Job
      • Player
      • xPlayer
  • 📂ทรัพยากรณ์
    • 📄วิธีการใส่ License
    • 🛍️AFU Enhanced Shop
      • คู่มือการตั้งค่า
    • 💞AFU.Status
      • exports ที่มีให้ใช้
    • 📧AFU.Mailbox
    • 🔮AFU.Gasha
      • Config.lua
      • Config.OpenZone.lua
      • ปัญหาที่พบบ่อยใน AFU.Gasha
  • ⚠️ข้อตกลงการให้บริการ
    • Terms & Conditions
    • ❓ปัญหาที่พบบ่อย
Powered by GitBook
On this page
  • ภาพรวม
  • ที่อยู่ไฟล์
  • ฟังก์ชัน
  • HasItem
  • GetPlayerItem
  • SearchInventory
  1. AFUCore
  2. Client
  3. Functions

ระบบไอเทม (Item System)

ภาพรวม

ฟังก์ชันสำหรับจัดการไอเทมในกระเป๋าผู้เล่น

ที่อยู่ไฟล์

source/client/services/item.lua

ฟังก์ชัน

HasItem

ตรวจสอบว่าไอเทมมีอยู่ในกระเป๋าหรือไม่

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

name

string

ชื่อไอเทมที่ต้องการตรวจสอบ

ค่าที่ส่งกลับ: boolean - true ถ้ามีไอเทม, false ถ้าไม่มี

-- ตัวอย่างการใช้งาน
if AFUCore.HasItem('bread') then
    print('มีขนมปังในกระเป๋า')
end

GetPlayerItem

ดึงข้อมูลไอเทมจากชื่อไอเทม

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

name

string

ชื่อไอเทมที่ต้องการดึงข้อมูล

ค่าที่ส่งกลับ: Item - ข้อมูลไอเทม (ดูโครงสร้าง Item ในส่วน Type Definitions)

-- ตัวอย่างการใช้งาน
local bread = AFUCore.GetPlayerItem('bread')
if bread then
    print(string.format('%s: จำนวน %d ชิ้น (น้ำหนัก: %.1f)', 
        bread.label, bread.count, bread.weight))
end

SearchInventory

ค้นหาไอเทมในกระเป๋าของผู้เล่น

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

items

string|string[]

ชื่อไอเทมเดี่ยว หรือ array ของชื่อไอเทม

count

boolean

true เพื่อดึงเฉพาะจำนวน, false เพื่อดึงข้อมูลไอเทมทั้งหมด

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

  • table<string, count> - ตารางของจำนวนไอเทม (ถ้า count = true)

  • table<string, Item> - ตารางของข้อมูลไอเทม (ถ้า count = false)

  • count - จำนวนไอเทม (ถ้าค้นหาไอเทมเดียวและ count = true)

  • nil - ถ้าไม่พบไอเทม

-- ตัวอย่างการค้นหาจำนวนไอเทมเดียว
local breadCount = AFUCore.SearchInventory('bread', true)
print('มีขนมปัง: ' .. (breadCount or 0) .. ' ชิ้น')

-- ตัวอย่างการค้นหาจำนวนหลายไอเทม
local itemCounts = AFUCore.SearchInventory({'bread', 'water'}, true)
for item, count in pairs(itemCounts) do
    print(string.format('%s: %d ชิ้น', item, count))
end

-- ตัวอย่างการค้นหาข้อมูลไอเทมทั้งหมด
local items = AFUCore.SearchInventory({'bread', 'water'}, false)
for name, item in pairs(items) do
    print(string.format('%s: %d ชิ้น (น้ำหนัก: %.1f)', 
        item.label, item.count, item.weight))
end
Previousระบบบัญชี (Accounts)Nextระบบอาชีพ (Job System)
☄️