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 จากผู้เล่น

Methods

getIdentifier()

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

getName()

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

setName(name)

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

Parameter
Type
Description

name

string

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

setGroup(newGroup)

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

Parameter
Type
Description

newGroup

string

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

getGroup()

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

getJob()

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

setJob(jobName, grade)

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

Parameter
Type
Description

jobName

string

ชื่ออาชีพ

grade

number

ระดับอาชีพ

getCoords(isVectorType)

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

Parameter
Type
Description

isVectorType

boolean

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

updateCoords()

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

setCoords(coords)

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

Parameter
Type
Description

coords

vector4/vector3

ตำแหน่งใหม่

getAccount(accountName)

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

Parameter
Type
Description

accountName

string

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

getAccounts(minimal)

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

Parameter
Type
Description

minimal

boolean

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

addAccountMoney(accountName, amount)

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

Parameter
Type
Description

accountName

string

ชื่อบัญชี

amount

number

จำนวนเงิน

getMoney()

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

addMoney(amount)

เพิ่มเงินสด

Parameter
Type
Description

amount

number

จำนวนเงิน

removeAccountMoney(accountName, amount)

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

Parameter
Type
Description

accountName

string

ชื่อบัญชี

amount

number

จำนวนเงิน

removeMoney(amount)

ลบเงินสด

Parameter
Type
Description

amount

number

จำนวนเงิน

setAccountMoney(accountName, amount)

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

Parameter
Type
Description

accountName

string

ชื่อบัญชี

amount

number

จำนวนเงิน

setMoney(amount)

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

Parameter
Type
Description

amount

number

จำนวนเงิน

getWeight()

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

setMaxWeight(weight)

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

Parameter
Type
Description

weight

number

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

getWeapon(weaponName)

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

Parameter
Type
Description

weaponName

string

ชื่ออาวุธ

getWeaponTint(weaponName)

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

Parameter
Type
Description

weaponName

string

ชื่ออาวุธ

getMeta(key)

ดึงข้อมูล metadata

Parameter
Type
Description

key

string

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

addWeaponComponent(weaponName, component)

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

Parameter
Type
Description

weaponName

string

ชื่ออาวุธ

component

string

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

addWeapon(weaponName, ammo, forceHand)

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

Parameter
Type
Description

weaponName

string

ชื่ออาวุธ

ammo

number

จำนวนกระสุน

forceHand

boolean

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

removeWeapon(weaponName)

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

Parameter
Type
Description

weaponName

string

ชื่ออาวุธ

removeWeaponAmmo(weaponName, ammoCount)

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

Parameter
Type
Description

weaponName

string

ชื่ออาวุธ

ammoCount

number

จำนวนกระสุน

hasWeaponComponent(weaponName, component)

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

Parameter
Type
Description

weaponName

string

ชื่ออาวุธ

component

string

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

removeWeaponComponent(weaponName, component)

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

Parameter
Type
Description

weaponName

string

ชื่ออาวุธ

component

string

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

addWeaponAmmo(weaponName, ammoCount)

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

Parameter
Type
Description

weaponName

string

ชื่ออาวุธ

ammoCount

number

จำนวนกระสุน

getLoadout(minimal)

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

Parameter
Type
Description

minimal

boolean

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

canCarryItem(itemName, count)

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

Parameter
Type
Description

itemName

string

ชื่อไอเทม

count

number

จำนวน

setInventoryItem(itemName, count)

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

Parameter
Type
Description

itemName

string

ชื่อไอเทม

count

number

จำนวน

addInventoryItem(itemName, count)

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

Parameter
Type
Description

itemName

string

ชื่อไอเทม

count

number

จำนวน

removeInventoryItem(itemName, count)

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

Parameter
Type
Description

itemName

string

ชื่อไอเทม

count

number

จำนวน

getInventory(minimal)

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

Parameter
Type
Description

minimal

boolean

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

hasItem(itemName, count)

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

Parameter
Type
Description

itemName

string

ชื่อไอเทม

count

number

จำนวนไอเทม

canSwapItem(itemName1, count1, itemName2, count2)

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

Parameter
Type
Description

itemName1

string

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

count1

number

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

itemName2

string

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

count2

number

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

set(key, value)

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

Parameter
Type
Description

key

string

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

value

table

ข้อมูล

get(key)

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

Parameter
Type
Description

key

string

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

triggerEvent(eventName, ...)

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

Parameter
Type
Description

eventName

string

ชื่อ event

...

any

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

kick(reason)

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

Parameter
Type
Description

reason

string

เหตุผล

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

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

showHelpNotification(msg, thisFrame, beep, duration)

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

Parameter
Type
Description

msg

string

ข้อความ

thisFrame

boolean

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

beep

boolean

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

duration

number

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

หมายเหตุ

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

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

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

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