Track LocalMods as part of monolith
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
if SERVER then return end
|
||||
if Game.IsSingleplayer then return end
|
||||
|
||||
local message = Networking.Start("client_side_enforced")
|
||||
Networking.Send(message)
|
||||
@@ -0,0 +1,61 @@
|
||||
if CLIENT then return end
|
||||
|
||||
LuaCsClientSideEnforced = {}
|
||||
LuaCsClientSideEnforced.KickTimer = 30
|
||||
|
||||
LuaUserData.RegisterType("Barotrauma.Networking.FileSender")
|
||||
|
||||
local function IsDownloading(client)
|
||||
for key, value in pairs(Game.Server.FileSender.ActiveTransfers) do
|
||||
if value.Connection == client.Connection then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
local clients = {}
|
||||
|
||||
local function GetOrCreateData(client)
|
||||
if not clients[client] then
|
||||
clients[client] = {}
|
||||
clients[client].HasInstalled = false
|
||||
clients[client].KickTimer = 0
|
||||
end
|
||||
|
||||
return clients[client]
|
||||
end
|
||||
|
||||
-- assume every already connected client has already client-side installed
|
||||
for _, client in pairs(Client.ClientList) do
|
||||
local data = GetOrCreateData(client)
|
||||
data.HasInstalled = true
|
||||
data.KickTimer = 0
|
||||
end
|
||||
|
||||
Networking.Receive("client_side_enforced", function(message, client)
|
||||
local data = GetOrCreateData(client)
|
||||
|
||||
if data.HasInstalled then return end
|
||||
data.HasInstalled = true
|
||||
data.KickTimer = 0
|
||||
|
||||
Logger.Log(TextManager.Get("luacs.svenforced.heartbeat").Value .. client.Name, Color.Green)
|
||||
end)
|
||||
|
||||
Hook.Add("client.connected", "ClientSideEnforced", function (client)
|
||||
GetOrCreateData(client)
|
||||
end)
|
||||
|
||||
Hook.Add("think", "ClientSideEnforced", function(client)
|
||||
for client, data in pairs(clients) do
|
||||
if not data.HasInstalled and not IsDownloading(client) then
|
||||
if data.KickTimer > LuaCsClientSideEnforced.KickTimer then
|
||||
client.Kick(TextManager.Get("luacs.enforced.kickmessage").Value)
|
||||
else
|
||||
data.KickTimer = data.KickTimer + 1/60
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
Reference in New Issue
Block a user