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
  • Properties
  • ข้อมูลพื้นฐาน
  • วิธีดึง xPlayer
  • Methods
  • getIdentifier()
  • getName()
  • setName(name)
  • setGroup(newGroup)
  • getGroup()
  • getJob()
  • setJob(jobName, grade)
  • getCoords(isVectorType)
  • updateCoords()
  • setCoords(coords)
  • getAccount(accountName)
  • getAccounts(minimal)
  • addAccountMoney(accountName, amount)
  • getMoney()
  • addMoney(amount)
  • removeAccountMoney(accountName, amount)
  • removeMoney(amount)
  • setAccountMoney(accountName, amount)
  • setMoney(amount)
  • getWeight()
  • setMaxWeight(weight)
  • getWeapon(weaponName)
  • getWeaponTint(weaponName)
  • getMeta(key)
  • addWeaponComponent(weaponName, component)
  • addWeapon(weaponName, ammo, forceHand)
  • removeWeapon(weaponName)
  • removeWeaponAmmo(weaponName, ammoCount)
  • hasWeaponComponent(weaponName, component)
  • removeWeaponComponent(weaponName, component)
  • addWeaponAmmo(weaponName, ammoCount)
  • getLoadout(minimal)
  • canCarryItem(itemName, count)
  • setInventoryItem(itemName, count)
  • addInventoryItem(itemName, count)
  • removeInventoryItem(itemName, count)
  • getInventory(minimal)
  • hasItem(itemName, count)
  • canSwapItem(itemName1, count1, itemName2, count2)
  • set(key, value)
  • get(key)
  • triggerEvent(eventName, ...)
  • kick(reason)
  • showNotification(message, notifyType, length, title, position, imageExt, rawHtmlOptions)
  • showAdvancedNotification(title, subject, msg, textureDict, iconType, flash, saveToBrief, hudColorIndex)
  • showHelpNotification(msg, thisFrame, beep, duration)
  • หมายเหตุ
  1. AFUCore
  2. Server

xPlayer

Properties

ข้อมูลพื้นฐาน

Property
Type
Description

source

number

ไอดีของผู้เล่น

playerId

number

ไอดีของผู้เล่น

identifier

string

ไอเดนติฟายเออร์ของผู้เล่น

name

string

ชื่อของผู้เล่น

firstname/firstName

string

ชื่อจริงของผู้เล่น

lastname/lastName

string

นามสกุลของผู้เล่น

group

string

กลุ่มของผู้เล่น (user, mod, admin, superadmin)

job

SharedPlayerJob

อาชีพของผู้เล่น

coords

vec4

ตำแหน่งของผู้เล่น

accounts

table<string, number>

บัญชีของผู้เล่น

weight

number

น้ำหนักของผู้เล่น

maxWeight

number

น้ำหนักสูงสุดที่ผู้เล่นสามารถถือได้

loadout

table

อาวุธของผู้เล่น

inventory

table

กระเป๋าของผู้เล่น

status

table

สถานะของผู้เล่น

exp

number

ประสบการณ์ของผู้เล่น

metadata

table

ข้อมูลเพิ่มเติมของผู้เล่น

dead

boolean

สถานะการตายของผู้เล่น

วิธีดึง xPlayer

วิธีดึง xPlayer จากผู้เล่น

---@param source number ไอดีของผู้เล่น
local xPlayer = AFUCore.GetPlayerFromId(1)

---@comments Server side คับ
RegisterNetEvent('server-log-player-name', function()
    local source = source
    local xPlayer = AFUCore.GetPlayerFromId(source)
    print("ชื่อของผู้เล่นไอดี " .. source .. " คือ " .. xPlayer.name)
end)

Methods

getIdentifier()

ดึง identifier ของผู้เล่น

local identifier = xPlayer.getIdentifier()
-- returns: "steam:1100001xxxxxx"
print("Identifier ของผู้เล่นคือ " .. identifier)

getName()

ดึงชื่อของผู้เล่น

