Skip to main content

es_extended

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

danger

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

commands.lua (Server)

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

ใช้คำสั่ง-แอดมิน

EventLabel
AdminCommandsใช้คำสั่ง-แอดมิน

SETJOB

วางรหัสด้านล่างนี้ต่อจาก args.playerId.setJob(args.job, args.grade) บรรทัดที่ 27

pcall(function()
if xPlayer.source == args.playerId.source then
exports['azael_dc-serverlogs']:insertData({
event = 'AdminCommands',
content = ('เปลี่ยนอาชีพให้ตนเองเป็น %s ระดับ %s'):format(args.job, args.grade),
source = xPlayer.source,
color = 7
})
else
exports['azael_dc-serverlogs']:insertData({
event = 'AdminCommands',
content = ('เปลี่ยนอาชีพให้ %s เป็น %s ระดับ %s'):format(args.playerId.name, args.job, args.grade),
source = xPlayer.source,
color = 3
})

exports['azael_dc-serverlogs']:insertData({
event = 'AdminCommands',
content = ('ถูกเปลี่ยนอาชีพเป็น %s ระดับ %s โดย %s'):format(args.job, args.grade, xPlayer.name),
source = args.playerId.source,
color = 2
})
end
end)

SETACCOUNTMONEY

วางรหัสด้านล่างนี้ต่อจาก args.playerId.setAccountMoney(args.account, args.amount, "Government Grant") บรรทัดที่ 139

pcall(function()
if xPlayer.source == args.playerId.source then
exports['azael_dc-serverlogs']:insertData({
event = 'AdminCommands',
content = ('กำหนด %s ให้ตนเองเป็น $%s'):format(args.account, ESX.Math.GroupDigits(args.amount)),
source = xPlayer.source,
color = 2,
options = {
important = (args.amount >= 100000 and true)
}
})
else
exports['azael_dc-serverlogs']:insertData({
event = 'AdminCommands',
content = ('กำหนด %s ให้ %s เป็น $%s'):format(args.account, args.playerId.name, ESX.Math.GroupDigits(args.amount)),
source = xPlayer.source,
color = 3,
options = {
important = (args.amount >= 100000 and true)
}
})

exports['azael_dc-serverlogs']:insertData({
event = 'AdminCommands',
content = ('ถูกกำหนด %s เป็น $%s โดย %s'):format(args.account, ESX.Math.GroupDigits(args.amount), xPlayer.name),
source = args.playerId.source,
color = 2,
options = {
important = (args.amount >= 100000 and true)
}
})
end
end)

GIVEACCOUNTMONEY

วางรหัสด้านล่างนี้ต่อจาก args.playerId.addAccountMoney(args.account, args.amount, "Government Grant") บรรทัดที่ 163

pcall(function()
if xPlayer.source == args.playerId.source then
exports['azael_dc-serverlogs']:insertData({
event = 'AdminCommands',
content = ('เพิ่ม %s จำนวน $%s ให้ตนเอง'):format(args.account, ESX.Math.GroupDigits(args.amount)),
source = xPlayer.source,
color = 2,
options = {
important = (args.amount >= 100000 and true)
}
})
else
exports['azael_dc-serverlogs']:insertData({
event = 'AdminCommands',
content = ('เพิ่ม %s จำนวน $%s ให้ %s'):format(args.account, ESX.Math.GroupDigits(args.amount), args.playerId.name),
source = xPlayer.source,
color = 3,
options = {
important = (args.amount >= 100000 and true)
}
})

exports['azael_dc-serverlogs']:insertData({
event = 'AdminCommands',
content = ('ได้รับ %s จำนวน $%s โดย %s'):format(args.account, ESX.Math.GroupDigits(args.amount), xPlayer.name),
source = args.playerId.source,
color = 2,
options = {
important = (args.amount >= 100000 and true)
}
})
end
end)

GIVEITEM

วางรหัสด้านล่างนี้ต่อจาก args.playerId.addInventoryItem(args.item, args.count) บรรทัดที่ 209

