mirror of
https://github.com/imayushsaini/Bombsquad-Ballistica-Modded-Server.git
synced 2025-10-20 00:00:39 +00:00
added idle player remover
This commit is contained in:
parent
a2bf7e4912
commit
d06bee0be0
4 changed files with 56 additions and 0 deletions
3
dist/ba_root/mods/custom_hooks.py
vendored
3
dist/ba_root/mods/custom_hooks.py
vendored
|
|
@ -21,6 +21,7 @@ from bastd.activity.coopscore import CoopScoreScreen
|
|||
from ba import _hooks
|
||||
from tools import Logger
|
||||
from playersData import pdata
|
||||
from tools import afk_check
|
||||
# from bastd.activity.multiteamvictory import
|
||||
# from tools import fireflies
|
||||
settings = setting.get_settings_data()
|
||||
|
|
@ -34,6 +35,8 @@ def on_app_launch():
|
|||
bootstraping()
|
||||
servercheck.checkserver().start()
|
||||
ServerUpdate.check()
|
||||
if settings["afk_remover"]['enable']:
|
||||
afk_check.checkIdle().start()
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
6
dist/ba_root/mods/setting.json
vendored
6
dist/ba_root/mods/setting.json
vendored
|
|
@ -70,6 +70,12 @@
|
|||
"liveStatsChannelID":925440043672285205,
|
||||
"logsChannelID":925440079843958834
|
||||
},
|
||||
"afk_remover":{
|
||||
"enable":true,
|
||||
"ingame_idle_time_in_secs":60,
|
||||
"kick_idle_from_lobby":true,
|
||||
"lobby_idle_time_in_secs":10
|
||||
},
|
||||
"sameCharacterForTeam":false,
|
||||
"newResultBoard":true,
|
||||
"HostDeviceName":"v1.3.2",
|
||||
|
|
|
|||
47
dist/ba_root/mods/tools/afk_check.py
vendored
Normal file
47
dist/ba_root/mods/tools/afk_check.py
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
# Custom kick idle player script by mr.smoothy#5824
|
||||
import time
|
||||
import ba
|
||||
from ba._general import Call
|
||||
import _ba
|
||||
import setting
|
||||
settings = setting.get_settings_data()
|
||||
INGAME_TIME=settings["afk_remover"]["ingame_idle_time_in_secs"]
|
||||
LOBBY_KICK=settings['afk_remover']["kick_idle_from_lobby"]
|
||||
INLOBBY_TIME=settings['afk_remover']["lobby_idle_time_in_secs"]
|
||||
class checkIdle(object):
|
||||
def start(self):
|
||||
self.t1=ba.timer(2, ba.Call(self.check),repeat=True)
|
||||
self.lobbies={}
|
||||
def check(self):
|
||||
current=ba.time(ba.TimeType.REAL,timeformat=ba.TimeFormat.MILLISECONDS)
|
||||
for player in _ba.get_foreground_host_session().sessionplayers:
|
||||
last_input=int(player.inputdevice.get_last_input_time())
|
||||
afk_time=int((current-last_input)/1000)
|
||||
if afk_time in range(INGAME_TIME,INGAME_TIME+20):
|
||||
self.warn_player(player.get_account_id(),"Press any button within "+str(INGAME_TIME+20-afk_time)+" secs")
|
||||
if afk_time > INGAME_TIME+20:
|
||||
player.remove_from_game()
|
||||
if LOBBY_KICK:
|
||||
current_players=[]
|
||||
for player in _ba.get_game_roster():
|
||||
if player['client_id'] !=-1 and len(player['players']) ==0:
|
||||
current_players.append(player['client_id'])
|
||||
if player['client_id'] not in self.lobbies:
|
||||
self.lobbies[player['client_id']]=current
|
||||
lobby_afk=int((current - self.lobbies[player['client_id']])/1000)
|
||||
if lobby_afk in range(INLOBBY_TIME,INLOBBY_TIME+10):
|
||||
_ba.screenmessage("Join game within "+str(INLOBBY_TIME+10-lobby_afk)+" secs",color=(1,0,0),transient=True,clients=[player['client_id']])
|
||||
if lobby_afk > INLOBBY_TIME+ 10:
|
||||
_ba.disconnect_client(player['client_id'],0)
|
||||
# clean the lobbies dict
|
||||
temp=self.lobbies.copy()
|
||||
for clid in temp:
|
||||
if clid not in current_players:
|
||||
del self.lobbies[clid]
|
||||
def warn_player(self,pbid,msg):
|
||||
for player in _ba.get_game_roster():
|
||||
if player["account_id"]==pbid:
|
||||
_ba.screenmessage(msg,color=(1,0,0),transient=True,clients=[player['client_id']])
|
||||
|
||||
|
||||
|
||||
BIN
dist/bombsquad_headless
vendored
BIN
dist/bombsquad_headless
vendored
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue