let players know when and why someone leaves the server

This commit is contained in:
edshot99 2024-04-13 04:33:56 -05:00
parent b4bd8be9d8
commit 0bebffd389
2 changed files with 21 additions and 0 deletions

View File

@ -0,0 +1,10 @@
net.Receive("edshot_player_disconnect_message_broadcast", function()
local name = net.ReadString()
local reason = net.ReadString()
if name and reason then
local message = "Player " .. name .. " has left the game (" .. reason .. ")"
chat.AddText(Color(255, 110, 110), message)
end
end)

View File

@ -0,0 +1,11 @@
util.AddNetworkString("edshot_player_disconnect_message_broadcast")
gameevent.Listen("player_disconnect")
hook.Add("player_disconnect", "edshot_player_disconnect_message", function(data)
if not data.bot then
net.Start("edshot_player_disconnect_message_broadcast")
net.WriteString(data.name)
net.WriteString(data.reason)
net.Broadcast()
end
end)