pcall(function()
if xPlayer.source == args.playerId.source then
exports['azael_dc-serverlogs']:insertData({
event = 'AdminCommands',
content = ('เพิ่ม %s จำนวน %s ให้ตนเอง'):format(ESX.GetItemLabel(args.item), args.count),
source = xPlayer.source,
color = 2,
options = {
important = (args.count >= 500 and true)
}
})
else
exports['azael_dc-serverlogs']:insertData({
event = 'AdminCommands',
content = ('เพิ่ม %s จำนวน %s ให้ %s'):format(ESX.GetItemLabel(args.item), args.count, args.playerId.name),
source = xPlayer.source,
color = 3,
options = {
important = (args.count >= 500 and true)
}
})

exports['azael_dc-serverlogs']:insertData({
event = 'AdminCommands',
content = ('ได้รับ %s จำนวน %s โดย %s'):format(ESX.GetItemLabel(args.item), args.count, xPlayer.name),
source = args.playerId.source,
color = 2,
options = {
important = (args.count >= 500 and true)
}
})
end
end)

GIVEWEAPON

วางรหัสด้านล่างนี้ต่อจาก args.playerId.addWeapon(args.weapon, args.ammo) บรรทัดที่ 233

pcall(function()
if xPlayer.source == args.playerId.source then
exports['azael_dc-serverlogs']:insertData({
event = 'AdminCommands',
content = ('เพิ่ม %s และ กระสุน จำนวน %s ให้ตนเอง'):format(ESX.GetWeaponLabel(args.weapon), args.ammo),
source = xPlayer.source,
color = 2
})
else
exports['azael_dc-serverlogs']:insertData({
event = 'AdminCommands',
content = ('เพิ่ม %s และ กระสุน จำนวน %s ให้ %s'):format(ESX.GetWeaponLabel(args.weapon), args.ammo, args.playerId.name),
source = xPlayer.source,
color = 3
})

exports['azael_dc-serverlogs']:insertData({
event = 'AdminCommands',
content = ('ได้รับ %s และ กระสุน จำนวน %s โดย %s'):format(ESX.GetWeaponLabel(args.weapon), args.ammo, xPlayer.name),
source = args.playerId.source,
color = 2
})
end
end)

GIVEAMMO

วางรหัสด้านล่างนี้ต่อจาก args.playerId.addWeaponAmmo(args.weapon, args.ammo) บรรทัดที่ 257

pcall(function()
if xPlayer.source == args.playerId.source then
exports['azael_dc-serverlogs']:insertData({
event = 'AdminCommands',
content = ('เพิ่ม กระสุน ของ %s จำนวน %s ให้ตนเอง'):format(ESX.GetWeaponLabel(args.weapon), args.ammo),
source = xPlayer.source,
color = 2
})
else
exports['azael_dc-serverlogs']:insertData({
event = 'AdminCommands',
content = ('เพิ่ม กระสุน ของ %s จำนวน %s ให้ %s'):format(ESX.GetWeaponLabel(args.weapon), args.ammo, args.playerId.name),
source = xPlayer.source,
color = 3
})

exports['azael_dc-serverlogs']:insertData({
event = 'AdminCommands',
content = ('ได้รับ กระสุน ของ %s จำนวน %s โดย %s'):format(ESX.GetWeaponLabel(args.weapon), args.ammo, xPlayer.name),
source = args.playerId.source,
color = 2
})
end
end)

GIVEWEAPONCOMPONENT

วางรหัสด้านล่างนี้ต่อจาก args.playerId.addWeaponComponent(args.weaponName, args.componentName) บรรทัดที่ 285

pcall(function()
if xPlayer.source == args.playerId.source then
exports['azael_dc-serverlogs']:insertData({
event = 'AdminCommands',
content = ('เพิ่ม %s ส่วนประกอบของ %s ให้ตนเอง'):format(component.label, ESX.GetWeaponLabel(args.weaponName)),
source = xPlayer.source,
color = 2
})
else
exports['azael_dc-serverlogs']:insertData({
event = 'AdminCommands',
content = ('เพิ่ม %s ส่วนประกอบของ %s ให้ %s'):format(component.label, ESX.GetWeaponLabel(args.weaponName), args.playerId.name),
source = xPlayer.source,
color = 3
})

exports['azael_dc-serverlogs']:insertData({
event = 'AdminCommands',
content = ('ได้รับ %s ส่วนประกอบของ %s โดย %s'):format(component.label, ESX.GetWeaponLabel(args.weaponName), xPlayer.name),
source = args.playerId.source,
color = 2
})
end
end)