local name = xPlayer.getName()
-- returns: "John Doe"
print("ชื่อของผู้เล่นคือ " .. name)

setName(name)

ตั้งชื่อให้ผู้เล่น

Parameter
Type
Description

name

string

ชื่อใหม่ของผู้เล่น

xPlayer.setName("John Smith")
print("กำหนดชื่อให้ผู้เล่นเป็น John Smith")

setGroup(newGroup)

กำหนดกลุ่มของผู้เล่น

Parameter
Type
Description

newGroup

string

กลุ่มใหม่ (user, mod, admin, superadmin)

xPlayer.setGroup("admin")
print("กำหนดกลุ่มให้ผู้เล่นเป็น admin")

getGroup()

ดึงชื่อกลุ่มของผู้เล่น

local group = xPlayer.getGroup()
-- returns: "user"
print("ผู้เล่นอยู่ในกลุ่ม " .. group)

getJob()

ดึงข้อมูลอาชีพของผู้เล่น

local job = xPlayer.getJob()
-- returns: SharedPlayerJob object
print(json.encode(job))

setJob(jobName, grade)

กำหนดอาชีพให้ผู้เล่น

Parameter
Type
Description

jobName

string

ชื่ออาชีพ

grade

number

ระดับอาชีพ

xPlayer.setJob("police", 1)
print("กำหนดอาชีพให้ผู้เล่นเป็น police ระดับ 1")

getCoords(isVectorType)

ดึงตำแหน่งของผู้เล่น

Parameter
Type
Description

isVectorType

boolean

รูปแบบการคืนค่า (true = vec3, false = table)

local coords = xPlayer.getCoords(true)
-- returns: vec3 object
print(json.encode(coords))

updateCoords()

อัพเดทตำแหน่งของผู้เล่น

xPlayer.updateCoords()
-- returns: nil

setCoords(coords)

กำหนดตำแหน่งของผู้เล่น

Parameter
Type
Description

coords

vector4/vector3

ตำแหน่งใหม่

xPlayer.setCoords(vector4(100.0, 100.0, 50.0, 180.0))

getAccount(accountName)

ดึงข้อมูลบัญชีเงินของผู้เล่น

Parameter
Type
Description

accountName

string

ชื่อบัญชี (bank, money, black_money)

local account = xPlayer.getAccount("bank")
print(json.encode(account))

getAccounts(minimal)

ดึงข้อมูลบัญชีเงินทั้งหมด

Parameter
Type
Description

minimal

boolean

รูปแบบข้อมูลแบบย่อ

local accounts = xPlayer.getAccounts(false)
print(json.encode(accounts))

addAccountMoney(accountName, amount)

เพิ่มเงินในบัญชี

Parameter
Type
Description

accountName

string

ชื่อบัญชี

amount

number

จำนวนเงิน

xPlayer.addAccountMoney("bank", 1000)
print("เพิ่มเงิน 1000 ในบัญชี bank")

getMoney()

ดึงจำนวนเงินสด

local cash = xPlayer.getMoney()
print("จำนวนเงินสดของผู้เล่นคือ " .. cash)

addMoney(amount)

เพิ่มเงินสด

Parameter
Type
Description

amount

number

จำนวนเงิน

xPlayer.addMoney(100)
print("เพิ่มเงินสด 100")

removeAccountMoney(accountName, amount)

ลบเงินในบัญชี

Parameter
Type
Description

accountName

string

ชื่อบัญชี

amount

number

จำนวนเงิน

xPlayer.removeAccountMoney("bank", 500)
print("ลบเงิน 500 จากบัญชี bank")

removeMoney(amount)

ลบเงินสด

Parameter
Type
Description

amount

number

จำนวนเงิน

xPlayer.removeMoney(50)
print("ลบเงินสด 50")

setAccountMoney(accountName, amount)

กำหนดจำนวนเงินในบัญชี

Parameter
Type
Description

accountName

string

ชื่อบัญชี

amount

number

จำนวนเงิน

xPlayer.setAccountMoney("bank", 10000)
print("กำหนดจำนวนเงินในบัญชี bank เป็น 10000")

