[Release] Server Logs to Discord

Logs 2 Discord

This is a server log script, which is used to log certain actions that are being made in the server.

V 1.1.0
  • Reworked Export function. (Now with identifier support)

Github
Download

Documentation
Showcase Video (Tnx to @Mailar) Updated Video for v1.1.0


Update History:

V 1.0.4
  • Added Nearest Postal For This Postal Map
  • Added check if the identifier is available ( Prevents some errors :slight_smile: )
  • Fixed some small bugs

V 1.0.3
  • Added Discord Identifier
  • Added Steam Profile URL
  • Fixed Death Reason
    • Player commited suicide
    • Player was murdered
    • Player Died (Other reasons like getting run over or random explosions)

V 1.0.2
  • Added more Customizations
    • Bot’s Username
    • Bot’s Avatar
    • Embed Community Name
    • Embed Community Logo
    • Color settings for default Events (You can get the decimal color values here)
  • Added Player ID to default Events
  • Added Option to enable/disable Player ID
  • Added option to enable/disable Steam ID

V 1.0.1
  • Added option to disable Shooting Logs

V 1.0.0
  • All log channel
  • Log to seperate channels
  • Log from server or client side
  • Easy changeble Avatar and Username
  • Option to change embed footer


Requirements
  • A Discord Server
  • FiveM FXServer

Install
  1. Download the files
  2. Put the JD_logs folder in the server resource directory
  3. Add this to your server.cfg:
ensure JD_logs

Adding more logs
  • Add the following code to your existing resource where you execude the code
exports.JD_logs:discord('MESSAGE_YOU_WANT_TO_POST_IN_THE_EMBED',PLAYER_ID,PLAYER_2_ID, 'DECIMAL_COLOR', 'WEBHOOK_CHANNEL')
  • Player ID is the server id of the player.
  • Player 2 ID is the sever id of player 2 (Set Player 2 ID to 0 if you only have 1 player.)
  • Decimal color is a color code in decimal you can get them from here
  • Create a discord channel with webhook and add this to the webhooks in the config.cfg
local webhooks = {
	all = "DISCORD_WEBHOOK",
	chat = "DISCORD_WEBHOOK",
	joins = "DISCORD_WEBHOOK",
	leaving = "DISCORD_WEBHOOK",
	deaths = "DISCORD_WEBHOOK",
	shooting = "DISCORD_WEBHOOK",
	resources = "DISCORD_WEBHOOK",
	WEBHOOK_CHANNEL = "DISCORD_WEBHOOK", <------
}


29 Likes

Nice release, better than any of the other ones on here. Maybe add logging for commands such as /twt, /ooc, /vpn ext :slight_smile:

5 Likes

Just what i needed! Thankyou :slight_smile:

1 Like

Nice release! Good work

1 Like

I think that it is important to log commands such as /twt, /ooc, /vpn ext :slight_smile:

I’m looking at the function to send from other resources to this and then to discord. I get how to add the new channel to this script, but I’m looking at things like our /ad, /ooc, etc… The example below is our Advert script that uses /ad. I “think” I have the string your stated above in the right place but really, I have no idea what I’m doing and I don’t know what I would need to put in to get it to send all the info from the advert.

AddEventHandler('chatMessage', function(source, name, msg)
	sm = stringsplit(msg, " ");
	if sm[1] == "/ad" then
		CancelEvent()
		TriggerClientEvent('chatMessage', -1, "ADVERT | " .. name, { 139, 142, 247 }, string.sub(msg,5))
		--export to jd discord
		exports.JD_logs:discord('<MESSAGE_YOU_WANT_TO_POST_IN_THE_EMBED>', '1752220', '<ADVERT2DISCORD>')
	end
end)

function stringsplit(inputstr, sep)
    if sep == nil then
        sep = "%s"
    end
    local t={} ; i=1
    for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
        t[i] = str
        i = i + 1
    end
    return t
