Skip to content

Commit b618e2b

Browse files
committed
Initial commit
0 parents  commit b618e2b

File tree

4 files changed

+75
-0
lines changed

4 files changed

+75
-0
lines changed

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

Serverlogging/__resource.lua

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
server_script 'server.lua'
2+
client_script 'client.lua'
3+
4+
description 'Server Logging'

Serverlogging/client.lua

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
-- Made by Tazio
2+
-- https://forum.fivem.net/t/release-death-messages-and-join-leave/16467
3+
4+
Citizen.CreateThread(function()
5+
-- main loop thing
6+
alreadyDead = false
7+
while true do
8+
Citizen.Wait(50)
9+
local playerPed = GetPlayerPed(-1)
10+
if IsEntityDead(playerPed) and not alreadyDead then
11+
killer = GetPedKiller(playerPed)
12+
killername = false
13+
for id = 0, 64 do
14+
if killer == GetPlayerPed(id) then
15+
killername = GetPlayerName(id)
16+
end
17+
end
18+
if killer == playerPed then
19+
TriggerServerEvent('playerDied',0,0)
20+
elseif killername then
21+
TriggerServerEvent('playerDied',killername,1)
22+
else
23+
TriggerServerEvent('playerDied',0,2)
24+
end
25+
alreadyDead = true
26+
end
27+
if not IsEntityDead(playerPed) then
28+
alreadyDead = false
29+
end
30+
end
31+
end)

Serverlogging/server.lua

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
-- Made by Tazio
2+
3+
local DISCORD_WEBHOOK = ""
4+
local DISCORD_NAME = "System"
5+
-- local DISCORD_IMAGE = "" !coming soon!
6+
7+
--PerformHttpRequest(DISCORD_WEBHOOK, function(err, text, headers) end, 'POST', json.encode({username = DISCORD_NAME, content = "**Serverlogging is ONLINE**"}), { ['Content-Type'] = 'application/json' })
8+
9+
10+
AddEventHandler('chatMessage', function(source, name, message)
11+
PerformHttpRequest(DISCORD_WEBHOOK, function(err, text, headers) end, 'POST', json.encode({username = name, content = message}), { ['Content-Type'] = 'application/json' })
12+
end)
13+
14+
AddEventHandler('playerConnecting', function()
15+
PerformHttpRequest(DISCORD_WEBHOOK, function(err, text, headers) end, 'POST', json.encode({username = DISCORD_NAME, content = "```".. GetPlayerName(source) .. " connecting ```"}), { ['Content-Type'] = 'application/json' })
16+
end)
17+
18+
AddEventHandler('playerDropped', function(reason)
19+
PerformHttpRequest(DISCORD_WEBHOOK, function(err, text, headers) end, 'POST', json.encode({username = DISCORD_NAME, content = "```".. GetPlayerName(source) .. " left ( ".. reason .. " )```"}), { ['Content-Type'] = 'application/json' })
20+
end)
21+
22+
RegisterServerEvent('playerDied')
23+
AddEventHandler('playerDied',function(killer,reason)
24+
if killer == "**Invalid**" then --Can't figure out what's generating invalid, it's late. If you figure it out, let me know. I just handle it as a string for now.
25+
reason = 2
26+
end
27+
if reason == 0 then
28+
--TriggerClientEvent('showNotification', -1,"~o~".. GetPlayerName(source).."~w~ committed suicide. ")
29+
PerformHttpRequest(DISCORD_WEBHOOK, function(err, text, headers) end, 'POST', json.encode({username = DISCORD_NAME, content = GetPlayerName(source) .. " committed suicide"}), { ['Content-Type'] = 'application/json' })
30+
elseif reason == 1 then
31+
--TriggerClientEvent('showNotification', -1,"~o~".. killer .. "~w~ killed ~o~"..GetPlayerName(source).."~w~.")
32+
PerformHttpRequest(DISCORD_WEBHOOK, function(err, text, headers) end, 'POST', json.encode({username = DISCORD_NAME, content = GetPlayerName(source) .. " was killed by: " .. killer}), { ['Content-Type'] = 'application/json' })
33+
else
34+
--TriggerClientEvent('showNotification', -1,"~o~".. GetPlayerName(source).."~w~ died.")
35+
PerformHttpRequest(DISCORD_WEBHOOK, function(err, text, headers) end, 'POST', json.encode({username = DISCORD_NAME, content = GetPlayerName(source) .. " died"}), { ['Content-Type'] = 'application/json' })
36+
37+
end
38+
end)

0 commit comments

Comments
 (0)