Update 19.06.2021

This commit is contained in:
ENoir420
2021-06-19 13:49:16 +02:00
parent 6831a026cb
commit a8cb3cb554
6 changed files with 65 additions and 217 deletions

149
README.md
View File

@@ -1,149 +0,0 @@
<h1 align="center">
JOIN THE DISCORD FOR SUPPORT
</h1>
<img src="https://i.gyazo.com/3894b03d4351bcb566ec85afc7f9b231.png">
<h4 align="center">
<a href="https://github.com/JokeDevil-com/JD_logs/releases/latest" title=""><img alt="Licence" src="https://img.shields.io/github/release/JokeDevil-com/JD_logs.svg"></a>
<a href="LICENSE" title=""><img alt="Licence" src="https://img.shields.io/github/license/JokeDevil-com/JD_logs.svg"></a>
<a href="https://discord.gg/m4BvmkG" title=""><img alt="Discord Status" src="https://discordapp.com/api/guilds/721339695199682611/widget.png"></a>
</h4>
<h4 align="center">
This is a server log script for FiveM, which is used to log certain actions that are being made in the server.
</h5>
### 🛠 Requirements
- A Discord Server
- FXServer
### ✅ Main Features
- Basic logs:
- Chat Logs (Messages typed in chat)
- Join Logs (When i player is connecting to the sever)
- Leave Logs (When a player disconnects from the server)
- Death Logs (When a player dies/get killed)
- Shooting Logs (When a player fires a weapon)
- Resource Logs (When a resouce get started/stopped)
- Plugin Support
- Easy way to add more logs to JD_logs with plugins. (More plugins will be released soon!)
- Optional custom logs
- Easy to add with the export.
### 🔧 Download & Installation
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
```
### 📝 Creating Custom Logs
1. Add the following code to your function/command.<br>
*This code needs to be added in the resource of the action you want to log.*
```
exports.JD_logs:discord('EMBED_MESSAGE', PLAYER_ID, PLAYER_2_ID, 'COLOR', 'WEBHOOK_CHANNEL')
```
`EMBED_MESSAGE`: This will be the message send in the top of the embed.<br>
`PLAYER_ID`: This will send the player to the script to get the info. (This needs to be a server id)<br>
`PLAYER_2_ID`: This will send the second player's to the script to get the info. (This needs to be a server id)<br>
`COLOR`: This will be the color of the embed. (You can use Decimal colors or Hex colors.)<br>
`WEBHOOK_CHANNEL`: This will be the webhook channel listed in the config.lua.<br>
2. Create a discord channel with webhook and add this to the webhooks.
```
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", <------
}
```
*This can be found in the `config.lua`*
### ❓ For more questions you can join the discord here: https://discord.gg/m4BvmkG
<details>
<summary>📦 Change Log</summary>
<br>
<details>
<summary>V1.3.0</summary>
• Added Plugin Support<br>
</details>
<summary>V1.1.6</summary>
• Fixed Death logs issue<br>
</details>
<details>
<summary>V1.1.5</summary>
• Bug fix/code clean up<br>
</details>
<details>
<summary>V1.1.4</summary>
• Bug fixes<br>
</details>
<details>
<summary>V1.1.3</summary>
• Bug fixes<br>
</details>
<details>
<summary>V1.1.2</summary>
• Added: License Identifier <code>Config.license = true</code> <br>
• Added: Player IP address <code>Config.IP = true</code><br>
</details>
<details>
<summary>V1.1.1</summary>
• Added hex color code support. (Old decimal color codes will still work.)<br>
• Added option to hide player info on exports. (Very simple just change the PLAYER_ID to 0 and it wont show any info.)
</details>
<details>
<summary>V1.1.0</summary>
• Reworked Export function. (Now with identifier support)<br>
</details>
<details>
<summary>V1.0.4</summary>
• Added Nearest Postal For This Postal Map<br>
• Added check if the identifier is available ( Prevents some errors :slight_smile: )<br>
• Fixed some small bugs<br>
</details>
<details>
<summary>V1.0.3</summary>
• Added Discord Identifier<br>
• Added Steam Profile URL<br>
• Fixed Death Reason<br>
• Player commited suicide<br>
• Player was murdered<br>
• Player Died (Other reasons like getting run over or random explosions)<br>
</details>
<details>
<summary>V1.0.2</summary>
• Added more Customizations<br>
&nbsp;&nbsp;• Bot's Username<br>
&nbsp;&nbsp;• Bot's Avatar<br>
&nbsp;&nbsp;• Embed Community Name<br>
&nbsp;&nbsp;• Embed Community Logo<br>
• Color settings for default Events<br>
• Added Player ID to default Events<br>
• Added Option to enable/disable Player ID<br>
• Added option to enable/disable Steam ID<br>
</details>
<details>
<summary>V1.0.1</summary>
• Added option to disable Shooting Logs<br>
</details>
<details>
<summary>V1.0.0</summary>
• All log channel<br>
• Log to seperate channels<br>
• Log from server or client side<br>
• Easy changeble Avatar and Username<br>
</details>
</details>

View File

@@ -370,6 +370,6 @@ end
function ShowDebug(text)
SetNotificationTextEntry("STRING")
AddTextComponentSubstringPlayerName("~b~JD_logs Debug:~s~\n"..text)
AddTextComponentSubstringPlayerName("~bENoir_logs Debug:~s~\n"..text)
DrawNotification(true, true)
end

View File

@@ -1,53 +1,53 @@
Config = {}
Config.AllLogs = true -- Attiva/Disattiva tutti i Log
Config.postal = false -- Attiva/Disattiva il civico nei Log
Config.username = "Bot Username Here" -- Bot Username
Config.avatar = "https://via.placeholder.com/30x30" -- Bot Avatar
Config.communtiyName = "Community Name Here" -- Icon top of the embed
Config.communtiyLogo = "https://via.placeholder.com/30x30" -- Icon top of the embed
Config.FooterText = "2021 ENoir" -- Footer text for the embed
Config.FooterIcon = "https://via.placeholder.com/30x30" -- Footer icon for the embed
Config.AllLogs = true -- Attiva/Disattiva i logs
Config.postal = false -- se lo setti False, non apparirà il civico di spawn
Config.username = "Bot Log" -- Bot Username
Config.avatar = "https://placeholder.com/" -- Bot Avatar
Config.communtiyName = "" -- Nome al top embed
Config.communtiyLogo = "https://placeholder.com/" -- Icona al top embed
Config.FooterText = "2021 ENoir_420" -- Testo Footer per l' embed
Config.FooterIcon = "https://placeholder.com/" -- Icona Footer per l' embed
Config.weaponLog = true -- set to false to disable the shooting weapon logs
Config.InlineFields = true -- set to false if you don't want the player details next to each other
Config.weaponLog = true -- setta False per disabilitare i colpi d'arma da fuoco log
Config.InlineFields = true -- setta False per disabilitare i dettagli dei player
Config.playerID = true -- set to false to disable Player ID in the logs
Config.steamID = true -- set to false to disable Steam ID in the logs
Config.steamURL = true -- set to false to disable Steam URL in the logs
Config.discordID = true -- set to false to disable Discord ID in the logs
Config.license = true -- set to false to disable license in the logs
Config.IP = true -- set to false to disable IP in the logs
Config.playerID = false -- setta False per disabilitare il Player ID nei Log
Config.steamID = true -- setta False per disabilitare lo Steam ID nei Log
Config.steamURL = false -- setta False per disabilitare lo URL Steam nei Log
Config.discordID = true -- setta False per disabilitare il Discord ID nei Log
Config.license = false -- setta False per disabilitare il numero di licenza nei Log
Config.IP = false -- setta False per disabilitare l'indirizzo IP nei Log
Config.BaseColors ={
chat = "#A1A1A1", -- Chat Message
joins = "#3AF241", -- Player Connecting
leaving = "#F23A3A", -- Player Disconnected
deaths = "#000000", -- Shooting a weapon
shooting = "#2E66F2", -- Player Died
resources = "#EBEE3F", -- Resource Stopped/Started
joins = "#3AF241", -- Log-in Player
leaving = "#F23A3A", -- Log-out Player
deaths = "#000000", -- Player che spara
shooting = "#2E66F2", -- Player Morto
resources = "#EBEE3F", -- Risorsa Startata/Stoppata
}
Config.webhooks = {
all = "DISCORD_WEBHOOK", -- All logs will be send to this channel
all = "DISCORD_WEBHOOK", -- Tutti i log in un unico canale
chat = "https://discord.com/api/webhooks/855611974058377228/xeXRIc7eexnm9Ys7lAdtsWdpANQ9Usg-6hloMK_8w92gTDjBY1T_ezjAnc4ydgdGcppc", -- Chat Message
joins = "https://discord.com/api/webhooks/855611628946456586/LoZmJUH3QzPjc-e_URfsFCLiS2NxTEr9M1A36dFPABSc2_5pPd7FD4NQnYoC0Xj1HLNA", -- Player Connecting
leaving = "https://discord.com/api/webhooks/855611628946456586/LoZmJUH3QzPjc-e_URfsFCLiS2NxTEr9M1A36dFPABSc2_5pPd7FD4NQnYoC0Xj1HLNA", -- Player Disconnected
deaths = "https://discord.com/api/webhooks/855611853043793930/oCLMu6xZgbZ8O6vRoJ-SZYcCgB1fTbk8-34UNyf1rd-T2NenNxQC8Dw136TLykLIMW2I", -- Shooting a weapon
shooting = "DISCORD_WEBHOOK", -- Player Died
resources = "https://discord.com/api/webhooks/855615988141391882/jHIpJptNwCMagtjvg2_txtjby535vhBygLj2DwCgxAdAfQlF0fQlPnTAcG9MULqG4dJf", -- Resource Stopped/Started
joins = "https://discord.com/api/webhooks/855611628946456586/LoZmJUH3QzPjc-e_URfsFCLiS2NxTEr9M1A36dFPABSc2_5pPd7FD4NQnYoC0Xj1HLNA", -- Log-in Player
leaving = "https://discord.com/api/webhooks/855611628946456586/LoZmJUH3QzPjc-e_URfsFCLiS2NxTEr9M1A36dFPABSc2_5pPd7FD4NQnYoC0Xj1HLNA", -- Log-out Player
deaths = "https://discord.com/api/webhooks/855611853043793930/oCLMu6xZgbZ8O6vRoJ-SZYcCgB1fTbk8-34UNyf1rd-T2NenNxQC8Dw136TLykLIMW2I", -- Player che spara
shooting = "DISCORD_WEBHOOK", -- Player Morto
resources = "https://discord.com/api/webhooks/855615988141391882/jHIpJptNwCMagtjvg2_txtjby535vhBygLj2DwCgxAdAfQlF0fQlPnTAcG9MULqG4dJf", -- Risorsa Startata/Stoppata
}
Config.TitleIcon = {
chat = "💬", -- Chat Message
joins = "📥", -- Player Connecting
leaving = "📤", -- Player Disconnected
deaths = "💀", -- Shooting a weapon
shooting = "🔫", -- Player Died
resources = "🔧", -- Resource Stopped/Started
joins = "📥", -- Log-in Player
leaving = "📤", -- Log-out Player
deaths = "💀", -- Player che spara
shooting = "🔫", -- Player Morto
resources = "🔧", -- Risorsa Startata/Stoppata
}
Config.Plugins = {
@@ -58,4 +58,4 @@ Config.Plugins = {
Config.debug = false
Config.versionCheck = "1.3.0"
Config.versionCheck = "1.0.0"

View File

@@ -1,17 +1,18 @@
author 'ENoir_420'
author 'ENoir'
description 'FXServer logs to Discord'
version '1.0.0'
-- Config
server_script 'config.lua'
-- Server Scripts
server_scripts {
'server/server.lua',
'plugins/server/**/*.lua'
}
--Client Scripts
client_scripts {
'client/client.lua',
'plugins/client/**/*.lua'

View File

@@ -1,3 +1 @@
{
"steam:123456789123456": "JokeDevil"
}
{"steam:1100001112ce4d0":"BanHammer"}

View File

@@ -24,11 +24,11 @@ exports('discord', function(message, id, id2, color, channel)
local _message = message
if message == nil then print("^1Error: Enoir Export. Invalid message.^0") return end
if id == nil or id == "PLAYER_ID" or not tonumber(id) then print("^1Error: ENoir Export. Invalid player id.^0") return end
if id == nil or id2 == "PLAYER_2_ID" or not tonumber(id2) then print("^1Error: ENoir Export. Invalid second player id.^0") return end
if color == nil then print("^1Error: ENoir Export. Invalid color.^0") return end
if channel == nil or channel == "" then print("^1Error: ENoir Export. Invalid channel.^0") return end
if message == nil then print("^1Error: ENoir_Logs Export. Invalid message.^0") return end
if id == nil or id == "PLAYER_ID" or not tonumber(id) then print("^1Error: ENoir_Logs Export. Invalid player id.^0") return end
if id == nil or id2 == "PLAYER_2_ID" or not tonumber(id2) then print("^1Error: ENoir_Logs Export. Invalid second player id.^0") return end
if color == nil then print("^1Error: ENoir_Logs Export. Invalid color.^0") return end
if channel == nil or channel == "" then print("^1Error: ENoir_Logs Export. Invalid channel.^0") return end
if string.find(color,"#") then _color = tonumber(color:gsub("#",""),16) else _color = color end
@@ -390,31 +390,30 @@ end
AddEventHandler("playerConnecting", function(name, setReason, deferrals)
SinglePlayerLogs('**' ..GetPlayerName(source).. '** si sta collegando al server.', Config.BaseColors['Connessione'], source, 'Connessione')
SinglePlayerLogs('**' ..GetPlayerName(source).. '** si sta connettendo al server.', Config.BaseColors['Connessione'], source, 'Connessione')
end)
AddEventHandler('playerDropped', function(reason)
SinglePlayerLogs('**' ..GetPlayerName(source).. '** è uscito dal server. (Reason: ' .. reason .. ')', Config.BaseColors['Uscita'], source, 'Uscita')
SinglePlayerLogs('**' ..GetPlayerName(source).. '** ha quittato il server. (Reason: ' .. reason .. ')', Config.BaseColors['Disconnesso'], source, 'Disconnesso')
end)
-- Send message when Player creates a chat message (Does not show commands)
AddEventHandler('chatMessage', function(source, name, msg)
SinglePlayerLogs('**' .. sanitize(GetPlayerName(source)) .. '**: `' .. msg..'`', Config.BaseColors['chat'], source, 'chat')
SinglePlayerLogs('**' .. sanitize(GetPlayerName(source)) .. '** ha scritto in chat `' .. msg..'`', Config.BaseColors['chat'], source, 'chat')
end)
-- Send message when Player died (including reason/killer check) (Not always working)
RegisterServerEvent('playerDied')
AddEventHandler('playerDied',function(id,player,killer,DeathReason, Weapon)
if Weapon == nil then _Weapon = "" else _Weapon = "`"..Weapon.."`" end
if id == 1 then -- Suicide/died
SinglePlayerLogs('**' .. sanitize(GetPlayerName(source)) .. '** `'..DeathReason..'` '.._Weapon, Config.BaseColors['deaths'], source, 'deaths') -- sending to deaths channel
elseif id == 2 then -- Killed by other player
DualPlayerLogs('**' .. GetPlayerName(killer) .. '** è stato ucciso da'..DeathReason..' ' .. GetPlayerName(source).. ' `('.._Weapon..')`', Config.BaseColors['deaths'], killer, source, 'deaths')
else -- When gets killed by something else
SinglePlayerLogs('**' .. GetPlayerName(source) .. '** `died`', Config.BaseColors['deaths'], source, 'deaths') -- sending to deaths channel
if id == 1 then
SinglePlayerLogs('**' .. sanitize(GetPlayerName(source)) .. '** si è suicidato per colpa di '.._Weapon, Config.BaseColors['morte/suicidio'], source, 'morte/suicidio')
elseif id == 2 then
DualPlayerLogs('**' .. GetPlayerName(killer) .. '** è stato ucciso da ' .. GetPlayerName(source).. ' `('.._Weapon..')`', Config.BaseColors['morte/suicidio'], killer, source, 'morte/suicidio')
else
SinglePlayerLogs('**' .. GetPlayerName(source) .. '** `è morto per colpa di`', Config.BaseColors['morte/suicidio'], source, 'morte/suicidio')
end
end)
@@ -423,7 +422,7 @@ RegisterServerEvent('playerShotWeapon')
AddEventHandler('playerShotWeapon', function(weapon)
local info = GetPlayerDetails(source)
if Config.weaponLog then
SinglePlayerLogs('**' .. GetPlayerName(source) .. '** a sparato con `' .. weapon .. '`', Config.BaseColors['shooting'], source, 'shooting')
SinglePlayerLogs('**' .. GetPlayerName(source) .. '** ha sparato con `' .. weapon .. '`', Config.BaseColors['shooting'], source, 'shooting')
end
end)
@@ -432,11 +431,11 @@ RegisterServerEvent('ClientDiscord')
AddEventHandler('ClientDiscord', function(message, id, id2, color, channel)
local _message = message
if message == nil then print("^1Error: ENoir Export. Invalid message.^0") return end
if id == nil or id == "PLAYER_ID" or not tonumber(id) then print("^1Error: ENoir Export. Invalid player id.^0") return end
if id == nil or id2 == "PLAYER_2_ID" or not tonumber(id2) then print("^1Error: ENoir Export. Invalid second player id.^0") return end
if color == nil then print("^1Error: ENoir Export. Invalid color.^0") return end
if channel == nil or channel == "" then print("^1Error: ENoir Export. Invalid channel.^0") return end
if message == nil then print("^1Error: ENoir_Logs Export. Invalid message.^0") return end
if id == nil or id == "PLAYER_ID" or not tonumber(id) then print("^1Error: ENoir_Logs Export. Invalid player id.^0") return end
if id == nil or id2 == "PLAYER_2_ID" or not tonumber(id2) then print("^1Error: ENoir_Logs Export. Invalid second player id.^0") return end
if color == nil then print("^1Error: ENoir_Logs Export. Invalid color.^0") return end
if channel == nil or channel == "" then print("^1Error: Enoir_Logs Export. Invalid channel.^0") return end
if string.find(color,"#") then _color = tonumber(color:gsub("#",""),16) else _color = color end
@@ -454,13 +453,13 @@ end)
AddEventHandler('onResourceStop', function (resourceName)
HidePlayerDetails('** è stata stoppata la seguente risorsa' '**' .. resourceName .. , Config.BaseColors['risorse server'], 'risorse server')
HidePlayerDetails('**' .. resourceName .. '** è stata stoppata.', Config.BaseColors['resources'], 'resources')
end)
AddEventHandler('onResourceStart', function (resourceName)
Wait(100)
HidePlayerDetails('** è stata startata la seguente risorsa' '**' .. resourceName .. , Config.BaseColors['risorse server'], 'risorse server')
HidePlayerDetails('**' .. resourceName .. '** è stata startata.', Config.BaseColors['resources'], 'resources')
end)
function GetPlayerDetails(src)
@@ -549,4 +548,3 @@ end
function firstToUpper(str)
return (str:gsub("^%l", string.upper))
end