end
2 Likes

@TTVResqDiver1317
Ye that’s the right place

2 Likes

It’s on my todo list :slight_smile:

1 Like
AddEventHandler('chatMessage', function(source, name, msg)
	sm = stringsplit(msg, " ");
	if sm[1] == "/ad" then
		CancelEvent()
		TriggerClientEvent('chatMessage', -1, "ADVERT | " .. name, { 139, 142, 247 }, string.sub(msg,5))
		--export to jd discord
		exports.JD_logs:discord('Advert | ' .. name, { 139, 142, 247 }, string.sub(msg,5), '1752220', 'Advert2Discord')
	end
end)

And then in the JD_logs config.lua you have to add your wehbook like this:

local webhooks = {
	all = "<DISCORD_WEBHOOK>",
	chat = "<DISCORD_WEBHOOK>",
	joins = "<DISCORD_WEBHOOK>",
	leaving = "<DISCORD_WEBHOOK>",
	deaths = "<DISCORD_WEBHOOK>",
	shooting = "<DISCORD_WEBHOOK>",
	resources = "<DISCORD_WEBHOOK>",
	Advert2Discord = "<DISCORD_WEBHOOK>", <------
}
2 Likes

Thank you for the reply!! I am not a coder/developer by any means but I understand just enough to mostly follow what I am looking at and was 85% sure that is what was needed to be put there, but that 15% unsure portion of me thought yea, lets ask and make sure!

One more question, our current server to discord resource (I believe it’s from Tazio), when someone dies, it just reports every death as “‘whoeveritis’ was killed by an unknown force”. It doesn’t actually tell us in discord who killed them or how they were killed which is an issue for me as one of the main reasons for wanting logs to discord is to see who killed someone when we have to investigate reports of RDM. Will this one actually report deaths properly?

Yeah it checks how the player has died .
So if someone killes someone else it will display this.
even what weapon was used to do so.

And questions are never wrong. glad i could help ya :slight_smile:

1 Like

How would I add this to track when players give money/items. Also How to track banking transfers. I undersatnd to add the exports.JD_logs:discord(’<MESSAGE_YOU_WANT_TO_POST_IN_THE_EMBED>’, ‘1752220’, ‘<WEBHOOK_CHANNEL>’
Where i want the log to be generated. But how to i tell it to print what was transferred?
Thanks

I got it all setup and created a channel for the shooting and death notices to go to and when we tested, it showed someone shot a gun and in a separate post, showed a person dying, but did not say how they died or who actually killed them.
https://gyazo.com/f8523b6ad2e6e74c72a9d16cb1fd8a60

I’ll have a look into it tomorrow.
Thanks for letting me know :slight_smile:

You have to get the values from where you add the export. you can add them in the message string like this:

exports.JD_logs:discord(’SOME_TEXT_HERE’ .. Variable .. ’SOME_MORE_TEXT_HERE’, ‘1752220’, ‘<WEBHOOK_CHANNEL>’)

No problem, Also, is it possible to turn off the shoot function? We noticed when someone used a jerry can to refuel their car, it spammed the heck out of that discord channel (not a huge deal as I moved the shoot webhook to it’s own channel that we can ignore, but really, we don’t need that particular function for our use)

I’ve added it to the config.
Latest version on Github :wink:

3 Likes

Now that you released the update (thank you for that by the way!) I just noticed something else that I was curious if it could be added next time you update this again. Is there anyway the chat section can show the server ID of the person talking in the logs? Mainly, when someone spams chat (or when someone with a mod menu launches an attack that also spams chat), it’s nice to have the player ID so we can quickly kick or ban them as needed without having to take the extra time to look up their ID (especially those times where they are using a mod menu that is lagging the server enough it makes it hard to look up IDs)

1 Like

Yeah sure!

it’s gonna be in next update :slight_smile:

2 Likes

You rock!!!

2 Likes