Skip to main content

Commands (Server-side)

Commands

onExecuted

ทำงานเมื่อดำเนินการใช้คำสั่งเสร็จสิ้นแล้ว

บรรทัดที่ 22
function Commands.onExecuted(source, command, success, response)
local client <const> = (source > 0 and source or nil)

if success then
return respHandler[command.key](client, response)
elseif client then
return Commands.sendClientMessage(client, false, ("Failed to execute command '^3%s^7': ^1%s^7."):format(command.raw, response.message))
end

print(("[^1ERROR^7] Failed to execute command '^3%s^7': ^1%s^7."):format(command.raw, response.message))
end

Parameters

  • source: integer
    • Net ID ของผู้เล่นที่ใช้คำสั่ง หรือ 0 หากใช้คำสั่งที่ Server Console
  • command: table<{ [key]: any }>
    • ข้อมูลของคำสั่งที่ใช้งาน (ดูรายละเอียดด้านล่าง)
  • success: boolean
    • สถานะการใช้งานคำสั่ง
  • response: table<{ [key]: any }>
    • ข้อมูลตอบกลับของคำสั่ง (ดูรายละเอียดด้านล่าง)
FieldTypeDescription
keystringคีย์ของคำสั่ง
namestringชื่อของคำสั่ง
rawstringข้อมูลของคำสั่งที่ใช้
argstable<{ [index]: string }>ข้อมูลอาร์กิวเมนต์ของคำสั่งที่ใช้

sendClientMessage

ส่งข้อความไปยังฝั่งไคลเอนต์เมื่อใช้คำสั่งเสร็จสิ้นแล้ว

บรรทัดที่ 38
function Commands.sendClientMessage(client, success, message)
if success then
return TriggerClientEvent('chat:addMessage', client, { multiline = true, color = { 0, 255, 0 }, args = { '»', message } })
end

TriggerClientEvent('chat:addMessage', client, { multiline = true, color = { 255, 0, 0 }, args = { '»', message } })
end

Parameters

  • client: integer
    • Net ID ของผู้เล่นที่ใช้คำสั่ง
  • success: boolean
    • สถานะการใช้งานคำสั่ง
  • message: string
    • ข้อความตอบกลับจากการใช้คำสั่งที่จะส่งไปยังฝั่ง Client

respHandler

จัดการข้อมูลการตอบกลับเมื่อใช้คำสั่งสำเร็จ โดยจะถูกเรียกใช้งานจากฟังก์ชัน onExecuted

getUser

ทำงานเมื่อใช้คำสั่ง "รับข้อมูลผู้ใช้งาน" สำเร็จ

บรรทัดที่ 82
function respHandler.getUser(client, resp)
local message <const> = ("[^2INFO^7] Successfully retrieved data for identifier '^5%s^7': %s"):format(resp.identifier, json.encode(resp.data, { indent = true }))

if client then
return Commands.sendClientMessage(client, true, message)
end

print(message)
end

Parameters

addUser

ทำงานเมื่อใช้คำสั่ง "เพิ่มข้อมูลผู้ใช้งาน" สำเร็จ

บรรทัดที่ 128
function respHandler.addUser(client, resp)
local message <const> = resp.data.bound_id
and ("[^2INFO^7] Successfully added identifier '^5%s^7' and bound ID '^5%s^7' to the database"):format(resp.identifier, resp.data.bound_id)
or ("[^2INFO^7] Successfully added identifier '^5%s^7' to the database"):format(resp.identifier)

if client then
return Commands.sendClientMessage(client, true, message)
end

print(message)
end

Parameters

deleteUser

ทำงานเมื่อใช้คำสั่ง "ลบข้อมูลผู้ใช้งาน" สำเร็จ

บรรทัดที่ 176
function respHandler.deleteUser(client, resp)
local message <const> = ("[^2INFO^7] Successfully deleted data for identifier '^5%s^7' from the database"):format(resp.identifier)

if client then
return Commands.sendClientMessage(client, true, message)
end

