added chat command for ping and hideid

/ping , /ping 113 , /hideid /showid
This commit is contained in:
Ayush Saini 2022-11-20 23:10:06 +05:30
parent 23c0fa7a9b
commit 7f11eca20b
6 changed files with 487 additions and 450 deletions

View file

@ -34,6 +34,8 @@ Here you can ban player , mute them , disable their kick votes
- Rank System. - Rank System.
- Chat commands. - Chat commands.
- V2 Account with cloud console for server. - V2 Account with cloud console for server.
- check clients ping , use /ping chat command to check ping of any player._ba.get_client_ping().
- Hide player specs from cleints, chatcommand /hideid /showid .
- Easy role management , create 1000 of roles as you wish add specific chat command to the role , give tag to role ..many more. - Easy role management , create 1000 of roles as you wish add specific chat command to the role , give tag to role ..many more.
- Rejoin cooldown. - Rejoin cooldown.
- Leaderboard , top 3 rank players name on top right corner. - Leaderboard , top 3 rank players name on top right corner.

View file

@ -6,424 +6,434 @@ import ba, _ba, time, setting
import ba.internal import ba.internal
import _thread import _thread
from tools import playlist from tools import playlist
Commands = ['lm', 'gp', 'party', 'quit', 'kickvote','maxplayers','playlist','ban','kick', 'remove', 'end', 'quit', 'mute', 'unmute', 'slowmo', 'nv', 'dv', 'pause', 'cameramode', 'createrole', 'addrole', 'removerole', 'addcommand', 'addcmd', 'removecommand','getroles', 'removecmd', 'changetag','customtag','customeffect','add', 'spectators', 'lobbytime'] Commands = ['showid','hideid','lm', 'gp', 'party', 'quit', 'kickvote','maxplayers','playlist','ban','kick', 'remove', 'end', 'quit', 'mute', 'unmute', 'slowmo', 'nv', 'dv', 'pause', 'cameramode', 'createrole', 'addrole', 'removerole', 'addcommand', 'addcmd', 'removecommand','getroles', 'removecmd', 'changetag','customtag','customeffect','add', 'spectators', 'lobbytime']
CommandAliases = ['max','rm', 'next', 'restart', 'mutechat', 'unmutechat', 'sm', 'slow', 'night', 'day', 'pausegame', 'camera_mode', 'rotate_camera','effect'] CommandAliases = ['max','rm', 'next', 'restart', 'mutechat', 'unmutechat', 'sm', 'slow', 'night', 'day', 'pausegame', 'camera_mode', 'rotate_camera','effect']
def ExcelCommand(command, arguments, clientid, accountid): def ExcelCommand(command, arguments, clientid, accountid):
""" """
Checks The Command And Run Function Checks The Command And Run Function
Parameters: Parameters:
command : str command : str
arguments : str arguments : str
clientid : int clientid : int
accountid : int accountid : int
Returns: Returns:
None None
""" """
if command in ['maxplayers','max']: if command in ['maxplayers','max']:
changepartysize(arguments) changepartysize(arguments)
elif command =='playlist': elif command =='playlist':
changeplaylist(arguments) changeplaylist(arguments)
elif command == 'kick': elif command == 'kick':
kick(arguments) kick(arguments)
elif command == 'ban': elif command == 'ban':
ban(arguments) ban(arguments)
elif command in ['end', 'next']: elif command in ['end', 'next']:
end(arguments) end(arguments)
elif command == 'kickvote': elif command == 'kickvote':
kikvote(arguments, clientid) kikvote(arguments, clientid)
elif command == 'hideid':
hide_player_spec()
elif command == "showid":
show_player_spec()
elif command == 'lm':
last_msgs(clientid)
elif command == 'lm': elif command == 'gp':
last_msgs(clientid) get_profiles(arguments, clientid)
elif command == 'gp': elif command == 'party':
get_profiles(arguments, clientid) party_toggle(arguments)
elif command == 'party': elif command in ['quit', 'restart']:
party_toggle(arguments) quit(arguments)
elif command in ['quit', 'restart']: elif command in ['mute', 'mutechat']:
quit(arguments) mute(arguments)
elif command in ['mute', 'mutechat']: elif command in ['unmute', 'unmutechat']:
mute(arguments) un_mute(arguments)
elif command in ['unmute', 'unmutechat']: elif command in ['remove', 'rm']:
un_mute(arguments) remove(arguments)
elif command in ['remove', 'rm']: elif command in ['sm', 'slow', 'slowmo']:
remove(arguments) slow_motion()
elif command in ['sm', 'slow', 'slowmo']: elif command in ['nv', 'night']:
slow_motion() nv(arguments)
elif command in ['nv', 'night']: elif command in ['dv', 'day']:
nv(arguments) dv(arguments)
elif command in ['dv', 'day']: elif command in ['pause', 'pausegame']:
dv(arguments) pause()
elif command in ['pause', 'pausegame']: elif command in ['cameraMode', 'camera_mode', 'rotate_camera']:
pause() rotate_camera()
elif command in ['cameraMode', 'camera_mode', 'rotate_camera']: elif command == 'createrole':
rotate_camera() create_role(arguments)
elif command == 'createrole': elif command == 'addrole':
create_role(arguments) add_role_to_player(arguments)
elif command == 'addrole': elif command == 'removerole':
add_role_to_player(arguments) remove_role_from_player(arguments)
elif command == 'removerole': elif command=='getroles':
remove_role_from_player(arguments) get_roles_of_player(arguments,clientid)
elif command=='getroles': elif command in ['addcommand', 'addcmd']:
get_roles_of_player(arguments,clientid) add_command_to_role(arguments)
elif command in ['addcommand', 'addcmd']: elif command in ['removecommand', 'removecmd']:
add_command_to_role(arguments) remove_command_to_role(arguments)
elif command in ['removecommand', 'removecmd']: elif command == 'changetag':
remove_command_to_role(arguments) change_role_tag(arguments)
elif command == 'changetag': elif command=='customtag':
change_role_tag(arguments) set_custom_tag(arguments)
elif command=='customtag': elif command in ['customeffect','effect']:
set_custom_tag(arguments) set_custom_effect(arguments)
elif command in ['customeffect','effect']: # elif command in ['add', 'whitelist']:
set_custom_effect(arguments) # whitelst_it(accountid, arguments)
# elif command in ['add', 'whitelist']: elif command == 'spectators':
# whitelst_it(accountid, arguments) spectators(arguments)
elif command == 'spectators': elif command == 'lobbytime':
spectators(arguments) change_lobby_check_time(arguments)
elif command == 'lobbytime':
change_lobby_check_time(arguments) def hide_player_spec():
_ba.hide_player_device_id(True)
def show_player_spec():
_ba.hide_player_device_id(False)
def changepartysize(arguments): def changepartysize(arguments):
if len(arguments)==0: if len(arguments)==0:
ba.internal.chatmessage("enter number") ba.internal.chatmessage("enter number")
else: else:
ba.internal.set_public_party_max_size(int(arguments[0])) ba.internal.set_public_party_max_size(int(arguments[0]))
def changeplaylist(arguments): def changeplaylist(arguments):
if len(arguments)==0: if len(arguments)==0:
ba.internal.chatmessage("enter list code or name") ba.internal.chatmessage("enter list code or name")
else: else:
if arguments[0]=='coop': if arguments[0]=='coop':
serverdata.coopmode=True serverdata.coopmode=True
else: else:
serverdata.coopmode=False serverdata.coopmode=False
playlist.setPlaylist(arguments[0]) playlist.setPlaylist(arguments[0])
return return
def kick(arguments): def kick(arguments):
ba.internal.disconnect_client(int(arguments[0])) ba.internal.disconnect_client(int(arguments[0]))
return return
def kikvote(arguments, clientid): def kikvote(arguments, clientid):
if arguments == [] or arguments == [''] or len(arguments) < 2: if arguments == [] or arguments == [''] or len(arguments) < 2:
return return
elif arguments[0] == 'enable': elif arguments[0] == 'enable':
if arguments[1] == 'all': if arguments[1] == 'all':
_ba.set_enable_default_kick_voting(True) _ba.set_enable_default_kick_voting(True)
else: else:
try: try:
cl_id=int(arguments[1]) cl_id=int(arguments[1])
for ros in ba.internal.get_game_roster(): for ros in ba.internal.get_game_roster():
if ros["client_id"]==cl_id: if ros["client_id"]==cl_id:
if ros["account_id"] in serverdata.clients: if ros["account_id"] in serverdata.clients:
serverdata.clients[ros["account_id"]]["canStartKickVote"]=True serverdata.clients[ros["account_id"]]["canStartKickVote"]=True
send("Upon server restart, Kick-vote will be enabled for this person", clientid) send("Upon server restart, Kick-vote will be enabled for this person", clientid)
return return
except: except:
return return
elif arguments[0] == 'disable': elif arguments[0] == 'disable':
if arguments[1] == 'all': if arguments[1] == 'all':
_ba.set_enable_default_kick_voting(False) _ba.set_enable_default_kick_voting(False)
else: else:
try: try:
cl_id=int(arguments[1]) cl_id=int(arguments[1])
for ros in ba.internal.get_game_roster(): for ros in ba.internal.get_game_roster():
if ros["client_id"]==cl_id: if ros["client_id"]==cl_id:
_ba.disable_kickvote(ros["account_id"]) _ba.disable_kickvote(ros["account_id"])
send("Kick-vote disabled for this person", clientid) send("Kick-vote disabled for this person", clientid)
if ros["account_id"] in serverdata.clients: if ros["account_id"] in serverdata.clients:
serverdata.clients[ros["account_id"]]["canStartKickVote"]=False serverdata.clients[ros["account_id"]]["canStartKickVote"]=False
return return
except: except:
return return
else: else:
return return
def last_msgs(clientid): def last_msgs(clientid):
for i in ba.internal.get_chat_messages(): for i in ba.internal.get_chat_messages():
send(i,clientid) send(i,clientid)
def get_profiles(arguments,clientid): def get_profiles(arguments,clientid):
try: try:
playerID = int(arguments[0]) playerID = int(arguments[0])
num = 1 num = 1
for i in ba.internal.get_foreground_host_session().sessionplayers[playerID].inputdevice.get_player_profiles(): for i in ba.internal.get_foreground_host_session().sessionplayers[playerID].inputdevice.get_player_profiles():
try: try:
send(f"{num})- {i}",clientid) send(f"{num})- {i}",clientid)
num += 1 num += 1
except: except:
pass pass
except: except:
pass pass
def party_toggle(arguments): def party_toggle(arguments):
if arguments == ['public']: if arguments == ['public']:
ba.internal.set_public_party_enabled(True) ba.internal.set_public_party_enabled(True)
ba.internal.chatmessage("party is public now") ba.internal.chatmessage("party is public now")
elif arguments == ['private']: elif arguments == ['private']:
ba.internal.set_public_party_enabled(False) ba.internal.set_public_party_enabled(False)
ba.internal.chatmessage("party is private now") ba.internal.chatmessage("party is private now")
else: else:
pass pass
def end(arguments): def end(arguments):
if arguments == [] or arguments == ['']: if arguments == [] or arguments == ['']:
try: try:
with _ba.Context(_ba.get_foreground_host_activity()): with _ba.Context(_ba.get_foreground_host_activity()):
_ba.get_foreground_host_activity().end_game() _ba.get_foreground_host_activity().end_game()
except: except:
pass pass
def ban(arguments): def ban(arguments):
try: try:
cl_id=int(arguments[0]) cl_id=int(arguments[0])
ac_id="" ac_id=""
for ros in ba.internal.get_game_roster(): for ros in ba.internal.get_game_roster():
if ros["client_id"]==cl_id: if ros["client_id"]==cl_id:
_thread.start_new_thread(pdata.ban_player,(ros['account_id'],)) _thread.start_new_thread(pdata.ban_player,(ros['account_id'],))
ac_id=ros['account_id'] ac_id=ros['account_id']
if ac_id in serverdata.clients: if ac_id in serverdata.clients:
serverdata.clients[ac_id]["isBan"]=True serverdata.clients[ac_id]["isBan"]=True
kick(arguments) kick(arguments)
except: except:
pass pass
def quit(arguments): def quit(arguments):
if arguments == [] or arguments == ['']: if arguments == [] or arguments == ['']:
ba.quit() ba.quit()
def mute(arguments): def mute(arguments):
if len(arguments)==0: if len(arguments)==0:
serverdata.muted=True serverdata.muted=True
try: try:
cl_id=int(arguments[0]) cl_id=int(arguments[0])
ac_id="" ac_id=""
for ros in ba.internal.get_game_roster(): for ros in ba.internal.get_game_roster():
if ros["client_id"]==cl_id: if ros["client_id"]==cl_id:
_thread.start_new_thread(pdata.mute,(ros['account_id'],)) _thread.start_new_thread(pdata.mute,(ros['account_id'],))
ac_id=ros['account_id'] ac_id=ros['account_id']
if ac_id in serverdata.clients: if ac_id in serverdata.clients:
serverdata.clients[ac_id]["isMuted"]=True serverdata.clients[ac_id]["isMuted"]=True
except: except:
pass pass
return return
def un_mute(arguments): def un_mute(arguments):
if len(arguments)==0: if len(arguments)==0:
serverdata.muted=False serverdata.muted=False
try: try:
cl_id=int(arguments[0]) cl_id=int(arguments[0])
ac_id="" ac_id=""
for ros in ba.internal.get_game_roster(): for ros in ba.internal.get_game_roster():
if ros["client_id"]==cl_id: if ros["client_id"]==cl_id:
pdata.unmute(ros['account_id']) pdata.unmute(ros['account_id'])
ac_id=ros['account_id'] ac_id=ros['account_id']
if ac_id in serverdata.clients: if ac_id in serverdata.clients:
serverdata.clients[ac_id]["isMuted"]=False serverdata.clients[ac_id]["isMuted"]=False
return return
except: except:
pass pass
def remove(arguments): def remove(arguments):
if arguments == [] or arguments == ['']: if arguments == [] or arguments == ['']:
return return
elif arguments[0] == 'all': elif arguments[0] == 'all':
session = ba.internal.get_foreground_host_session() session = ba.internal.get_foreground_host_session()
for i in session.sessionplayers: for i in session.sessionplayers:
i.remove_from_game() i.remove_from_game()
else: else:
try: try:
session = ba.internal.get_foreground_host_session() session = ba.internal.get_foreground_host_session()
for i in session.sessionplayers: for i in session.sessionplayers:
if i.inputdevice.client_id== int(arguments[0]): if i.inputdevice.client_id== int(arguments[0]):
i.remove_from_game() i.remove_from_game()
except: except:
return return
def slow_motion(): def slow_motion():
activity = _ba.get_foreground_host_activity() activity = _ba.get_foreground_host_activity()
if activity.globalsnode.slow_motion != True: if activity.globalsnode.slow_motion != True:
activity.globalsnode.slow_motion = True activity.globalsnode.slow_motion = True
else: else:
activity.globalsnode.slow_motion = False activity.globalsnode.slow_motion = False
def nv(arguments): def nv(arguments):
activity = _ba.get_foreground_host_activity() activity = _ba.get_foreground_host_activity()
if arguments == [] or arguments == ['']: if arguments == [] or arguments == ['']:
if activity.globalsnode.tint != (0.5, 0.7, 1.0): if activity.globalsnode.tint != (0.5, 0.7, 1.0):
activity.globalsnode.tint = (0.5, 0.7, 1.0) activity.globalsnode.tint = (0.5, 0.7, 1.0)
else: else:
#will fix this soon #will fix this soon
pass pass
elif arguments[0] == 'off': elif arguments[0] == 'off':
if activity.globalsnode.tint != (0.5, 0.7, 1.0): if activity.globalsnode.tint != (0.5, 0.7, 1.0):
return return
else: else:
pass pass
def dv(arguments): def dv(arguments):
activity = _ba.get_foreground_host_activity() activity = _ba.get_foreground_host_activity()
if arguments == [] or arguments == ['']: if arguments == [] or arguments == ['']:
if activity.globalsnode.tint != (1,1,1): if activity.globalsnode.tint != (1,1,1):
activity.globalsnode.tint = (1,1,1) activity.globalsnode.tint = (1,1,1)
else: else:
#will fix this soon #will fix this soon
pass pass
elif arguments[0] == 'off': elif arguments[0] == 'off':
if activity.globalsnode.tint != (1,1,1): if activity.globalsnode.tint != (1,1,1):
return return
else: else:
pass pass
def pause(): def pause():
activity = _ba.get_foreground_host_activity() activity = _ba.get_foreground_host_activity()
if activity.globalsnode.paused != True: if activity.globalsnode.paused != True:
activity.globalsnode.paused = True activity.globalsnode.paused = True
else: else:
activity.globalsnode.paused = False activity.globalsnode.paused = False
def rotate_camera(): def rotate_camera():
activity = _ba.get_foreground_host_activity() activity = _ba.get_foreground_host_activity()
if activity.globalsnode.camera_mode != 'rotate': if activity.globalsnode.camera_mode != 'rotate':
activity.globalsnode.camera_mode = 'rotate' activity.globalsnode.camera_mode = 'rotate'
else: else:
activity.globalsnode.camera_mode == 'normal' activity.globalsnode.camera_mode == 'normal'
def create_role(arguments): def create_role(arguments):
try: try:
pdata.create_role(arguments[0]) pdata.create_role(arguments[0])
except: except:
return return
def add_role_to_player(arguments): def add_role_to_player(arguments):
try: try:
session = ba.internal.get_foreground_host_session() session = ba.internal.get_foreground_host_session()
for i in session.sessionplayers: for i in session.sessionplayers:
if i.inputdevice.client_id== int(arguments[1]): if i.inputdevice.client_id== int(arguments[1]):
roles=pdata.add_player_role(arguments[0],i.get_v1_account_id()) roles=pdata.add_player_role(arguments[0],i.get_v1_account_id())
except: except:
return return
def remove_role_from_player(arguments): def remove_role_from_player(arguments):
try: try:
session = ba.internal.get_foreground_host_session() session = ba.internal.get_foreground_host_session()
for i in session.sessionplayers: for i in session.sessionplayers:
if i.inputdevice.client_id== int(arguments[1]): if i.inputdevice.client_id== int(arguments[1]):
roles=pdata.remove_player_role(arguments[0],i.get_v1_account_id()) roles=pdata.remove_player_role(arguments[0],i.get_v1_account_id())
except: except:
return return
def get_roles_of_player(arguments,clientid): def get_roles_of_player(arguments,clientid):
try: try:
session = ba.internal.get_foreground_host_session() session = ba.internal.get_foreground_host_session()
roles=[] roles=[]
reply="" reply=""
for i in session.sessionplayers: for i in session.sessionplayers:
if i.inputdevice.client_id== int(arguments[0]): if i.inputdevice.client_id== int(arguments[0]):
roles=pdata.get_player_roles(i.get_v1_account_id()) roles=pdata.get_player_roles(i.get_v1_account_id())
print(roles) print(roles)
for role in roles: for role in roles:
reply=reply+role+"," reply=reply+role+","
send(reply,clientid) send(reply,clientid)
except: except:
return return
def change_role_tag(arguments): def change_role_tag(arguments):
try: try:
pdata.change_role_tag(arguments[0], arguments[1]) pdata.change_role_tag(arguments[0], arguments[1])
except: except:
return return
def set_custom_tag(arguments): def set_custom_tag(arguments):
try: try:
session = ba.internal.get_foreground_host_session() session = ba.internal.get_foreground_host_session()
for i in session.sessionplayers: for i in session.sessionplayers:
if i.inputdevice.client_id== int(arguments[1]): if i.inputdevice.client_id== int(arguments[1]):
roles=pdata.set_tag(arguments[0],i.get_v1_account_id()) roles=pdata.set_tag(arguments[0],i.get_v1_account_id())
except: except:
return return
def set_custom_effect(arguments): def set_custom_effect(arguments):
try: try:
session = ba.internal.get_foreground_host_session() session = ba.internal.get_foreground_host_session()
for i in session.sessionplayers: for i in session.sessionplayers:
if i.inputdevice.client_id== int(arguments[1]): if i.inputdevice.client_id== int(arguments[1]):
roles=pdata.set_effect(arguments[0],i.get_v1_account_id()) roles=pdata.set_effect(arguments[0],i.get_v1_account_id())
except: except:
return return
@ -432,69 +442,69 @@ all_commands = ["changetag","createrole", "addrole", "removerole", "addcommand",
def add_command_to_role(arguments): def add_command_to_role(arguments):
try: try:
if arguments[1] in all_commands: if arguments[1] in all_commands:
pdata.add_command_role(arguments[0], arguments[1]) pdata.add_command_role(arguments[0], arguments[1])
except: except:
return return
def remove_command_to_role(arguments): def remove_command_to_role(arguments):
try: try:
if arguments[1] in all_commands: if arguments[1] in all_commands:
pdata.remove_command_role(arguments[0], arguments[1]) pdata.remove_command_role(arguments[0], arguments[1])
except: except:
return return
# def whitelst_it(accountid : str, arguments): # def whitelst_it(accountid : str, arguments):
# settings = setting.get_settings_data() # settings = setting.get_settings_data()
# if arguments[0] == 'on': # if arguments[0] == 'on':
# if settings["white_list"]["whitelist_on"]: # if settings["white_list"]["whitelist_on"]:
# ba.internal.chatmessage("Already on") # ba.internal.chatmessage("Already on")
# else: # else:
# settings["white_list"]["whitelist_on"] = True # settings["white_list"]["whitelist_on"] = True
# setting.commit(settings) # setting.commit(settings)
# ba.internal.chatmessage("whitelist on") # ba.internal.chatmessage("whitelist on")
# from tools import whitelist # from tools import whitelist
# whitelist.Whitelist() # whitelist.Whitelist()
# return # return
# elif arguments[0] == 'off': # elif arguments[0] == 'off':
# settings["white_list"]["whitelist_on"] = False # settings["white_list"]["whitelist_on"] = False
# setting.commit(settings) # setting.commit(settings)
# ba.internal.chatmessage("whitelist off") # ba.internal.chatmessage("whitelist off")
# return # return
# else: # else:
# rost = ba.internal.get_game_roster() # rost = ba.internal.get_game_roster()
# for i in rost: # for i in rost:
# if i['client_id'] == int(arguments[0]): # if i['client_id'] == int(arguments[0]):
# add_to_white_list(i['account_id'], i['display_string']) # add_to_white_list(i['account_id'], i['display_string'])
# ba.internal.chatmessage(str(i['display_string'])+" whitelisted") # ba.internal.chatmessage(str(i['display_string'])+" whitelisted")
# add_commit_to_logs(accountid+" added "+i['account_id']) # add_commit_to_logs(accountid+" added "+i['account_id'])
def spectators(arguments): def spectators(arguments):
if arguments[0] in ['on', 'off']: if arguments[0] in ['on', 'off']:
settings = setting.get_settings_data() settings = setting.get_settings_data()
if arguments[0] == 'on': if arguments[0] == 'on':
settings["white_list"]["spectators"] = True settings["white_list"]["spectators"] = True
setting.commit(settings) setting.commit(settings)
ba.internal.chatmessage("spectators on") ba.internal.chatmessage("spectators on")
elif arguments[0] == 'off': elif arguments[0] == 'off':
settings["white_list"]["spectators"] = False settings["white_list"]["spectators"] = False
setting.commit(settings) setting.commit(settings)
ba.internal.chatmessage("spectators off") ba.internal.chatmessage("spectators off")

View file

@ -4,87 +4,106 @@ import ba.internal
from stats import mystats from stats import mystats
from ba._general import Call from ba._general import Call
import _thread import _thread
Commands = ['me', 'list', 'uniqeid'] Commands = ['me', 'list', 'uniqeid','ping']
CommandAliases = ['stats', 'score', 'rank', 'myself', 'l', 'id', 'pb-id', 'pb', 'accountid'] CommandAliases = ['stats', 'score', 'rank', 'myself', 'l', 'id', 'pb-id', 'pb', 'accountid']
def ExcelCommand(command, arguments, clientid, accountid): def ExcelCommand(command, arguments, clientid, accountid):
""" """
Checks The Command And Run Function Checks The Command And Run Function
Parameters: Parameters:
command : str command : str
arguments : str arguments : str
clientid : int clientid : int
accountid : int accountid : int
Returns: Returns:
None None
""" """
if command in ['me', 'stats', 'score', 'rank', 'myself']: if command in ['me', 'stats', 'score', 'rank', 'myself']:
fetch_send_stats(accountid,clientid) fetch_send_stats(accountid,clientid)
elif command in ['list', 'l']: elif command in ['list', 'l']:
list(clientid) list(clientid)
elif command in ['uniqeid', 'id', 'pb-id', 'pb' , 'accountid']: elif command in ['uniqeid', 'id', 'pb-id', 'pb' , 'accountid']:
accountid_request(arguments, clientid, accountid) accountid_request(arguments, clientid, accountid)
elif command in ['ping']:
get_ping(arguments, clientid)
def get_ping(arguments, clientid):
if arguments == [] or arguments == ['']:
send(f"Your ping {_ba.get_client_ping(clientid)}ms ", clientid)
else:
try:
session = ba.internal.get_foreground_host_session()
for index, player in enumerate(session.sessionplayers):
name = player.getname(full=True,icon = False),
if player.inputdevice.client_id == int(arguments[0]):
ping = _ba.get_client_ping(int(arguments[0]))
send(f" {name}'s ping {ping}ms", clientid)
except:
return
def stats(ac_id,clientid): def stats(ac_id,clientid):
stats=mystats.get_stats_by_id(ac_id) stats=mystats.get_stats_by_id(ac_id)
if stats: if stats:
reply="Score:"+str(stats["scores"])+"\nGames:"+str(stats["games"])+"\nKills:"+str(stats["kills"])+"\nDeaths:"+str(stats["deaths"])+"\nAvg.:"+str(stats["avg_score"]) reply="Score:"+str(stats["scores"])+"\nGames:"+str(stats["games"])+"\nKills:"+str(stats["kills"])+"\nDeaths:"+str(stats["deaths"])+"\nAvg.:"+str(stats["avg_score"])
else: else:
reply="Not played any match yet." reply="Not played any match yet."
_ba.pushcall(Call(send,reply,clientid),from_other_thread=True) _ba.pushcall(Call(send,reply,clientid),from_other_thread=True)
def fetch_send_stats(ac_id,clientid): def fetch_send_stats(ac_id,clientid):
_thread.start_new_thread(stats,(ac_id,clientid,)) _thread.start_new_thread(stats,(ac_id,clientid,))
def list(clientid): def list(clientid):
"""Returns The List Of Players Clientid and index""" """Returns The List Of Players Clientid and index"""
p = u'{0:^16}{1:^15}{2:^10}' p = u'{0:^16}{1:^15}{2:^10}'
seprator = '\n______________________________\n' seprator = '\n______________________________\n'
list = p.format('Name', 'Client ID' , 'Player ID')+seprator list = p.format('Name', 'Client ID' , 'Player ID')+seprator
session = ba.internal.get_foreground_host_session() session = ba.internal.get_foreground_host_session()
for index, player in enumerate(session.sessionplayers): for index, player in enumerate(session.sessionplayers):
list += p.format(player.getname(icon = False), list += p.format(player.getname(icon = False),
player.inputdevice.client_id, index)+"\n" player.inputdevice.client_id, index)+"\n"
send(list, clientid) send(list, clientid)
def accountid_request(arguments, clientid, accountid): def accountid_request(arguments, clientid, accountid):
"""Returns The Account Id Of Players""" """Returns The Account Id Of Players"""
if arguments == [] or arguments == ['']: if arguments == [] or arguments == ['']:
send(f"Your account id is {accountid} ", clientid) send(f"Your account id is {accountid} ", clientid)
else: else:
try: try:
session = ba.internal.get_foreground_host_session() session = ba.internal.get_foreground_host_session()
player = session.sessionplayers[int(arguments[0])] player = session.sessionplayers[int(arguments[0])]
name = player.getname(full=True, icon=True) name = player.getname(full=True, icon=True)
accountid = player.get_v1_account_id() accountid = player.get_v1_account_id()
send(f" {name}'s account id is '{accountid}' ", clientid)
except:
return
send(f" {name}'s account id is '{accountid}' ", clientid)
except:
return

View file

@ -89,6 +89,7 @@ def bootstraping():
_ba.set_server_name(settings["HostName"]) _ba.set_server_name(settings["HostName"])
_ba.set_transparent_kickvote(settings["ShowKickVoteStarterName"]) _ba.set_transparent_kickvote(settings["ShowKickVoteStarterName"])
_ba.set_kickvote_msg_type(settings["KickVoteMsgType"]) _ba.set_kickvote_msg_type(settings["KickVoteMsgType"])
_ba.hide_player_device_id(settings["Anti-IdRevealer"])
# check for auto update stats # check for auto update stats
_thread.start_new_thread(mystats.refreshStats, ()) _thread.start_new_thread(mystats.refreshStats, ())
@ -122,6 +123,8 @@ def bootstraping():
if settings["whitelist"]: if settings["whitelist"]:
pdata.load_white_list() pdata.load_white_list()
#
import_discord_bot() import_discord_bot()
import_games() import_games()
import_dual_team_score() import_dual_team_score()

View file

@ -5,7 +5,7 @@ import ba.internal
import time import time
last_end_vote_start_time = 0 last_end_vote_start_time = 0
end_vote_duration = 30 end_vote_duration = 50
game_started_on = 0 game_started_on = 0
min_game_duration_to_start_end_vote = 30 min_game_duration_to_start_end_vote = 30
@ -66,6 +66,8 @@ def required_votes(players):
return 4 return 4
elif players == 8: elif players == 8:
return 4 return 4
elif players == 10:
return 5
else: else:
return players - 4 return players - 4
@ -90,7 +92,7 @@ def update_vote_text(votes_needed):
votes_needed) votes_needed)
})).autoretain() })).autoretain()
activity.end_vote_text = node activity.end_vote_text = node
ba.timer(10, remove_vote_text) ba.timer(20, remove_vote_text)
def remove_vote_text(): def remove_vote_text():

View file

@ -1,6 +1,7 @@
{ {
"whitelist": false, "whitelist": false,
"useV2Account": false, "useV2Account": false,
"Anti-IdRevealer": false,
"ChatCommands": { "ChatCommands": {
"BrodcastCommand": true "BrodcastCommand": true
}, },