Skip to main content

esx_policejob

ตัวอย่างรหัสที่ใช้เพิ่มไปยังทรัพยากร esx_policejob เพื่อส่งข้อมูลมายัง azael_dc-serverlogs

danger

โปรดตรวจสอบตัวแปรของรหัสทุกครั้ง เนื่องจากเวอร์ชันของทรัพยากรในตัวอย่างอาจจะไม่มีความเข้ากันได้กับทรัพยากรในเวอร์ชันที่คุณกำลังใช้งานอยู่ และส่งผลให้ไม่มีการส่งข้อมูลไปยัง azael_dc-serverlogs เนื่องจากมีข้อผิดพลาดเกิดขึ้นจากรหัสที่คุณดำเนินการเพิ่ม

main.lua (Server)

ไปยังโฟลเดอร์ server แล้วดำเนินการเปิดไฟล์ main.lua

ตำรวจ-ยึด (ไอเทม, เงิน, อาวุธ)

note

ไม่ต้องดำเนินการในส่วนนี้ หากคุณใช้งาน nc_inventory หรือ esx_inventoryhud

EventLabel
PoliceTakeItemตำรวจ-ยึด-ไอเทม

วางรหัสด้านล่างนี้ต่อจาก sourceXPlayer.addInventoryItem(itemName, amount) บรรทัดที่ 31

pcall(function()
exports['azael_dc-serverlogs']:insertData({
event = 'PoliceTakeItem',
content = ('ยึด %s จำนวน %s จาก %s'):format(sourceItem.label, amount, targetXPlayer.name),
source = sourceXPlayer.source,
color = 2,
options = {
important = (amount >= 500 and true)
}
})

exports['azael_dc-serverlogs']:insertData({
event = 'PoliceTakeItem',
content = ('ถูกยึด %s จำนวน %s โดย %s'):format(sourceItem.label, amount, sourceXPlayer.name),
source = targetXPlayer.source,
color = 3,
options = {
important = (amount >= 500 and true)
}
})
end)

ตำรวจ-ไอเทม-ออกจากคลัง

EventLabel
PoliceGetStockItemตำรวจ-ไอเทม-ออกจากคลัง

วางรหัสด้านล่างนี้ต่อจาก xPlayer.addInventoryItem(itemName, count) บรรทัดที่ 129

pcall(function()
exports['azael_dc-serverlogs']:insertData({
event = 'PoliceGetStockItem',
content = ('นำ %s จำนวน %s ออกจากคลัง'):format(inventoryItem.label, count),
source = xPlayer.source,
color = 1,
options = {
important = (count >= 500 and true or count < 0 and true)
}
})
end)

ตำรวจ-ไอเทม-เก็บเข้าคลัง

EventLabel
PolicePutStockItemตำรวจ-ไอเทม-เก็บเข้าคลัง

วางรหัสด้านล่างนี้ต่อจาก inventory.addItem(itemName, count) บรรทัดที่ 151

pcall(function()
exports['azael_dc-serverlogs']:insertData({
event = 'PolicePutStockItem',
content = ('นำ %s จำนวน %s เก็บเข้าคลัง'):format(inventoryItem.label, count),
source = xPlayer.source,
color = 2,
options = {
important = (count >= 500 and true or count < 0 and true)
}
})
end)

ตำรวจ-อาวุธ-เก็บเข้าคลัง

EventLabel
PolicePutArmoryWeaponตำรวจ-อาวุธ-เก็บเข้าคลัง

วางรหัสด้านล่างนี้ต่อจาก xPlayer.removeWeapon(weaponName) บรรทัดที่ 249

pcall(function()
exports['azael_dc-serverlogs']:insertData({
event = 'PolicePutArmoryWeapon',
content = ('นำ %s จำนวน 1 เก็บเข้าคลัง'):format(ESX.GetWeaponLabel(weaponName)),
source = xPlayer.source,
color = 2
})
end)

ตำรวจ-อาวุธ-ออกจากคลัง

EventLabel
PoliceGetArmoryWeaponตำรวจ-อาวุธ-ออกจากคลัง

วางรหัสด้านล่างนี้ต่อจาก xPlayer.addWeapon(weaponName, 500) บรรทัดที่ 278

pcall(function()
exports['azael_dc-serverlogs']:insertData({
event = 'PoliceGetArmoryWeapon',
content = ('นำ %s และ กระสุน จำนวน 500 ออกจากคลัง'):format(ESX.GetWeaponLabel(weaponName)),
source = xPlayer.source,
color = 1
})
end)

ตำรวจ-ซื้ออาวุธ

EventLabel
PoliceBuyWeaponตำรวจ-ซื้ออาวุธ
  1. วางรหัสด้านล่างนี้ต่อจาก xPlayer.addWeapon(weaponName, 100) บรรทัดที่ 324
pcall(function()
exports['azael_dc-serverlogs']:insertData({
event = 'PoliceBuyWeapon',
content = ('ซื้อ %s และ กระสุน จำนวน 100 ราคา $%s'):format(ESX.GetWeaponLabel(weaponName), ESX.Math.GroupDigits(selectedWeapon.price)),
source = xPlayer.source,
color = 2
})
end)
  1. วางรหัสด้านล่างนี้ต่อจาก xPlayer.addWeaponComponent(weaponName, component.name) บรรทัดที่ 340
pcall(function()
exports['azael_dc-serverlogs']:insertData({
event = 'PoliceBuyWeapon',
content = ('ซื้อ %s ส่วนประกอบของอาวุธ %s ราคา $%s'):format(component.label, ESX.GetWeaponLabel(weaponName), ESX.Math.GroupDigits(price)),
source = xPlayer.source,
color = 5
})
end)

ตำรวจ-ซื้อรถ

EventLabel
PoliceBuyVehicleตำรวจ-ซื้อรถ

วางรหัสด้านล่างนี้ต่อจาก function(rowsChanged) บรรทัดที่ 367

pcall(function()
exports['azael_dc-serverlogs']:insertData({
event = 'PoliceBuyVehicle',
content = ('ซื้อ ยานพาหนะ %s ทะเบียน %s ราคา $%s'):format(vehicleProps.model, vehicleProps.plate, ESX.Math.GroupDigits(price)),
source = xPlayer.source,
color = 2
})
end)

main.lua (Client)

ไปยังโฟลเดอร์ client แล้วดำเนินการเปิดไฟล์ main.lua

ตำรวจ-งัดรถ

EventLabel
PoliceHijackตำรวจ-งัดรถ

วางรหัสด้านล่างนี้ต่อจาก SetVehicleDoorsLockedForAllPlayers(vehicle, false) บรรทัดที่ 351

pcall(function()
exports['azael_dc-serverlogs']:insertData({
event = 'PoliceHijack',
content = ('งัด ยานพาหนะ %s ทะเบียน %s'):format(GetDisplayNameFromVehicleModel(GetEntityModel(vehicle)), GetVehicleNumberPlateText(vehicle)),
color = 3
})
end)

ตำรวจ-พาวท์รถ

EventLabel
PoliceImPoundตำรวจ-พาวท์รถ

วางรหัสด้านล่างนี้ต่อจาก currentTask.busy = false ภายใน function ImpoundVehicle(vehicle) บรรทัดที่ 1557

pcall(function()
exports['azael_dc-serverlogs']:insertData({
event = 'PoliceImPound',
content = ('ส่ง ยานพาหนะ %s ทะเบียน %s ไปยังพาวท์'):format(GetDisplayNameFromVehicleModel(GetEntityModel(vehicle)), GetVehicleNumberPlateText(vehicle)),
color = 2
})
end)