main.lua (Server)

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

tip
  1. หากคุณใช้งานทรัพยากร ox_inventory ไม่ต้องติดตั้งรหัสสำหรับเหตุการณ์ ส่ง, ทิ้ง, เก็บ ที่ทรัพยากร es_extended
  2. หากคุณใช้งานทรัพยากร nc_inventory ไม่ต้องติดตั้งรหัสสำหรับเหตุการณ์ ส่ง, ทิ้ง ที่ทรัพยากร es_extended

ส่ง-ไอเทม

EventLabel
GiveItemส่ง-ไอเทม

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

pcall(function()
exports['azael_dc-serverlogs']:insertData({
event = 'GiveItem',
content = ('ส่ง %s จำนวน %s ให้กับ %s'):format(sourceItem.label, itemCount, targetXPlayer.name),
source = sourceXPlayer.source,
color = 1,
options = {
important = (itemCount >= 500 and true)
}
})

exports['azael_dc-serverlogs']:insertData({
event = 'GiveItem',
content = ('ได้รับ %s จำนวน %s จาก %s'):format(sourceItem.label, itemCount, sourceXPlayer.name),
source = targetXPlayer.source,
color = 2,
options = {
important = (itemCount >= 500 and true)
}
})
end)

ส่ง-เงิน

EventLabel
GiveMoneyส่ง-เงินเขียว
GiveDirtyMoneyส่ง-เงินแดง

วางรหัสด้านล่างนี้ต่อจาก targetXPlayer.addAccountMoney(itemName, itemCount, "Received from " .. sourceXPlayer.name) บรรทัดที่ 444

pcall(function()
local eventName = (itemName == 'money' and 'GiveMoney' or 'GiveDirtyMoney')

exports['azael_dc-serverlogs']:insertData({
event = eventName,
content = ('ส่ง %s จำนวน $%s ให้กับ %s'):format(Config.Accounts[itemName].label, ESX.Math.GroupDigits(itemCount), targetXPlayer.name),
source = sourceXPlayer.source,
color = 1,
options = {
important = (itemCount >= 100000 and true)
}
})

exports['azael_dc-serverlogs']:insertData({
event = eventName,
content = ('ได้รับ %s จำนวน $%s จาก %s'):format(Config.Accounts[itemName].label, ESX.Math.GroupDigits(itemCount), sourceXPlayer.name),
source = targetXPlayer.source,
color = 2,
options = {
important = (itemCount >= 100000 and true)
}
})
end)

ส่ง-อาวุธ

EventLabel
GiveWeaponส่ง-อาวุธ

วางรหัสด้านล่างนี้ต่อจาก targetXPlayer.addWeapon(itemName, itemCount) บรรทัดที่ 470

pcall(function()
exports['azael_dc-serverlogs']:insertData({
event = 'GiveWeapon',
content = ('ส่ง %s และ กระสุน จำนวน %s ให้กับ %s'):format(weaponLabel, itemCount, targetXPlayer.name),
source = sourceXPlayer.source,
color = 1
})

exports['azael_dc-serverlogs']:insertData({
event = 'GiveWeapon',
content = ('ได้รับ %s และ กระสุน จำนวน %s จาก %s'):format(weaponLabel, itemCount, sourceXPlayer.name),
source = targetXPlayer.source,
color = 2
})
end)

ส่ง-กระสุน

EventLabel
GiveAmmoส่ง-กระสุน

วางรหัสด้านล่างนี้ต่อจาก targetXPlayer.addWeaponAmmo(itemName, itemCount) บรรทัดที่ 497