print(message)
end

Parameters

getBanInfo

ทำงานเมื่อใช้คำสั่ง "รับข้อมูลการถูกแบน" สำเร็จ

บรรทัดที่ 202
function respHandler.getBanInfo(client, resp)
local message <const> = ("[^2INFO^7] Identifier: ^5%s^7\n[^2INFO^7] Bound ID: %s\n[^2INFO^7] Associated ID: %s\n[^2INFO^7] Ban Type: %s\n[^2INFO^7] Ban Reason: %s\n[^2INFO^7] Ban Start: %s\n[^2INFO^7] Ban End: %s")
:format(resp.identifier,
('^5' .. resp.boundId .. '^7' or 'None'),
(resp.banDetails.associated_id and '^3' .. resp.banDetails.associated_id .. '^7' or 'None'),
(resp.banDetails.type == 'temporary' and '^3Temporary^7' or '^1Permanent^7'),
'^6' .. resp.banDetails.reason .. '^7',
'^3' .. resp.banDetails.start_datetime .. '^7',
(resp.banDetails.end_datetime and '^2' .. resp.banDetails.end_datetime .. '^7' or 'None')
)

if client then
return Commands.sendClientMessage(client, true, message)
end

print(message)
end

Parameters

banUser

ทำงานเมื่อใช้คำสั่ง "แบนผู้ใช้ถาวรหรือชั่วคราว" สำเร็จ

บรรทัดที่ 236
function respHandler.banUser(client, resp)
local message <const> = resp.banDays
and ("[^2INFO^7] Successfully banned identifier '^5%s^7' for ^3%d^7 days"):format(resp.identifier, resp.banDays)
or ("[^2INFO^7] Successfully permanently banned identifier '^5%s^7'"):format(resp.identifier)

if client then
return Commands.sendClientMessage(client, true, message)
end

print(message)
end

Parameters

unbanUser

ทำงานเมื่อใช้คำสั่ง "ยกเลิกแบนผู้ใช้" สำเร็จ

บรรทัดที่ 265
function respHandler.unbanUser(client, resp)
local message <const> = ("[^2INFO^7] Successfully unbanned identifier '^5%s^7' by '^3%s^7'"):format(resp.identifier, (resp.unbanBy or 'Unknown'))

if client then
return Commands.sendClientMessage(client, true, message)
end

print(message)
end

Parameters

setUserRole

ทำงานเมื่อใช้คำสั่ง "กำหนดบทบาทของผู้ใช้" สำเร็จ

บรรทัดที่ 288
function respHandler.setUserRole(client, resp)
local message <const> = ("[^2INFO^7] Successfully assigned role '^2%s^7' (ID: ^2%d^7) to identifier '^5%s^7'."):format(resp.newRole.name, resp.newRole.id, resp.identifier)

if client then
return Commands.sendClientMessage(client, true, message)
end

print(message)
end

Parameters

  • client: integer | nil
    • Net ID ของผู้เล่น หรือ nil หากใช้คำสั่งที่ Server Console
  • resp: table<{ [key]: any }>

reactivateUser

ทำงานเมื่อใช้คำสั่ง "ยกเลิกสถานะการถูกระงับ" สำเร็จ (เป็นการยกเลิกสถานะ inactivePlayers)

บรรทัดที่ 311
function respHandler.reactivateUser(client, resp)
local message <const> = ("[^2INFO^7] Successfully reactivated identifier '^5%s^7' in the database"):format(resp.identifier)

if client then
return Commands.sendClientMessage(client, true, message)
end

print(message)
end

Parameters

  • client: integer | nil
    • Net ID ของผู้เล่น หรือ nil หากใช้คำสั่งที่ Server Console
  • resp: table<{ [key]: any }>

setNewIdentifier

ทำงานเมื่อใช้คำสั่ง "กำหนดตัวระบุให้ผู้ใช้ใหม่" สำเร็จ

