Information - ข้อมูลเบื้องต้น

  • เวอร์ชั่นปัจจุบัน 1.0.0

Requirements - ความต้องการขั้นพื้นฐาน

  • FXServer (ต้องรองรับ Onesync, GlobalState)
  • es_extended
  • ox_lib

VSCode Extensions - ส่วนเสริมโปรแกรม

Installation - ติดตั้ง

Download ให้คุณไปที่ไฟล์ fxmanifest.lua ของโฟลเดอร์ Project ที่คุณต้องการใช้งาน ns_core และเพิ่ม
shared_scripts {
	'@ox_lib/init.lua',
}

client_scripts {
  '@ns_core/lib/client.lua'
}

server_scripts {
  '@ns_core/lib/server.lua'
}
หลังจากนั้นให้คุณไปที่ไฟล์ฝั่ง Client ของคุณและเริ่มต้นใช้งานทรัพยากร ns_core
local app = lib.client:new(self, ESX)
  RegisterCommand('get-item', function(_, args)
    local item = self:getItem(args[1], true)
    print(ESX.DumpTable(item))
  end, false)
end

app:start()

--- Test
--- Function: self:getItem(name: string, validate?: boolean)
--- Execute command /get-item bread
--- Output: {
---   ['name'] = 'bread'
---   ['count'] = ...,
---   ['...'] = ...
--- }
ฟังก์ชั่นที่เราทำการส่งเข้าไปใน lib.client:new จะทำงานเมื่อผู้เล่นโหลดตัวละครสำเร็จแล้วโดยอ้างอิงจากทรัพยากร es_extended ฟังก์ชั่น ESX.IsPlayerLoaded โดยฟังก์ชั่นตัวอย่าง getItem จะมีการส่ง Parameters 2 อย่างก็คือ
NameTypeRequiredDefault
namestringYESnil
validateboleanNOfalse