mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 20:41:41 +09:00
Added ExpGamingPlayer.afkKick
This commit is contained in:
@@ -1,39 +0,0 @@
|
|||||||
--[[
|
|
||||||
Explosive Gaming
|
|
||||||
|
|
||||||
This file can be used with permission but this and the credit below must remain in the file.
|
|
||||||
Contact a member of management on our discord to seek permission to use our code.
|
|
||||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
|
||||||
Discord: https://discord.gg/r6dC2uK
|
|
||||||
]]
|
|
||||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
|
||||||
|
|
||||||
function get_allowed_afk_time(player)
|
|
||||||
local rank = Ranking.get_rank(player)
|
|
||||||
local count = #game.connected_players
|
|
||||||
local base = rank.base_afk_time or false
|
|
||||||
if not base then return false end
|
|
||||||
return (base/5)*count
|
|
||||||
end
|
|
||||||
|
|
||||||
Event.register(-1,function(event)
|
|
||||||
Server.new_thread{
|
|
||||||
name='afk-kick',
|
|
||||||
}:on_event('tick',function(self)
|
|
||||||
if (game.tick%3600) ~= 0 then return end
|
|
||||||
for _,player in pairs(game.connected_players) do
|
|
||||||
local afk = #game.connected_players < 3 and 10 or get_allowed_afk_time(player)
|
|
||||||
if afk then
|
|
||||||
if player.afk_time > afk*3600 then game.kick_player(player,'AFK For Too Long ('..math.floor(afk)..' Minutes)') end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end):on_event('error',function(self,err)
|
|
||||||
Sync.emit_embeded{
|
|
||||||
title='Auto Kick Error',
|
|
||||||
color=Color.to_hex(defines.text_color.bg),
|
|
||||||
description='Auto Kick Error - Closed Thread',
|
|
||||||
Error=err
|
|
||||||
}
|
|
||||||
self:close()
|
|
||||||
end):open()
|
|
||||||
end)
|
|
||||||
38
modules/ExpGamingPlayer/afkKick/control.lua
Normal file
38
modules/ExpGamingPlayer/afkKick/control.lua
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
--- A full ranking system for factorio.
|
||||||
|
-- @module ExpGamingPlayer.playerInfo
|
||||||
|
-- @author Cooldude2606
|
||||||
|
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||||
|
|
||||||
|
local Game = require('FactorioStdLib.Game')
|
||||||
|
local Gui = require('ExpGamingCore.Gui')
|
||||||
|
local Ranking -- hanndled on load
|
||||||
|
local Sync -- hanndled on load
|
||||||
|
|
||||||
|
function get_allowed_afk_time(player)
|
||||||
|
local rank
|
||||||
|
if Ranking then rank = Ranking.get_rank(player)
|
||||||
|
else if player.admin then return else rank = {base_afk_time=15} end end
|
||||||
|
local count = #game.connected_players
|
||||||
|
local base = rank.base_afk_time or false
|
||||||
|
if not base then return false end
|
||||||
|
return (base/5)*count
|
||||||
|
end
|
||||||
|
|
||||||
|
script.on_event(defines.events.on_tick,function(event)
|
||||||
|
if (game.tick%3600) ~= 0 then return end
|
||||||
|
for _,player in pairs(game.connected_players) do
|
||||||
|
local afk = #game.connected_players < 3 and 10 or get_allowed_afk_time(player)
|
||||||
|
if afk then
|
||||||
|
if player.afk_time > afk*3600 then game.kick_player(player,'AFK For Too Long ('..math.floor(afk)..' Minutes)') end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
return {
|
||||||
|
get_allowed_afk_time=get_allowed_afk_time,
|
||||||
|
on_init=function(self)
|
||||||
|
if loaded_modules['ExpGamingCore.Ranking'] then Ranking = require('ExpGamingCore.Ranking') end
|
||||||
|
if loaded_modules['ExpGamingCore.Sync'] then Sync = require('ExpGamingCore.Sync') end
|
||||||
|
if loaded_modules['ExpGamingCore.Server'] then require(module_path..'/src/server.lua',Sync) end
|
||||||
|
end
|
||||||
|
}
|
||||||
21
modules/ExpGamingPlayer/afkKick/softmod.json
Normal file
21
modules/ExpGamingPlayer/afkKick/softmod.json
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"name": "afkKick",
|
||||||
|
"version": "4.0.0",
|
||||||
|
"type": "Submodule",
|
||||||
|
"description": "Adds a varible amount of time before a user is kicked based on the current player count.",
|
||||||
|
"location": "<blank>",
|
||||||
|
"keywords": [
|
||||||
|
"Kick",
|
||||||
|
"AFK",
|
||||||
|
"Players",
|
||||||
|
"Smart",
|
||||||
|
"Varible"
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"FactorioStdLib.Game": "^0.8.0",
|
||||||
|
"ExpGamingCore.Gui": "^4.0.0",
|
||||||
|
"ExpGamingCore.Ranking": "?^4.0.0",
|
||||||
|
"ExpGamingCore.Sync": "?^4.0.0",
|
||||||
|
"ExpGamingCore.Server": "?^4.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
25
modules/ExpGamingPlayer/afkKick/src/server.lua
Normal file
25
modules/ExpGamingPlayer/afkKick/src/server.lua
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
local Sync = Sync
|
||||||
|
Event[defines.events.on_tick] = nil
|
||||||
|
script.on_init(function(event)
|
||||||
|
Server.new_thread{
|
||||||
|
name='afk-kick',
|
||||||
|
}:on_event('tick',function(self)
|
||||||
|
if (game.tick%3600) ~= 0 then return end
|
||||||
|
for _,player in pairs(game.connected_players) do
|
||||||
|
local afk = #game.connected_players < 3 and 10 or get_allowed_afk_time(player)
|
||||||
|
if afk then
|
||||||
|
if player.afk_time > afk*3600 then game.kick_player(player,'AFK For Too Long ('..math.floor(afk)..' Minutes)') end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end):on_event('error',function(self,err)
|
||||||
|
if Sync then
|
||||||
|
Sync.emit_embeded{
|
||||||
|
title='Auto Kick Error',
|
||||||
|
color=Color.to_hex(defines.text_color.bg),
|
||||||
|
description='Auto Kick Error - Closed Thread',
|
||||||
|
Error=err
|
||||||
|
}
|
||||||
|
end
|
||||||
|
self:close()
|
||||||
|
end):open()
|
||||||
|
end)
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "playerInfo",
|
"name": "playerInfo",
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
"type": "Module",
|
"type": "Submodule",
|
||||||
"description": "Used to give so common info on a player as a lua table or a frame.",
|
"description": "Used to give so common info on a player as a lua table or a frame.",
|
||||||
"location": "<blank>",
|
"location": "<blank>",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@@ -11,8 +11,9 @@
|
|||||||
"Info",
|
"Info",
|
||||||
"Useful"
|
"Useful"
|
||||||
],
|
],
|
||||||
"author": "<blank>",
|
"dependencies": {
|
||||||
"contact": "<blank>",
|
"FactorioStdLib.Game": "^0.8.0",
|
||||||
"license": "<blank>",
|
"ExpGamingCore.Gui": "^4.0.0",
|
||||||
"dependencies": {}
|
"ExpGamingCore.Ranking": "?^4.0.0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "playerList",
|
"name": "playerList",
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
"type": "Module",
|
"type": "Submodule",
|
||||||
"description": "Used to display player names and online time on the top left.",
|
"description": "Used to display player names and online time on the top left.",
|
||||||
"location": "<blank>",
|
"location": "<blank>",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@@ -10,14 +10,12 @@
|
|||||||
"Gui",
|
"Gui",
|
||||||
"Names"
|
"Names"
|
||||||
],
|
],
|
||||||
"author": "<blank>",
|
|
||||||
"contact": "<blank>",
|
|
||||||
"license": "<blank>",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"FactorioStdLib.Game": "^0.8.0",
|
"FactorioStdLib.Game": "^0.8.0",
|
||||||
"ExpGamingCore.Gui": "^4.0.0",
|
"ExpGamingCore.Gui": "^4.0.0",
|
||||||
"ExpGamingCore.Ranking": "?^4.0.0",
|
"ExpGamingCore.Ranking": "?^4.0.0",
|
||||||
"ExpGamingAdmin.buttonFlow": "?^4.0.0",
|
"ExpGamingAdmin.buttonFlow": "?^4.0.0",
|
||||||
"ExpGamingAdmin.reports": "?^4.0.0"
|
"ExpGamingAdmin.reports": "?^4.0.0",
|
||||||
|
"ExpGamingPlayer.playerInfo": "?^4.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,5 +13,68 @@
|
|||||||
"author": "Cooldude2606",
|
"author": "Cooldude2606",
|
||||||
"contact": "Discord: Cooldude2606#5241",
|
"contact": "Discord: Cooldude2606#5241",
|
||||||
"license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE",
|
"license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE",
|
||||||
"submodules": {}
|
"submodules": {
|
||||||
|
"afkKick": {
|
||||||
|
"name": "afkKick",
|
||||||
|
"version": "4.0.0",
|
||||||
|
"type": "Submodule",
|
||||||
|
"description": "Adds a varible amount of time before a user is kicked based on the current player count.",
|
||||||
|
"location": "<blank>",
|
||||||
|
"keywords": [
|
||||||
|
"Kick",
|
||||||
|
"AFK",
|
||||||
|
"Players",
|
||||||
|
"Smart",
|
||||||
|
"Varible"
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"FactorioStdLib.Game": "^0.8.0",
|
||||||
|
"ExpGamingCore.Gui": "^4.0.0",
|
||||||
|
"ExpGamingCore.Ranking": "?^4.0.0",
|
||||||
|
"ExpGamingCore.Sync": "?^4.0.0",
|
||||||
|
"ExpGamingCore.Server": "?^4.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"playerInfo": {
|
||||||
|
"name": "playerInfo",
|
||||||
|
"version": "4.0.0",
|
||||||
|
"type": "Submodule",
|
||||||
|
"description": "Used to give so common info on a player as a lua table or a frame.",
|
||||||
|
"location": "<blank>",
|
||||||
|
"keywords": [
|
||||||
|
"Cam",
|
||||||
|
"Follow",
|
||||||
|
"Player",
|
||||||
|
"Info",
|
||||||
|
"Useful"
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"FactorioStdLib.Game": "^0.8.0",
|
||||||
|
"ExpGamingCore.Gui": "^4.0.0",
|
||||||
|
"ExpGamingCore.Ranking": "?^4.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"playerList": {
|
||||||
|
"name": "playerList",
|
||||||
|
"version": "4.0.0",
|
||||||
|
"type": "Submodule",
|
||||||
|
"description": "Used to display player names and online time on the top left.",
|
||||||
|
"location": "<blank>",
|
||||||
|
"keywords": [
|
||||||
|
"Player List",
|
||||||
|
"List",
|
||||||
|
"Gui",
|
||||||
|
"Names"
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"FactorioStdLib.Game": "^0.8.0",
|
||||||
|
"ExpGamingCore.Gui": "^4.0.0",
|
||||||
|
"ExpGamingCore.Ranking": "?^4.0.0",
|
||||||
|
"ExpGamingAdmin.buttonFlow": "?^4.0.0",
|
||||||
|
"ExpGamingAdmin.reports": "?^4.0.0",
|
||||||
|
"ExpGamingPlayer.playerInfo": "?^4.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"dependencies": {}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user