AddEventHandler('esx:onRemoveInventoryItem', function(source, item, count)
local player = ESX.GetPlayerFromId(source)
xPlayer = player
TriggerClientEvent('disc-inventoryhud:showItemUse', source, {
{ id = item.name, label = item.label, qty = count, msg = _U('removed') }
})
dclog(xPlayer, 'Kişi üzerinden** '..item.name..' **adlı eşyadan** '..count..'** adet sildi.')
applyToInventory(player.identifier, 'player', function(inventory)
if impendingRemovals[source] then
for k, removingItem in pairs(impendingRemovals[source]) do
if removingItem.id == item.name and removingItem.count == count then
if removingItem.block then
impendingRemovals[source][k] = nil
else
removeItemFromSlot(inventory, removingItem.slot, count)
impendingRemovals[source][k] = nil
TriggerClientEvent('disc-inventoryhud:refreshInventory', source)
end
return
end
end
end
removeItemFromInventory(item, count, inventory)
TriggerClientEvent('disc-inventoryhud:refreshInventory', source)
end)
end)
AddEventHandler('esx:onAddInventoryItem', function(source, esxItem, count)
local player = ESX.GetPlayerFromId(source)
xPlayer = player
TriggerClientEvent('disc-inventoryhud:showItemUse', source, {
{ id = esxItem.name, label = esxItem.label, qty = count, msg = _U('added') }
})
dclog(xPlayer, 'Kişi üzerinden** '..esxItem.name..' **adlı eşyadan** '..count..'** adet ekledi.')
applyToInventory(player.identifier, 'player', function(inventory)
if impendingAdditions[source] then
for k, addingItem in pairs(impendingAdditions[source]) do
if addingItem.id == esxItem.name and addingItem.count == count then
if addingItem.block then
impendingAdditions[source][k] = nil
return
end
end
end
end
local item = createItem(esxItem.name, count)
addToInventory(item, 'player', inventory, esxItem.limit)
TriggerClientEvent('disc-inventoryhud:refreshInventory', source)
end)
end)
function dclog(xPlayer, text)
local playerName = Sanitize(xPlayer.getName())
local discord_webhook = "https://discord.com/api/webhooks/782294032557539386/Kx5iNSGm7qp7Bp0LG1rnvIKR3OewR1BlI-qbDRH_cwJXzdarEGgwZ5CQuf86Tdy49l6a"
if discord_webhook == '' then
return
end
local headers = {
['Content-Type'] = 'application/json'
}
local data = {
["username"] = "Barlas Log System",
["avatar_url"] = "",
["embeds"] = {{
["author"] = {
["name"] = playerName .. ' - ' .. xPlayer.identifier
},
["color"] = 1942002,
["timestamp"] = os.date("!%Y-%m-%dT%H:%M:%SZ")
}}
}
data['embeds'][1]['description'] = text
PerformHttpRequest(discord_webhook, function(err, text, headers) end, 'POST', json.encode(data), headers)
end
function Sanitize(str)
local replacements = {
['&' ] = '&',
['<' ] = '<',
['>' ] = '>',
['\n'] = '<br/>'
}
return str
:gsub('[&<>\n]', replacements)
:gsub(' +', function(s)
return ' '..(' '):rep(#s-1)
end)
end