setMoney(amount)

กำหนดจำนวนเงินสด

Parameter
Type
Description

amount

number

จำนวนเงิน

xPlayer.setMoney(1000)
print("กำหนดจำนวนเงินสดเป็น 1000")

getWeight()

ดึงน้ำหนักปัจจุบันของผู้เล่น

local weight = xPlayer.getWeight()
-- returns: 15.5
print("น้ำหนักปัจจุบันของผู้เล่นคือ " .. weight)

setMaxWeight(weight)

กำหนดน้ำหนักสูงสุดที่ผู้เล่นสามารถถือได้

Parameter
Type
Description

weight

number

น้ำหนักสูงสุด

xPlayer.setMaxWeight(50.0)
print("กำหนดน้ำหนักสูงสุดที่ผู้เล่นสามารถถือได้เป็น 50.0")

getWeapon(weaponName)

ดึงข้อมูลอาวุธที่ผู้เล่นถืออยู่

Parameter
Type
Description

weaponName

string

ชื่ออาวุธ

local weapon = xPlayer.getWeapon("WEAPON_PISTOL")
print(weapon)

getWeaponTint(weaponName)

ดึงข้อมูลสีของอาวุธ

Parameter
Type
Description

weaponName

string

ชื่ออาวุธ

local tint = xPlayer.getWeaponTint("WEAPON_PISTOL")
print(tint)

getMeta(key)

ดึงข้อมูล metadata

Parameter
Type
Description

key

string

คีย์ของข้อมูล

local meta = xPlayer.getMeta("licenses")
print(json.encode(meta))

addWeaponComponent(weaponName, component)

เพิ่มอุปกรณ์เสริมให้อาวุธ

Parameter
Type
Description

weaponName

string

ชื่ออาวุธ

component

string

ชื่ออุปกรณ์เสริม

xPlayer.addWeaponComponent("WEAPON_PISTOL", "COMPONENT_AT_PI_SUPP_02")
print("เพิ่มอุปกรณ์เสริม COMPONENT_AT_PI_SUPP_02 ให้อาวุธ WEAPON_PISTOL")

addWeapon(weaponName, ammo, forceHand)

เพิ่มอาวุธให้ผู้เล่น

Parameter
Type
Description

weaponName

string

ชื่ออาวุธ

ammo

number

จำนวนกระสุน

forceHand

boolean

บังคับถือทันที

xPlayer.addWeapon("WEAPON_PISTOL", 100, true)
print("เพิ่มอาวุธ WEAPON_PISTOL และกระสุนจำนวน 100")

removeWeapon(weaponName)

ลบอาวุธของผู้เล่น

Parameter
Type
Description

weaponName

string

ชื่ออาวุธ

xPlayer.removeWeapon("WEAPON_PISTOL")
print("ลบอาวุธ WEAPON_PISTOL")

removeWeaponAmmo(weaponName, ammoCount)

ลบกระสุนของอาวุธ

Parameter
Type
Description

weaponName

string

ชื่ออาวุธ

ammoCount

number

จำนวนกระสุน

xPlayer.removeWeaponAmmo("WEAPON_PISTOL", 30)
print("ลบกระสุนอาวุธ WEAPON_PISTOL จำนวน 30")

hasWeaponComponent(weaponName, component)

ตรวจสอบว่ามีอุปกรณ์เสริมติดตั้งอยู่หรือไม่

Parameter
Type
Description

weaponName

string

ชื่ออาวุธ

component

string

ชื่ออุปกรณ์เสริม

local hasComponent = xPlayer.hasWeaponComponent("WEAPON_PISTOL", "COMPONENT_AT_PI_SUPP_02")
if hasComponent then
    print("มีอุปกรณ์เสริม COMPONENT_AT_PI_SUPP_02 ติดตั้งอยู่")
else
    print("ไม่มีอุปกรณ์เสริม COMPONENT_AT_PI_SUPP_02 ติดตั้งอยู่")
end

removeWeaponComponent(weaponName, component)

