Skip to main content

NUI (Client-side)

Nui

show

ฟังก์ชันแสดง UI (User Panel)

บรรทัดที่ 39
function Nui.show()
if isNuiVisible then return end

if IsPauseMenuActive() then
SetFrontendActive(false)
end

SendNUIMessage({ action = 'show', theme = gameName, panel = 'user', locale = LOCALE })
SetNuiFocus(true, false)
SetNuiFocusKeepInput(true)

isNuiVisible = true
activePanel = 'user'

Citizen.CreateThread(disablePauseMenu)
end

showAdmin

ฟังก์ชันแสดง UI (Admin Panel)

บรรทัดที่ 57
function Nui.showAdmin()
if isNuiVisible then return end

if IsPauseMenuActive() then
SetFrontendActive(false)
end

SendNUIMessage({ action = 'show', theme = gameName, panel = 'admin', locale = LOCALE })
SetNuiFocus(true, true)

isNuiVisible = true
activePanel = 'admin'

Citizen.CreateThread(disablePauseMenu)
end

close

ฟังก์ชันปิด UI

บรรทัดที่ 76
function Nui.close(_, cb)
if not isNuiVisible then
return cb and cb({ success = false, message = 'NUI is not visible' }) or nil
end

SetNuiFocus(false, false)
SetNuiFocusKeepInput(false)
SendNUIMessage({ action = 'close' })

isNuiVisible = false
activePanel = nil

isClosing = true
Citizen.SetTimeout(100, function() isClosing = false end)

if cb then
cb({ success = true, message = 'NUI closed successfully' })
end
end

Parameters

  • _: any
    • ไม่ได้ใช้งาน (สำหรับ NUI Callback)
  • cb: function?
    • ฟังก์ชัน callback ที่จะเรียกหลังจากปิด UI (สำหรับ NUI Callback)

isVisible

ตรวจสอบว่า NUI เปิดอยู่หรือไม่

บรรทัดที่ 100
function Nui.isVisible()
return isNuiVisible
end

Returns

  • isNuiVisible: boolean
    • สถานะว่า NUI กำลังแสดงอยู่หรือไม่

getActivePanel

รับ panel ที่กำลังใช้งานอยู่

บรรทัดที่ 106
function Nui.getActivePanel()
return activePanel
end

Returns

  • activePanel: string?
    • ชื่อ panel ที่เปิดอยู่ ('user' | 'admin' | nil)

updateUser

ฟังก์ชันอัปเดตข้อมูลผู้ใช้

บรรทัดที่ 112
function Nui.updateUser(data)
SendNUIMessage({ action = 'updateUser', data = data })
end

Parameters

  • data: table<{ [key]: any }>
    • ตารางข้อมูลผู้ใช้
      • roleName: string | nil
      • airtimeLeft: integer | nil
      • queuePoints: table<{ [key]: any }> | nil
        • ตารางข้อมูลคิวพ้อยท์
          • permanent: integer
            • จำนวนคิวพ้อยท์แบบถาวร
          • temporary: integer
            • จำนวนคิวพ้อยท์แบบชั่วคราว (มีวันหมดอายุ)
          • temporaryData: table<{ [index]: table<{ [key]: any }> }> | nil
            • ตารางข้อมูลคิวพ้อยท์แบบชั่วคราว
              • points: integer
                • จำนวนคิวพ้อยท์
              • expiresAt: string
                • วันที่และเวลาหมดอายุของคิวพ้อยท์ ในรูปแบบ ISO 8601 (UTC) เช่น "2025-05-23T17:20:00Z"

updateQueue

ฟังก์ชันอัปเดตข้อมูลคิวรอเชื่อมต่อ

บรรทัดที่ 118
function Nui.updateQueue(data)
SendNUIMessage({ action = 'updateQueue', data = data })
end

Parameters

  • data: table<{ [key]: any }> | nil
    • ตารางข้อมูลของระบบคิว
      • numQueues: integer
        • จำนวนผู้เล่นที่รออยู่ในคิว
      • maxQueues: integer
        • จำนวนคิวสูงสุดที่รองรับ
      • numSlots: integer
        • จำนวนสล็อตเซิร์ฟเวอร์ที่ถูกใช้งาน
      • maxSlots: integer
        • จำนวนสล็อตเซิร์ฟเวอร์สูงสุด

updateAdmin

ฟังก์ชันอัปเดตข้อมูลผู้ดูแลระบบ

บรรทัดที่ 124
function Nui.updateAdmin(data)
SendNUIMessage({ action = 'updateAdmin', data = data })
end

Parameters

  • data: table
    • ตารางข้อมูลของผู้ดูแลระบบ

sendAdminActionResult

ส่งผลลัพธ์ของการดำเนินการผู้ดูแลระบบ

บรรทัดที่ 130
function Nui.sendAdminActionResult(data)
SendNUIMessage({ action = 'adminActionResult', data = data })
end

Parameters

  • data: table
    • ตารางข้อมูลผลลัพธ์ของการดำเนินการ

sendAdminNotify

ส่งการแจ้งเตือนไปยังแผงผู้ดูแลระบบ

บรรทัดที่ 137
function Nui.sendAdminNotify(type, message)
SendNUIMessage({ action = 'adminNotify', data = { type = type, message = message } })
end

Parameters

  • type: string
    • ประเภทของการแจ้งเตือน ('success' | 'error' | 'info')
  • message: string
    • ข้อความแจ้งเตือน

sendPlayerPageResult

ส่งข้อมูลผู้เล่นแบบแบ่งหน้าไปยังแผงผู้ดูแลระบบ

บรรทัดที่ 143
function Nui.sendPlayerPageResult(data)
SendNUIMessage({ action = 'playerPageResult', data = data })
end

Parameters

  • data: table
    • ตารางข้อมูลผู้เล่นแบบแบ่งหน้า