-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.lua
46 lines (37 loc) · 1.27 KB
/
server.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
local webhook = "ADDYOURDISCORDWEBHOOK"
RegisterCommand("combat", function(source, args, rawcmd)
TriggerClientEvent("NHdisconnect:show", source)
end)
AddEventHandler("playerDropped", function(reason)
local crds = GetEntityCoords(GetPlayerPed(source))
local id = source
local identifier = ""
local discordName = nil
-- Loop through all identifiers to find Discord
for i = 0, GetNumPlayerIdentifiers(id) - 1 do
local iden = GetPlayerIdentifier(id, i)
if string.sub(iden, 1, 8) == "discord:" then
discordName = iden -- Save the discord identifier
break
end
end
-- Fallback if Discord identifier not found
if discordName then
identifier = discordName
else
identifier = "Discord not linked"
end
TriggerClientEvent("NHdisconnect", -1, id, crds, identifier, reason)
if Config.LogSystem then
SendLog(id, crds, identifier, reason)
end
end)
function SendLog(id, crds, identifier, reason)
local name = GetPlayerName(id)
local date = os.date('*t')
print("id:"..id)
print("X: "..crds.x..", Y: "..crds.y..", Z: "..crds.z)
print("identifier:"..identifier)
print("reason:"..reason)
-- Additional logging or webhook send code here
end