ลบอุปกรณ์เสริมออกจากอาวุธ

Parameter
Type
Description

weaponName

string

ชื่ออาวุธ

component

string

ชื่ออุปกรณ์เสริม

xPlayer.removeWeaponComponent("WEAPON_PISTOL", "COMPONENT_AT_PI_SUPP_02")
print("ลบอุปกรณ์เสริม COMPONENT_AT_PI_SUPP_02 ออกจากอาวุธ WEAPON_PISTOL")

addWeaponAmmo(weaponName, ammoCount)

เพิ่มกระสุนให้อาวุธ

Parameter
Type
Description

weaponName

string

ชื่ออาวุธ

ammoCount

number

จำนวนกระสุน

xPlayer.addWeaponAmmo("WEAPON_PISTOL", 50)
print("เพิ่มกระสุนให้อาวุธ WEAPON_PISTOL และกระสุนจำนวน 50")

getLoadout(minimal)

ดึงข้อมูลอาวุธทั้งหมด

Parameter
Type
Description

minimal

boolean

รูปแบบข้อมูลแบบย่อ

local loadout = xPlayer.getLoadout(false)
print(json.encode(loadout))

canCarryItem(itemName, count)

ตรวจสอบว่าสามารถถือไอเทมได้หรือไม่

Parameter
Type
Description

itemName

string

ชื่อไอเทม

count

number

จำนวน

local canCarry = xPlayer.canCarryItem("bread", 5)
if canCarry then
    print("สามารถถือไอเทมได้")
else
    print("ไม่สามารถถือไอเทมได้")
end

setInventoryItem(itemName, count)

กำหนดจำนวนไอเทมในกระเป๋า

Parameter
Type
Description

itemName

string

ชื่อไอเทม

count

number

จำนวน

xPlayer.setInventoryItem("bread", 10)
print("กำหนดจำนวนไอเทม bread เป็น 10")

addInventoryItem(itemName, count)

เพิ่มไอเทมในกระเป๋า

Parameter
Type
Description

itemName

string

ชื่อไอเทม

count

number

จำนวน

xPlayer.addInventoryItem("bread", 2)
print("เพิ่มไอเทม bread จำนวน 2")

removeInventoryItem(itemName, count)

ลบไอเทมในกระเป๋า

Parameter
Type
Description

itemName

string

ชื่อไอเทม

count

number

จำนวน

xPlayer.removeInventoryItem("bread", 1)
print("ลบไอเทม bread จำนวน 1")

getInventory(minimal)

ดึงข้อมูลไอเทมในกระเป๋าทั้งหมด

Parameter
Type
Description

minimal

boolean

รูปแบบข้อมูลแบบย่อ

local inventory = xPlayer.getInventory(false)
print(json.encode(inventory))

hasItem(itemName, count)

ตรวจสอบว่ามีไอเทมหรือไม่

Parameter
Type
Description

itemName

string

ชื่อไอเทม

count

number

จำนวนไอเทม

local hasItem = xPlayer.hasItem("bread", 1)
if hasItem then
    print("มีไอเทมจำนวน 1")
else
    print("ไม่มีไอเทมจำนวน 1")
end

canSwapItem(itemName1, count1, itemName2, count2)

ตรวจสอบว่าสามารถสลับไอเทมได้หรือไม่

Parameter
Type
Description

itemName1

string

ชื่อไอเทมที่ 1

count1

number

จำนวนไอเทมที่ 1

itemName2

string

ชื่อไอเทมที่ 2

count2

number

จำนวนไอเทมที่ 2

local canSwap = xPlayer.canSwapItem("bread", 5, "water", 3)
if canSwap then
    print("สามารถสลับไอเทมได้")
else
    print("ไม่สามารถสลับไอเทมได้")
end

set(key, value)

กำหนดข้อมูลเพิ่มเติม

Parameter
Type
Description

key

string

คีย์ของข้อมูล

value

table

ข้อมูล

