Hello
I will teach you to keep a log of the data you want of any plugin.
If you don't think your knowledge is enough, I recommend you to make a backup of the plugin.
The function I will share is not a plugin, it does not work with copy paste logic.
You need to adapt the log according to the data you want to keep.
Just paste this code at the bottom of any file on the server side of the plugin you want to log.
I will teach you to keep a log of the data you want of any plugin.
If you don't think your knowledge is enough, I recommend you to make a backup of the plugin.
The function I will share is not a plugin, it does not work with copy paste logic.
You need to adapt the log according to the data you want to keep.
Just paste this code at the bottom of any file on the server side of the plugin you want to log.
Code:
function dclog(xPlayer, text)
local playerName = Sanitize(xPlayer.getName())
local discord_webhook = "WEBHOOK"
if discord_webhook == '' then
return
end
local headers = {
['Content-Type'] = 'application/json'
}
local data = {
["username"] = "USERNAME",
["avatar_url"] = "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
Here is an example event of a plugin that I log for you to understand the logic.
Code:
RegisterServerEvent("esx_newDrugs:reward")
AddEventHandler("esx_newDrugs:reward",function(amount,typed)
local xPlayer = ESX.GetPlayerFromId(source)
if xPlayer.canCarryItem(typed.."brick", math.ceil(amount)) then
xPlayer.addInventoryItem(typed.."brick",math.ceil(amount))
dclog(xPlayer, '**'..math.ceil(amount)..'x '..typed..'brick** elde etti.' )
else
TriggerClientEvent('mythic_notify:client:SendAlert', xPlayer.source, { type = 'error', text = 'Daha fazla taşıyamazsın!'})
end
end)
There are two types of data that the function needs.
The player performing the action and the text to be logged.
You can edit the text however you want.
If there is a place that is stuck in your mind or you cannot do it, you can comment under the topic.
The player performing the action and the text to be logged.
You can edit the text however you want.
If there is a place that is stuck in your mind or you cannot do it, you can comment under the topic.