บรรทัดที่ 327
function respHandler.setNewIdentifier(client, resp)
local message <const> = ("[^2INFO^7] Successfully updated identifier from '^3%s^7' to '^2%s^7' in the database"):format(resp.identifier, resp.newIdentifier)

if client then
return Commands.sendClientMessage(client, true, message)
end

print(message)
end

Parameters

  • client: integer | nil
    • Net ID ของผู้เล่น หรือ nil หากใช้คำสั่งที่ Server Console
  • resp: table<{ [key]: any }>

resetBindIdentifier

ทำงานเมื่อใช้คำสั่ง "รีเซ็ตตัวระบุที่ถูกผูกไว้ของผู้ใช้" สำเร็จ

บรรทัดที่ 343
function respHandler.resetBindIdentifier(client, resp)
local message <const> = ("[^2INFO^7] Successfully reset bound ID for identifier '^5%s^7' in the database"):format(resp.identifier)

if client then
return Commands.sendClientMessage(client, true, message)
end

print(message)
end

Parameters

resetHwids

ทำงานเมื่อใช้คำสั่ง "รีเซ็ต HWIDs ของผู้ใช้" สำเร็จ

บรรทัดที่ 361
function respHandler.resetHwids(client, resp)
local message <const> = ("[^2INFO^7] Successfully reset HWIDs for identifier '^5%s^7' in the database"):format(resp.identifier)

if client then
return Commands.sendClientMessage(client, true, message)
end

print(message)
end

Parameters

  • client: integer | nil
    • Net ID ของผู้เล่น หรือ nil หากใช้คำสั่งที่ Server Console
  • resp: table<{ [key]: any }>
    • ข้อมูลตอบกลับของคำสั่ง

getPoints

ทำงานเมื่อใช้คำสั่ง "รับพอยท์ของผู้ใช้" สำเร็จ

บรรทัดที่ 388
function respHandler.getPoints(client, resp)
local indexedData <const> = {}