xPlayer.set("customData", { level = 5 })
print("set ข้อมูล customData ของ xPlayer มีค่า level เป็น 5")

get(key)

ดึงข้อมูลเพิ่มเติม

Parameter
Type
Description

key

string

คีย์ของข้อมูล

local data = xPlayer.get("customData")
print(data.level) -- 5

triggerEvent(eventName, ...)

ส่ง event ไปยังผู้เล่น

Parameter
Type
Description

eventName

string

ชื่อ event

...

any

พารามิเตอร์เพิ่มเติม

xPlayer.triggerEvent("customEvent", "data1", "data2")
print("ส่ง event customEvent ไปยังผู้เล่นพร้อมข้อมูล string 'data1' และ 'data2'")

kick(reason)

เตะผู้เล่นออกจากเซิร์ฟเวอร์

Parameter
Type
Description

reason

string

เหตุผล

xPlayer.kick("Banned for cheating")
print("เตะผู้เล่นออกจากเซิร์ฟเวอร์พร้อมเหตุผล 'Banned for cheating'")

showNotification(message, notifyType, length, title, position, imageExt, rawHtmlOptions)

แสดงการแจ้งเตือนให้กับผู้เล่น

Parameter
Type
Description

message

string

ข้อความ

notifyType

string

ประเภทการแจ้งเตือน

length

number

ระยะเวลาแสดง

title

string

หัวข้อ

position

string

ตำแหน่ง

imageExt

string

รูปภาพ

rawHtmlOptions

table

ตัวเลือก HTML

xPlayer.showNotification("Item added!", "success", 5000, "Inventory", "top-right")
print("แสดงการแจ้งเตือนของผู้เล่นพร้อมข้อมูล 'Item added!' พร้อมประเภท 'success' ระยะเวลา 5000 มิลลิวินาที หัวข้อ 'Inventory' ตำแหน่ง 'top-right'")

showAdvancedNotification(title, subject, msg, textureDict, iconType, flash, saveToBrief, hudColorIndex)

แสดงการแจ้งเตือนขั้นสูง

Parameter
Type
Description

title

string

หัวข้อ

subject

string

หัวข้อย่อย

msg

string

ข้อความ

textureDict

string

รูปภาพ

iconType

string

ไอคอน

flash

boolean

เอฟเฟคกระพริบ

saveToBrief

boolean

บันทึกในประวัติ

hudColorIndex

number

สีของ HUD

xPlayer.showAdvancedNotification("CHAR_BANK", "Bank", "Transaction Complete", "CHAR_BANK", 1, true, true, 2)
print("แสดงการแจ้งเตือนของผู้เล่นพร้อมข้อมูล 'Transaction Complete' พร้อมประเภท 'CHAR_BANK' ระยะเวลา 5000 มิลลิวินาที หัวข้อ 'Bank' ตำแหน่ง 'top-right'")

showHelpNotification(msg, thisFrame, beep, duration)

แสดงข้อความช่วยเหลือ

Parameter
Type
Description

msg

string

ข้อความ

thisFrame

boolean

แสดงเฉพาะเฟรมนี้

beep

boolean

เสียงแจ้งเตือน

duration

number

ระยะเวลาแสดง

xPlayer.showHelpNotification("Press ~INPUT_CONTEXT~ to open menu", false, true, 5000)
print("แสดงการแจ้งเตือนของผู้เล่นพร้อมข้อมูล 'Press ~INPUT_CONTEXT~ to open menu' พร้อมประเภท 'false' ระยะเวลา 5000 มิลลิวินาที หัวข้อ 'Press ~INPUT_CONTEXT~ to open menu' ตำแหน่ง 'false'")

หมายเหตุ

  • ทุกฟังก์ชันมีการ validate ข้อมูลก่อนดำเนินการ

  • มีระบบ logging สำหรับข้อผิดพลาดต่างๆ

  • สามารถ override ฟังก์ชันและตัวแปรได้ผ่าน config

  • มีระบบป้องกันการโกงแบบพื้นฐาน

PreviousPlayerNextวิธีการใส่ License
☄️