Files
Elite-Gaming-FiveM/resources/[EGRP-Discord-Integration]/Discord-Logging/server.lua
T
Jacob 775709ddef New Improvements & Bug Fixes
+ Added new Wheel-Damage script which causes wheels to fly off if the car is hit hard.
+ Added newer version of the police siren LVC menu.
+ Changed a bunch of keybinds in order to facilitate FivePD.
+ Readded the accidentally removed emote menu and removed NoDriveBy.
+ Updated the server theme alittle away from just RP.
+ Updated to server artifacts version to 6372
2023-04-02 20:38:32 +01:00

90 lines
3.7 KiB
Lua

-- Made by Tazio
local DISCORD_WEBHOOK = "https://discord.com/api/webhooks/982313609268961320/HkhB-ih8xJLBEsntxBDk6xauyWo7mr8SDmWETK7GsnzEfMolxxQXZYnus5lf82Rcv4NQ"
local DISCORD_NAME = "Elite Gaming RP"
local STEAM_KEY = "0C034D20C57C8D6C5A8EED855916981F"
local DISCORD_IMAGE = "https://i.imgur.com/lF8nHnz.jpg" -- default is FiveM logo
--DON'T EDIT BELOW THIS
PerformHttpRequest(DISCORD_WEBHOOK, function(err, text, headers) end, 'POST', json.encode({username = DISCORD_NAME, content = "Discord Webhook is **ONLINE**", avatar_url = DISCORD_IMAGE}), { ['Content-Type'] = 'application/json' })
AddEventHandler('chatMessage', function(source, name, message)
if string.match(message, "@everyone") then
message = message:gsub("@everyone", "`@everyone`")
end
if string.match(message, "@here") then
message = message:gsub("@here", "`@here`")
end
--print(tonumber(GetIDFromSource('steam', source), 16)) -- DEBUGGING
--print('https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=' .. STEAM_KEY .. '&steamids=' .. tonumber(GetIDFromSource('steam', source), 16))
if STEAM_KEY == '' or STEAM_KEY == nil then
PerformHttpRequest(DISCORD_WEBHOOK, function(err, text, headers) end, 'POST', json.encode({username = name .. " [" .. source .. "]", content = message, tts = false}), { ['Content-Type'] = 'application/json' })
else
PerformHttpRequest('https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=' .. STEAM_KEY .. '&steamids=' .. tonumber(GetIDFromSource('steam', source), 16), function(err, text, headers)
local image = string.match(text, '"avatarfull":"(.-)","')
--print(image) -- DEBUGGING
PerformHttpRequest(DISCORD_WEBHOOK, function(err, text, headers) end, 'POST', json.encode({username = name .. " [" .. source .. "]", content = message, avatar_url = image, tts = false}), { ['Content-Type'] = 'application/json' })
end)
end
end)
AddEventHandler('playerConnecting', function()
--PerformHttpRequest(DISCORD_WEBHOOK, function(err, text, headers) end, 'POST', json.encode({username = DISCORD_NAME, content = "```CSS\n".. GetPlayerName(source) .. " connecting\n```", avatar_url = DISCORD_IMAGE}), { ['Content-Type'] = 'application/json' })
sendToDiscord("Server Login", "**" .. GetPlayerName(source) .. "** is connecting to the server.", 65280)
end)
AddEventHandler('playerDropped', function(reason)
local color = 16711680
if string.match(reason, "Kicked") or string.match(reason, "Banned") then
color = 16007897
end
sendToDiscord("Server Logout", "**" .. GetPlayerName(source) .. "** has left the server. \n Reason: " .. reason, color)
end)
RegisterServerEvent('playerDied')
AddEventHandler('playerDied',function(message)
sendToDiscord("Death log", message, 16711680)
end)
function GetIDFromSource(Type, ID) --(Thanks To WolfKnight [forum.FiveM.net])
local IDs = GetPlayerIdentifiers(ID)
for k, CurrentID in pairs(IDs) do
local ID = stringsplit(CurrentID, ':')
if (ID[1]:lower() == string.lower(Type)) then
return ID[2]:lower()
end
end
return nil
end
function stringsplit(input, seperator)
if seperator == nil then
seperator = '%s'
end
local t={} ; i=1
for str in string.gmatch(input, '([^'..seperator..']+)') do
t[i] = str
i = i + 1
end
return t
end
function sendToDiscord(name, message, color)
local connect = {
{
["color"] = color,
["title"] = "**".. name .."**",
["description"] = message,
["footer"] = {
["text"] = "Server Logging",
},
}
}
PerformHttpRequest(DISCORD_WEBHOOK, function(err, text, headers) end, 'POST', json.encode({username = DISCORD_NAME, embeds = connect, avatar_url = DISCORD_IMAGE}), { ['Content-Type'] = 'application/json' })
end