if resp.data?.temporary then
for i, v in ipairs(resp.data.temporary) do
indexedData[#indexedData + 1] = ("[^2INFO^7] Index: ^3%d^7 | Value: ^5%d^7 | Expiry: ^1%s^7"):format(i, v.value, v.expiry_datetime)
end
end

local message <const> = ("[^2INFO^7] Points for identifier '^5%s^7'\n[^2INFO^7] Total Points: ^2%d^7\n[^2INFO^7] Permanent Points: ^5%d^7\n[^2INFO^7] Temporary Points: ^5%d^7\n%s")
:format(resp.identifier, resp.totalPoints, resp.permPoints, resp.tempPoints, (next(indexedData) and table.concat(indexedData, '\n') or ''))

if client then
return Commands.sendClientMessage(client, true, message)
end

print(message)
end

Parameters

  • client: integer | nil
    • Net ID ของผู้เล่น หรือ nil หากใช้คำสั่งที่ Server Console
  • resp: table<{ [key]: any }>
    • ข้อมูลตอบกลับของคำสั่ง
      • identifier: string
      • totalPoints: integer
        • จำนวนคิวพ้อยท์ทั้งหมด
      • permPoints: integer
        • จำนวนคิวพ้อยท์ถาวร
      • tempPoints: integer
        • จำนวนคิวพ้อยท์ชั่วคราว (แบบมีวันหมดอายุ)
      • data: table<{ [key]: any }> | nil

addPoints

ทำงานเมื่อใช้คำสั่ง "เพิ่มพอยท์ให้ผู้ใช้" สำเร็จ

บรรทัดที่ 425
function respHandler.addPoints(client, resp)
local message <const> = resp.expirationDays
and ("[^2INFO^7] Successfully added ^2%d^7 points with an expiration of ^3%d^7 days for identifier '^5%s^7' (Prev Points: ^3%d^7, New Points: ^2%d^7)")
:format(resp.addPoints, resp.expirationDays, resp.identifier, resp.prevPoints, resp.newPoints)
or ("[^2INFO^7] Successfully added ^2%d^7 points without expiration for identifier '^5%s^7' (Prev Points: ^3%d^7, New Points: ^2%d^7)")
:format(resp.addPoints, resp.identifier, resp.prevPoints, resp.newPoints)

if client then
return Commands.sendClientMessage(client, true, message)
end

print(message)
end

Parameters

  • client: integer | nil
    • Net ID ของผู้เล่น หรือ nil หากใช้คำสั่งที่ Server Console
  • resp: table<{ [key]: any }>
    • ข้อมูลตอบกลับของคำสั่ง
      • identifier: string
      • addPoints: integer
        • จำนวนคิวพ้อยท์ที่ถูกเพิ่ม
      • expirationDays: integer | nil
        • จำนวนวันหมดอายุของคิวพ้อยท์แบบชั่วคราว หรือ nil หากเป็นคิวพ้อยท์แบบถาวร (ไม่มีวันหมดอายุ)
      • prevPoints: integer
        • จำนวนคิวพ้อยท์ก่อนที่จะเพิ่ม
      • newPoints: integer
        • จำนวนคิวพ้อยท์หลังจากถูกเพิ่ม
      • data: table<{ [key]: any }> | nil

setPermanentPoints

ทำงานเมื่อใช้คำสั่ง "กำหนดพ้อยท์แบบไม่มีวันหมดอายุให้ผู้ใช้" สำเร็จ

บรรทัดที่ 457
function respHandler.setPermanentPoints(client, resp)
local message <const> = ("[^2INFO^7] Permanent points successfully set: ^2%d^7 for identifier '^5%s^7'\n[^2INFO^7] Prev Permanent Points: ^3%d^7\n[^2INFO^7] New Permanent Points: ^2%d^7\n[^2INFO^7] Current Temporary Points: ^5%d^7\n[^2INFO^7] Total Points: ^2%d^7")
:format(resp.setPermPoints, resp.identifier, resp.prevPermPoints, resp.setPermPoints, resp.tempPoints, resp.totalPoints)

if client then
return Commands.sendClientMessage(client, true, message)
end

print(message)
end

Parameters

  • client: integer | nil
    • Net ID ของผู้เล่น หรือ nil หากใช้คำสั่งที่ Server Console
  • resp: table<{ [key]: any }>
    • ข้อมูลตอบกลับของคำสั่ง
      • identifier: string
      • setPermPoints: integer
        • จำนวนคิวพ้อยท์ถาวรที่ถูกกำหนดใหม่ (ไม่มีวันหมดอายุ)
      • prevPermPoints: integer
        • จำนวนคิวพ้อยท์ถาวรก่อนถูกกำหนดใหม่ (จำนวนเก่า)
      • tempPoints: integer
        • จำนวนคิวพ้อยท์ชั่วคราว (แบบมีวันหมดอายุ)
      • totalPoints: integer
        • จำนวนคิวพ้อยท์ทั้งหมด (หลังถูกกำหนดใหม่)
      • data: table<{ [key]: any }> | nil

deleteTemporaryPoints

ทำงานเมื่อใช้คำสั่ง "ลบพ้อยท์แบบมีวันหมดอายุของผู้ใช้" สำเร็จ

บรรทัดที่ 489
function respHandler.deleteTemporaryPoints(client, resp)
local message <const> = ("[^2INFO^7] Successfully deleted ^1%d^7 temporary points from index ^3%d^7 for identifier '^5%s^7'\n[^2INFO^7] Prev Temporary Points: ^3%d^7\n[^2INFO^7] Remaining Temporary Points: ^2%d^7\n[^2INFO^7] Current Permanent Points: ^5%d^7\n[^2INFO^7] Current Total Points: ^2%d^7")
:format(resp.removedData.value, resp.removedIndex, resp.identifier, (resp.tempPoints + resp.removedData.value), resp.tempPoints, resp.permPoints, resp.totalPoints)

if client then
return Commands.sendClientMessage(client, true, message)
end

print(message)
end

Parameters

  • client: integer | nil
    • Net ID ของผู้เล่น หรือ nil หากใช้คำสั่งที่ Server Console
  • resp: table<{ [key]: any }>
    • ข้อมูลตอบกลับของคำสั่ง
      • identifier: string
      • removedIndex: integer
        • หมายเลข index ของตารางที่ถูกลบข้อมูลคิวพ้อยท์ชั่วคราวออก (แบบมีวันหมดอายุ)
      • removedData: table<{ value: integer, expiry_datetime: string }>
        • ข้อมูลคิวพ้อยท์ชั่วคราวออกที่ถูกลบออก
      • tempPoints: integer
        • จำนวนคิวพ้อยท์ชั่วคราวคงเหลือ
      • totalPoints: integer
        • จำนวนคิวพ้อยท์คงเหลือทั้งหมด
      • data: table<{ [key]: any }> | nil

purgePoints

ทำงานเมื่อใช้คำสั่ง "ลบพ้อยท์ทั้งหมดของผู้ใช้" สำเร็จ

บรรทัดที่ 514
function respHandler.purgePoints(client, resp)
local message <const> = ("[^2INFO^7] Successfully purged points for identifier '^5%s^7'\n[^2INFO^7] Total Points Removed: ^1%d^7\n[^2INFO^7] Permanent Points Removed: ^1%d^7\n[^2INFO^7] Temporary Points Removed: ^1%d^7\n[^2INFO^7] Data Before Purge: %s")
:format(resp.identifier, resp.totalPoints, resp.permPoints, resp.tempPoints, json.encode(resp.data, { indent = true }))

if client then
return Commands.sendClientMessage(client, true, message)
end

print(message)
end

Parameters

  • client: integer | nil
    • Net ID ของผู้เล่น หรือ nil หากใช้คำสั่งที่ Server Console
  • resp: table<{ [key]: any }>

getAirtime

ทำงานเมื่อใช้คำสั่ง "รับเวลาออนไลน์ที่เหลือของผู้ใช้" สำเร็จ

บรรทัดที่ 531
function respHandler.getAirtime(client, resp)
local message <const> = ("[^2INFO^7] Successfully retrieved remaining airtime for identifier '^5%s^7'\n[^2INFO^7] Remaining Airtime: ^2%d^7 seconds"):format(resp.identifier, resp.numAirtime)

if client then
return Commands.sendClientMessage(client, true, message)
end

print(message)
end

Parameters

setAirtime

ทำงานเมื่อใช้คำสั่ง "กำหนดเวลาออนไลน์ให้ผู้ใช้" สำเร็จ

บรรทัดที่ 548
function respHandler.setAirtime(client, resp)
local message <const> = ("[^2INFO^7] Successfully set ^3%d^7 seconds of airtime for identifier '^5%s^7'\n[^2INFO^7] Previous Airtime: ^3%d^7 seconds\n[^2INFO^7] Current Airtime: ^2%d^7 seconds")
:format(resp.newAirtime, resp.identifier, resp.oldAirtime, resp.newAirtime)

if client then
return Commands.sendClientMessage(client, true, message)
end

print(message)
end

Parameters

addAirtime

ทำงานเมื่อใช้คำสั่ง "เพิ่มเวลาออนไลน์ให้ผู้ใช้" สำเร็จ

บรรทัดที่ 567
function respHandler.addAirtime(client, resp)
local message <const> = ("[^2INFO^7] Successfully added ^2%d^7 seconds of airtime for identifier '^5%s^7'\n[^2INFO^7] Previous Airtime: ^3%d^7 seconds\n[^2INFO^7] Current Airtime: ^2%d^7 seconds")
:format(resp.addAirtime, resp.identifier, resp.oldAirtime, resp.newAirtime)

if client then
return Commands.sendClientMessage(client, true, message)
end

print(message)
end

Parameters

removeAirtime

ทำงานเมื่อใช้คำสั่ง "ลดเวลาออนไลน์ของผู้ใช้" สำเร็จ

บรรทัดที่ 586
function respHandler.removeAirtime(client, resp)
local message <const> = ("[^2INFO^7] Successfully removed ^1%d^7 seconds of airtime for identifier '^5%s^7'\n[^2INFO^7] Previous Airtime: ^3%d^7 seconds\n[^2INFO^7] Current Airtime: ^2%d^7 seconds")
:format(resp.removeAirtime, resp.identifier, resp.oldAirtime, resp.newAirtime)

if client then
return Commands.sendClientMessage(client, true, message)
end

print(message)
end

Parameters

clearPlayerCache

ทำงานเมื่อใช้คำสั่ง "ล้างแคชข้อมูลผู้เล่น" สำเร็จ

บรรทัดที่ 600
function respHandler.clearPlayerCache(client, resp)
local message <const> = ("[^2INFO^7] Successfully cleared player cache for identifier '^5%s^7'"):format(resp.identifier)

if client then
return Commands.sendClientMessage(client, true, message)
end

print(message)
end

Parameters

  • client: integer | nil
    • Net ID ของผู้เล่น หรือ nil หากใช้คำสั่งที่ Server Console
  • resp: table<{ [key]: any }>

getMyInfo

ทำงานเมื่อใช้คำสั่ง "รับข้อมูลส่วนตัวของผู้เล่น" สำเร็จ

บรรทัดที่ 629
function respHandler.getMyInfo(client, resp)
local message <const> = ("[^2INFO^7] User Role: ^2%s^7\n[^2INFO^7] Airtime Left: ^3%s^7\n[^2INFO^7] Total Points: ^2%d^7\n[^2INFO^7] Permanent Points: ^5%d^7\n[^2INFO^7] Temporary Points: ^3%d^7")
:format(resp.role.name:gsub('^%l', string.upper), resp.airtimeLeft, resp.queuePoints.total, resp.queuePoints.permanent, resp.queuePoints.temporary)

if client then
return Commands.sendClientMessage(client, true, message)
end

print(message)
end

Parameters

getQueueInfo

ทำงานเมื่อใช้คำสั่ง "รับข้อมูลเกี่ยวกับระบบคิว" สำเร็จ

บรรทัดที่ 652
function respHandler.getQueueInfo(client, resp)
local message <const> = ('[^2INFO^7] Queue Status: %s\n[^2INFO^7] Max Queue Size: ^3%d^7\n[^2INFO^7] Players in Queue: ^3%d^7\n[^2INFO^7] Players Downloading: ^3%d^7\n[^2INFO^7] Players Reconnectable (Crashed): ^3%d^7\n[^2INFO^7] Players Online: ^3%d^7\n[^2INFO^7] Total Used Slots: ^5%d^7/^5%d^7')
:format((resp.isQueueFull and '^1Full^7' or '^2Not Full^7'), resp.maxQueueSize, resp.numQueues, resp.numDownloads, resp.numCrashes, resp.numPlayers, resp.numUsedSlots, resp.maxServerSlots)

if client then
return Commands.sendClientMessage(client, true, message)
end

print(message)
end

Parameters

  • client: integer | nil
    • Net ID ของผู้เล่น หรือ nil หากใช้คำสั่งที่ Server Console
  • resp: table<{ [key]: any }>
    • isQueueFull: boolean
      • ตอบกลับ true หากคิวเต็ม
    • maxServerSlots: integer
      • จำนวนสล็อตเซิร์ฟเวอร์สูงสุด
    • maxQueueSize: integer
      • จำนวนคิวสูงสุดที่รองรับ
    • numQueues: integer
      • จำนวนผู้เล่นที่รออยู่ในคิว
    • numDownloads: integer
    • numCrashes: integer
    • numPlayers: integer
      • จำนวนผู้เล่นออนไลน์อยู่ในเซิร์ฟเวอร์
    • numUsedSlots: integer
      • จำนวนสล็อตเซิร์ฟเวอร์ที่ถูกใช้งาน (numPlayers + numDownloads + numCrashes)