pcall(function()
exports['azael_dc-serverlogs']:insertData({
event = 'GiveAmmo',
content = ('ส่ง กระสุน ของ %s จำนวน %s ให้กับ %s'):format(weapon.label, itemCount, targetXPlayer.name),
source = sourceXPlayer.source,
color = 1
})

exports['azael_dc-serverlogs']:insertData({
event = 'GiveAmmo',
content = ('ได้รับ กระสุน ของ %s จำนวน %s จาก %s'):format(weapon.label, itemCount, sourceXPlayer.name),
source = targetXPlayer.source,
color = 2
})
end)

ทิ้ง-ไอเทม

EventLabel
RemoveItemทิ้ง-ไอเทม

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

pcall(function()
exports['azael_dc-serverlogs']:insertData({
event = 'RemoveItem',
content = ('ทิ้ง %s จำนวน %s'):format(xItem.label, itemCount),
source = xPlayer.source,
color = 1,
options = {
important = (itemCount >= 500 and true)
}
})
end)

ทิ้ง-เงิน

EventLabel
RemoveMoneyทิ้ง-เงินเขียว
RemoveDirtyMoneyทิ้ง-เงินแดง

วางรหัสด้านล่างนี้ต่อจาก xPlayer.removeAccountMoney(itemName, itemCount, "Threw away") บรรทัดที่ 540

pcall(function()
exports['azael_dc-serverlogs']:insertData({
event = (itemName == 'money' and 'RemoveMoney' or 'RemoveDirtyMoney'),
content = ('ทิ้ง %s จำนวน $%s'):format(Config.Accounts[itemName].label, ESX.Math.GroupDigits(itemCount)),
source = xPlayer.source,
color = 1,
options = {
important = (itemCount >= 100000 and true)
}
})
end)

ทิ้ง-อาวุธ

EventLabel
RemoveWeaponทิ้ง-อาวุธ

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

pcall(function()
exports['azael_dc-serverlogs']:insertData({
event = 'RemoveWeapon',
content = ('ทิ้ง %s และ กระสุน จำนวน %s'):format(weapon.label, weapon.ammo),
source = xPlayer.source,
color = 1
})
end)

ใช้งาน-ไอเทม

EventLabel
UseItemใช้งาน-ไอเทม

วางรหัสด้านล่างนี้ต่อจาก ESX.UseItem(source, itemName) บรรทัดที่ 576

pcall(function()
exports['azael_dc-serverlogs']:insertData({
event = 'UseItem',
content = ('ใช้งาน %s จำนวน 1'):format(ESX.GetItemLabel(itemName)),
source = xPlayer.source,
color = 3
})
end)

เก็บ-ไอเทม

EventLabel
PickupItemเก็บ-ไอเทม

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

pcall(function()
exports['azael_dc-serverlogs']:insertData({
event = 'PickupItem',
content = ('เก็บ %s จำนวน %s'):format(ESX.GetItemLabel(pickup.name), pickup.count),
source = xPlayer.source,
color = 2,
options = {
important = (pickup.count >= 500 and true)
}
})
end)

เก็บ-เงิน

EventLabel
PickupMoneyเก็บ-เงินเขียว
PickupDirtyMoneyเก็บ-เงินแดง

วางรหัสด้านล่างนี้ต่อจาก xPlayer.addAccountMoney(pickup.name, pickup.count, "Picked up") บรรทัดที่ 596

pcall(function()
exports['azael_dc-serverlogs']:insertData({
event = (pickup.name == 'money' and 'PickupMoney' or 'PickupDirtyMoney'),
content = ('เก็บ %s จำนวน $%s'):format(Config.Accounts[pickup.name].label, ESX.Math.GroupDigits(pickup.count)),
source = xPlayer.source,
color = 2,
options = {
important = (pickup.count >= 100000 and true)
}
})
end)

เก็บ-อาวุธ

EventLabel
PickupWeaponเก็บ-อาวุธ

วางรหัสด้านล่างนี้ต่อจาก xPlayer.setWeaponTint(pickup.name, pickup.tintIndex) บรรทัดที่ 603

pcall(function()
exports['azael_dc-serverlogs']:insertData({
event = 'PickupWeapon',
content = ('เก็บ %s และ กระสุน จำนวน %s'):format(ESX.GetWeaponLabel(pickup.name), pickup.count),
source = xPlayer.source,
color = 2
})
end)