หลักการคือ Config ระบุชื่อ Resource/Export ส่วน config/functions เป็น Adapter แปลง API ของ resource ภายนอก เพื่อไม่กระจาย export call ไปทั่ว Core
text
Config = ชื่อ resource / export / option
config/functions = แปลง API ของ resource ภายนอก
Core = business logic ของ ks_policeInventory#
ค่า Default รองรับ nc_inventory และสามารถเปลี่ยนเป็น inventory อื่นได้
lua
Config.Integrations.Inventory = {
Enabled = true,
Resource = 'my_inventory',
SearchExport = 'OpenPlayerInventory',
SearchType = 'police',
AddExport = 'AddItem',
RemoveExport = 'RemoveItem',
UpdateWeaponAmmoExport = 'UpdateWeaponAmmo',
ItemImageBase = 'nui://my_inventory/html/images/',
ItemImageExtension = '.png',
UseExportForMutations = true
}ยึดของจาก nc_inventory เข้าตู้หน่วยงาน#
หาก Inventory build รองรับ Search hooks ให้เปิด Config.Search.SeizedItemsToAgencySafe = true และเชื่อม hook กับ Server exports:
lua
exports['ks_police']:ShouldRouteSearchSeizure(officerSource, targetSource, itemName, itemCount, itemType, searchType)
exports['ks_police']:DepositSearchSeizure(officerSource, targetSource, itemName, itemCount, itemType, searchType)เมื่อยึดแบบ take ระบบจะนำของจากผู้ต้องหาเข้าตู้หน่วยงานโดยตรง ไม่ผ่านกระเป๋าตำรวจ
Inventory ไม่มี hook หลังยึด#
ใช้ Snapshot Fallback ได้ หรือหลัง Inventory ยืนยันว่าของถูกนำออกสำเร็จแล้วให้แจ้ง KS Police แบบ Exact:
lua
exports['ks_police']:RecordSeizedEvidence(
officerSource, suspectSource, itemName, amount, itemType, itemLabel, suspectName
)เรียกหลังยึดสำเร็จเท่านั้น
RecordSeizedEvidence มีหน้าที่บันทึกหลักฐาน ไม่ควรเรียกก่อน Inventory ยืนยันการ Remove เพราะอาจทำให้ข้อมูลหลักฐานไม่ตรงของจริง
Optional Resources#
screenshot-basic— ใช้แนบ Screenshot ใน Discord Logazael_playpass— Integration เสริมที่เปิด/ปิดได้