Initial commit

This commit is contained in:
vortex 2024-02-26 00:17:10 +05:30
parent bc49523c99
commit 44d606cce7
1929 changed files with 612166 additions and 0 deletions

View file

@ -0,0 +1,457 @@
from .Handlers import handlemsg, handlemsg_all, clientid_to_myself,send
from bastd.actor.zoomtext import ZoomText
import ba, _ba
import json
import os
Commands = ['kill', 'fall', 'heal', 'zoommessage', 'curse', 'sleep', 'superpunch', 'gloves', 'shield', 'freeze', 'unfreeze', 'godmode', 'speedon','admincmdlist']
CommandAliases = ['die', 'fell-down', 'zm', 'heath', 'cur', 'sp', 'punch', 'protect', 'ice', 'thaw', 'gm', 'speedy', 'acl']
def ExcelCommand(command, arguments, clientid, accountid):
"""
Checks The Command And Run Function
Parameters:
command : str
arguments : str
clientid : int
accountid : int
Returns:
None
"""
if command in ['kill', 'die']:
kill(arguments, clientid)
elif command in ['fall', 'fell-down']:
fall(arguments, clientid)
elif command in ['heal', 'heath']:
heal(arguments, clientid)
elif command in ['curse', 'cur']:
curse(arguments, clientid)
elif command == 'sleep':
sleep(arguments, clientid)
elif command in ['sp', 'superpunch']:
super_punch(arguments, clientid)
elif command in ['gloves', 'punch']:
gloves(arguments, clientid)
elif command in ['shield', 'protect']:
shield(arguments, clientid)
elif command in ['freeze', 'ice']:
freeze(arguments, clientid)
elif command in ['zm', 'zoommessage']:
zm(arguments, clientid)
elif command in ['unfreeze', 'thaw']:
un_freeze(arguments, clientid)
elif command in ['gm', 'godmode']:
god_mode(arguments, clientid)
elif command in ['speedon', 'speedy']:
speedy(arguments, clientid)
elif command in ['acl']:
acl(arguments, clientid)
def kill(arguments, clientid):
if arguments == [] or arguments == ['']:
myself = clientid_to_myself(clientid)
handlemsg(myself, ba.DieMessage())
elif arguments[0] == 'all':
handlemsg_all(ba.DieMessage())
else:
try:
req_player = int(arguments[0])
handlemsg(req_player, ba.DieMessage())
except:
return
def fall(arguments, clientid):
if arguments == [] or arguments == ['']:
myself = clientid_to_myself(clientid)
handlemsg(myself, ba.StandMessage())
elif arguments[0] == 'all':
handlemsg_all(ba.StandMessage())
else:
try:
req_player = int(arguments[0])
handlemsg(req_player, ba.StandMessage())
except:
return
def heal(arguments, clientid):
if arguments == [] or arguments == ['']:
myself = clientid_to_myself(clientid)
handlemsg(myself, ba.PowerupMessage(poweruptype='health'))
elif arguments[0] == 'all':
handlemsg_all(ba.PowerupMessage(poweruptype='health'))
else:
try:
req_player = int(arguments[0])
handlemsg(req_player, ba.PowerupMessage(poweruptype='health'))
except:
return
def curse(arguments, clientid):
if arguments == [] or arguments == ['']:
myself = clientid_to_myself(clientid)
handlemsg(myself, ba.PowerupMessage(poweruptype='curse'))
elif arguments[0] == 'all':
handlemsg_all(ba.PowerupMessage(poweruptype='curse'))
else:
try:
req_player = int(arguments[0])
handlemsg(req_player, ba.PowerupMessage(poweruptype='curse'))
except:
return
def sleep(arguments, clientid):
activity = _ba.get_foreground_host_activity()
if arguments == [] or arguments == ['']:
myself = clientid_to_myself(clientid)
activity.players[myself].actor.node.handlemessage('knockout', 8000)
elif arguments[0] == 'all':
for i in activity.players:
i.actor.node.handlemessage('knockout', 8000)
else:
try:
req_player = int(arguments[0])
activity.players[req_player].actor.node.handlemessage('knockout', 8000)
except:
return
def hug(arguments, clientid):
activity = _ba.get_foreground_host_activity()
if arguments == [] or arguments == ['']:
myself = clientid_to_myself(clientid)
if activity.players[myself].actor.node.hold_node != True:
activity.players[myself].actor.node.hold_node = True
else:
activity.players[myself].node.hold_node = False
elif arguments[0] == 'all':
activity = _ba.get_foreground_host_activity()
for i in activity.players:
if i.actor.node.hold_node != True:
i.actor.node.hold_node = True
else:
i.actor.node.hold_node = False
else:
try:
activity = _ba.get_foreground_host_activity()
req_player = int(arguments[0])
if activity.players[req_player].actor.node.hold_node != True:
activity.players[req_player].actor.node.hold_node = True
else:
activity.players[req_player].actor.node.hold_node = False
except:
return
def super_punch(arguments, clientid):
activity = _ba.get_foreground_host_activity()
if arguments == [] or arguments == ['']:
myself = clientid_to_myself(clientid)
if activity.players[myself].actor._punch_power_scale != 15:
activity.players[myself].actor._punch_power_scale = 15
activity.players[myself].actor._punch_cooldown = 0
else:
activity.players[myself].actor._punch_power_scale = 1.2
activity.players[myself].actor._punch_cooldown = 400
elif arguments[0] == 'all':
activity = _ba.get_foreground_host_activity()
for i in activity.players:
if i.actor._punch_power_scale != 15:
i.actor._punch_power_scale = 15
i.actor._punch_cooldown = 0
else:
i.actor._punch_power_scale = 1.2
i.actor._punch_cooldown = 400
else:
try:
activity = _ba.get_foreground_host_activity()
req_player = int(arguments[0])
if activity.players[req_player].actor._punch_power_scale != 15:
activity.players[req_player].actor._punch_power_scale = 15
activity.players[req_player].actor._punch_cooldown = 0
else:
activity.players[req_player].actor._punch_power_scale = 1.2
activity.players[req_player].actor._punch_cooldown = 400
except:
return
def gloves(arguments, clientid):
if arguments == [] or arguments == ['']:
myself = clientid_to_myself(clientid)
handlemsg(myself, ba.PowerupMessage(poweruptype='punch'))
elif arguments[0] == 'all':
handlemsg_all(ba.PowerupMessage(poweruptype='punch'))
else:
try:
req_player = int(arguments[0])
handlemsg(req_player, ba.PowerupMessage(poweruptype='punch'))
except:
return
def shield(arguments, clientid):
if arguments == [] or arguments == ['']:
myself = clientid_to_myself(clientid)
handlemsg(myself, ba.PowerupMessage(poweruptype='shield'))
elif arguments[0] == 'all':
handlemsg_all(ba.PowerupMessage(poweruptype='shield'))
else:
try:
req_player = int(arguments[0])
handlemsg(req_player, ba.PowerupMessage(poweruptype='shield'))
except:
return
def freeze(arguments, clientid):
if arguments == [] or arguments == ['']:
myself = clientid_to_myself(clientid)
handlemsg(myself, ba.FreezeMessage())
elif arguments[0] == 'all':
handlemsg_all(ba.FreezeMessage())
else:
try:
req_player = int(arguments[0])
handlemsg(req_player, ba.FreezeMessage())
except:
return
def un_freeze(arguments, clientid):
if arguments == [] or arguments == ['']:
myself = clientid_to_myself(clientid)
handlemsg(myself, ba.ThawMessage())
elif arguments[0] == 'all':
handlemsg_all(ba.ThawMessage())
else:
try:
req_player = int(arguments[0])
handlemsg(req_player, ba.ThawMessage())
except:
return
def god_mode(arguments, clientid):
if arguments == [] or arguments == ['']:
myself = clientid_to_myself(clientid)
activity = _ba.get_foreground_host_activity()
player = activity.players[myself].actor
if player._punch_power_scale != 7:
player._punch_power_scale = 7
player.node.hockey = True
player.node.invincible = True
else:
player._punch_power_scale = 1.2
player.node.hockey = False
player.node.invincible = False
elif arguments[0] == 'all':
activity = _ba.get_foreground_host_activity()
for i in activity.players:
if i.actor._punch_power_scale != 7:
i.actor._punch_power_scale = 7
i.actor.node.hockey = True
i.actor.node.invincible = True
else:
i.actor._punch_power_scale = 1.2
i.actor.node.hockey = False
i.actor.node.invincible = False
else:
activity = _ba.get_foreground_host_activity()
req_player = int(arguments[0])
player = activity.players[req_player].actor
if player._punch_power_scale != 7:
player._punch_power_scale = 7
player.node.hockey = True
player.node.invincible = True
else:
player._punch_power_scale = 1.2
player.node.hockey = False
player.node.invincible = False
def speedy(arguments, clientid):
if arguments == [] or arguments == ['']:
myself = clientid_to_myself(clientid)
activity = _ba.get_foreground_host_activity()
player = activity.players[myself].actor
if player.node.hockey != True:
player.node.hockey = True
else:
player.node.hockey = False
elif arguments[0] == 'all':
activity = _ba.get_foreground_host_activity()
for i in activity.players:
if i.actor.node.hockey != True:
i.actor.node.hockey = True
else:
i.actor.node.hockey = False
else:
activity = _ba.get_foreground_host_activity()
req_player = int(arguments[0])
player = activity.players[req_player].actor
if player.node.hockey != True:
player.node.hockey = True
else:
player.node.hockey = False
def zm(arguments, clientid):
if len(arguments) == 0:
_ba.screenmessage("Special Chat Only For Main", color=(1,1,1), transient=True, clients=[clientid])
else:
k = arguments[0]
with ba.Context(_ba.get_foreground_host_activity()):
ZoomText(
k,
position=(0, 180),
maxwidth=800,
lifespan=25000,
color=(0.93*1.25, 0.9*1.25, 1.0*1.25),
trailcolor=(0.15, 0.05, 1.0, 0.0),
flash=False,
jitter=2.0).autoretain
def load_roles_data():
base_path = os.path.join(_ba.env()['python_directory_user'], "playersData" + os.sep)
roles_file_path = os.path.join(base_path, 'roles.json')
with open(roles_file_path, 'r') as file:
roles_data = json.load(file)
return roles_data
def acl(arguments, client_id):
roles_data = load_roles_data()
if arguments == [] or arguments == ['']:
admin_commands = roles_data.get("admin", {}).get("commands", [])
msg = "Admin Commands:\n" + "\n".join(admin_commands)+"\n"
send(msg, client_id)

View file

@ -0,0 +1,332 @@
from .Handlers import handlemsg, handlemsg_all, send, clientid_to_myself, sendchat
from playersData import pdata
# from tools.whitelist import add_to_white_list, add_commit_to_logs
from serverData import serverdata
import ba,os,json
from datetime import datetime, timedelta
import _ba
import time
import setting
import ba.internal
import _thread
import set
import roles
import random
import setting
from stats import mystats
from bastd.gameutils import SharedObjects
from tools import playlist
from tools import logger, mongo
import set
import json
Commands = ['cjt', 'checkjointime', 'shop', 'donate','removepaideffect']
CommandAliases = ['give', 'buy', 'cts', 'stc', 'rpe', 'bsc', 'bombsquad-card', 'claim']
BANK_PATH = _ba.env().get("python_directory_user", "") + "/bank.json"
base_path = os.path.join(_ba.env()['python_directory_user'], "stats" + os.sep)
statsfile = base_path + 'stats.json'
python_path = _ba.env()["python_directory_user"]
settings = setting.get_settings_data()
tic = settings["CurrencyType"]["YourCurrency"]
def CoinCommands(command, arguments, clientid, accountid):
"""
Checks The Command And Run Function
Parameters:
command : str
arguments : str
clientid : int
accountid : int
Returns:
None
"""
if command == 'shop':
shop(arguments, clientid)
elif command in ['scoretocash', 'stc']:
stc(arguments, clientid, accountid)
elif command in ['cashtoscore', 'cts']:
cts(arguments, clientid, accountid)
elif command in ['donate', 'give']:
donate(arguments, clientid, accountid)
elif command == 'buy':
buy(arguments, clientid, accountid)
elif command == 'claim':
claim_ticket(arguments, clientid, accountid)
elif command in ['rpe', 'removepaideffect']:
rpe(arguments, clientid, accountid)
elif command in ['cjt', 'checkjointime']:
check_claim_time(arguments, clientid, accountid)
elif command in ['bsc', 'bombsquad-card']:
bombsquad_card(clientid, accountid)
def getcoins(accountid: str):
with open(BANK_PATH, 'r') as f:
coins = json.loads(f.read())
if accountid in coins:
return coins[accountid]
def getstats():
f = open(statsfile, 'r')
return json.loads(f.read())
def addcoins(accountid: str, amount: int):
if os.path.exists(BANK_PATH):
with open(BANK_PATH) as f:
bank = json.loads(f.read())
else:
bank = {}
if accountid not in bank:
bank[accountid] = 0
bank[accountid] += amount
with open(BANK_PATH, 'w') as f:
f.write(json.dumps(bank))
if amount > 0:
ba.playsound(ba.getsound("cashRegister"))
print('Transaction successful')
def addcoin(accountid: str, amount: int):
if os.path.exists(BANK_PATH):
with open(BANK_PATH) as f:
bank = json.loads(f.read())
else:
bank = {}
if accountid not in bank:
bank[accountid] = 0
bank[accountid] += amount
with open(BANK_PATH, 'w') as f:
f.write(json.dumps(bank))
if amount > 0:
print('Transaction successful')
def shop(arguments, clientid):
players = _ba.get_foreground_host_activity().players
player = _ba.get_foreground_host_activity()
a = arguments
with ba.Context(player):
string = '==You can buy following items==\n'
if a == []:
send("Usage: /shop commands, /shop effects and /shop tag", clientid)
elif a[0].startswith('effects'):
for x in set.availableeffects:
string += f"{x} ---- {tic}{str(set.availableeffects[x])} ---- for 1 day\n"
send(string, clientid)
elif a[0].startswith('commands'):
separator = ' '
for x in set.availablecommands:
string += f"{x}----{tic}{str(set.availablecommands[x])}{separator}"
if separator == ' ': separator = '\n'
else: separator = ' '
ba.screenmessage(string, transient=True, color=(1, 1, 1), clients=[clientid])
else:
send("Usage: /shop commands or /shop effects", clientid)
def check_claim_time(arguments, clientid, accountid):
customers = pdata.get_custom()['coin_claim']
if accountid in customers:
if customers:
expiry = datetime.strptime(customers[accountid]['expiry'], '%d-%m-%Y %H:%M:%S')
remaining_time_seconds = int((expiry - datetime.now()).total_seconds())
# Calculate hours, minutes, and seconds
hours = remaining_time_seconds // 3600
minutes = (remaining_time_seconds % 3600) // 60
seconds = remaining_time_seconds % 60
send(f"Time remaining until your next join coin claim: {hours}:{minutes}:{seconds}", clientid)
def stc(arguments, clientid, accountid):
players = _ba.get_foreground_host_activity().players
player = _ba.get_foreground_host_activity()
a = arguments
with ba.Context(player):
try:
score = int(a[0])
stats = mystats.get_all_stats()
havescore = stats[accountid]['scores']
if havescore < score:
send(f"Not enough scores to perform the transaction", clientid)
send(f"You have {havescore} Score only....", clientid)
elif score < 500:
send(f"You can only convert more than 500 scores", clientid)
else:
stats[accountid]['scores'] -= score
mystats.dump_stats(stats)
equivalentCoins = int(score / 5 * 0.9)
addcoins(accountid, equivalentCoins)
ba.screenmessage('Transaction Successful', color=(0,1,0))
_ba.chatmessage(f"{str(equivalentCoins)}{tic} added to your account. [10% transaction fee deducted]")
mystats.refreshStats()
except:
send("Usage: /scoretocash or stc amount_of_score", clientid)
def donate(arguments, clientid, accountid):
players = _ba.get_foreground_host_activity().players
player = _ba.get_foreground_host_activity()
session = ba.internal.get_foreground_host_session()
a = arguments
with ba.Context(player):
try:
if len(a) < 2:
ba.screenmessage("Usage: /donate [amount] [clientid of player]", transient=True, clients=[clientid])
else:
havecoins = getcoins(accountid)
transfer = int(a[0])
if transfer < 100:
send(f"You can only transfer more than 100{tic}.", clientid)
return
sendersID = accountid
receiversID = None
for i in session.sessionplayers:
if i.inputdevice.client_id == int(a[1]):
receiversID = i.get_v1_account_id()
pname = i.getname(full=True, icon=True)
if i.inputdevice.client_id == clientid:
name = i.getname(full=True, icon=True)
if None not in [sendersID, receiversID]:
if sendersID == receiversID:
send(f"You can't transfer to your own account", clientid)
elif getcoins(sendersID) < transfer:
send(f"Not enough {tic}tickets to perform the transaction", clientid)
send(f"You have {havecoins}{tic} only....", clientid)
else:
addcoins(sendersID, transfer * -1)
addcoins(receiversID, transfer)
ba.playsound(ba.getsound("cashRegister"))
ba.screenmessage(f'Transaction Successful', color=(0,1,0))
_ba.chatmessage(f"Successfully transfered {transfer}{tic} into {pname}'s account.")
else:
send(f"player not found", clientid)
except Exception as e:
print(f"An error occurred: {e}")
ba.screenmessage('An error occurred. Check the console for details.', transient=True, clients=[clientid])
def cts(arguments, clientid, accountid):
players = _ba.get_foreground_host_activity().players
player = _ba.get_foreground_host_activity()
a = arguments
with ba.Context(player):
try:
coins = int(a[0])
havecoins = getcoins(accountid)
if havecoins < coins:
send(f"Not enough {tic}tickets to perform the transaction", clientid)
send(f"You have {havecoins}{tic} only....", clientid)
elif coins < 100:
send(f"You can only convert more than 100{tic}", clientid)
else:
addcoins(accountid, coins * -1)
stats = mystats.get_all_stats()
equivalentScore = int(coins * 5 * 0.9)
stats[accountid]['scores'] += equivalentScore
ba.playsound(ba.getsound("cashRegister"))
ba.screenmessage(f'Transaction Successful', color=(0,1,0))
mystats.dump_stats(stats)
_ba.chatmessage(f"{str(equivalentScore)} scores added to your account stats. [10% transaction fee deducted]")
mystats.refreshStats()
except:
send("Usage: /cashtoscore or cts amount_of_cash", clientid)
def buy(arguments, clientid, accountid):
global effectCustomers
players = _ba.get_foreground_host_activity().players
player = _ba.get_foreground_host_activity()
a = arguments
with ba.Context(player):
if a == []:
_ba.chatmessage('Usage: /buy item_name')
elif a[0] in set.availableeffects:
effect = a[0]
costofeffect = set.availableeffects[effect]
havecoins = getcoins(accountid)
if havecoins >= costofeffect:
customers = pdata.get_custom()['paideffects']
if accountid not in customers:
expiry = datetime.now() + timedelta(days=1)
customers[accountid] = {'effect': effect, 'expiry': expiry.strftime('%d-%m-%Y %H:%M:%S')}
addcoins(accountid, costofeffect * -1)
_ba.chatmessage(f"Success! That cost you {str(costofeffect)}{tic}")
else:
activeeffect = customers[accountid]['effect']
till = customers[accountid]['expiry']
send(f"You already have {activeeffect} effect active\nTill = {till}", clientid)
else:
send(f"You need {str(costofeffect)}{tic} for that, You have {str(havecoins)}{tic} only.", clientid)
else: send(f"invalid item, try using '/shop effects", clientid)
def rpe(arguments, clientid, accountid):
try:
custom = pdata.get_custom()['paideffects']
aeffect = custom[accountid]['effect']
session = ba.internal.get_foreground_host_session()
pdata.remove_paid_effect(accountid)
send(f"paid {aeffect} effect have been removed Successfully", clientid)
except:
return
def claim_ticket(arguments, clientid, accountid):
players = _ba.get_foreground_host_activity().players
player = _ba.get_foreground_host_activity()
session = ba.internal.get_foreground_host_session()
if arguments == [] or arguments == ['']:
with ba.Context(player):
customers = pdata.get_custom()['ticketclaimed']
for i in session.sessionplayers:
if i.inputdevice.client_id == clientid:
name = i.getname(full=True, icon=True)
if accountid not in customers:
expiry = datetime.now() + timedelta(seconds=1)
customers[accountid] = {'name': name, 'expiry': expiry.strftime('%d-%m-%Y %H:%M:%S')}
coin_claim = 50
addcoins(accountid, coin_claim)
_ba.chatmessage(f"Successfully added {coin_claim}{tic} into {name}'s account..")
else:
till = customers[accountid]['expiry']
send(f"Hey, you've already claimed your reward.\nNext chance: {till}", clientid)
# Function to check credit card details by player ID
def check_credit_card_by_pbid(accountid):
card_data = mongo.collection.find_one({"player_id": accountid})
if card_data:
return card_data
else:
return None
# Function to handle the /cc command
def bombsquad_card(clientid, accountid):
card_data = check_credit_card_by_pbid(accountid)
if card_data:
message = (
f"Credit card details found:\n"
f"Player ID: {card_data['player_id']}\n"
f"Player Name: {card_data['player_name']}\n"
f"Main Bs Number: {card_data['main_bs_number']}\n"
)
send(message, clientid)
else:
send(f"No Main Bs Number details found for player ID: {pbid}", clientid)

View file

@ -0,0 +1,218 @@
from .Handlers import handlemsg, handlemsg_all
import ba, _ba
from tools import corelib
Commands = ['fly', 'invisible', 'headless', 'creepy', 'celebrate', 'speed', 'floater']
CommandAliases = ['inv', 'hl', 'creep', 'celeb', 'flo']
def ExcelCommand(command, arguments, clientid, accountid):
"""
Checks The Command And Run Function
Parameters:
command : str
arguments : str
clientid : int
accountid : int
Returns:
None
"""
if command=='speed':
speed(arguments)
elif command == 'fly':
fly(arguments)
elif command in ['inv', 'invisible']:
invi(arguments)
elif command in ['hl', 'headless']:
headless(arguments)
elif command in ['creepy', 'creep']:
creep(arguments)
elif command in ['celebrate', 'celeb']:
celeb(arguments)
elif command in ['floater','flo']:
floater(arguments,clientid)
def floater(arguments,clientid):
try:
from .. import floater
if arguments ==[]:
floater.assignFloInputs(clientid)
else:
floater.assignFloInputs(arguments[0])
except:
pass
def speed(arguments):
if arguments ==[] or arguments==['']:
return
else:
corelib.set_speed(float(arguments[0]))
def fly(arguments):
if arguments == [] or arguments == ['']:
return
elif arguments[0] == 'all':
activity = _ba.get_foreground_host_activity()
for players in activity.players:
if players.actor.node.fly != True:
players.actor.node.fly = True
else:
players.actor.node.fly = False
else:
try:
activity = _ba.get_foreground_host_activity()
player = int(arguments[0])
if activity.players[player].actor.node.fly != True:
activity.players[player].actor.node.fly = True
else:
activity.players[player].actor.node.fly = False
except:
return
def invi(arguments):
if arguments == [] or arguments == ['']:
return
elif arguments[0] == 'all':
activity = _ba.get_foreground_host_activity()
for i in activity.players:
if i.actor.exists() and i.actor.node.torso_model != None:
body = i.actor.node
body.head_model = None
body.torso_model = None
body.upper_arm_model = None
body.forearm_model = None
body.pelvis_model = None
body.hand_model = None
body.toes_model = None
body.upper_leg_model = None
body.lower_leg_model = None
body.style = 'cyborg'
else:
player = int(arguments[0])
activity = _ba.get_foreground_host_activity()
body = activity.players[player].actor.node
if body.torso_model != None:
body.head_model = None
body.torso_model = None
body.upper_arm_model = None
body.forearm_model = None
body.pelvis_model = None
body.hand_model = None
body.toes_model = None
body.upper_leg_model = None
body.lower_leg_model = None
body.style = 'cyborg'
def headless(arguments):
if arguments == [] or arguments == ['']:
return
elif arguments[0] == 'all':
activity = _ba.get_foreground_host_activity()
for players in activity.players:
node = players.actor.node
if node.head_model != None:
node.head_model = None
node.style='cyborg'
else:
try:
player = int(arguments[0])
activity = _ba.get_foreground_host_activity()
node = activity.players[player].actor.node
if node.head_model != None:
node.head_model = None
node.style='cyborg'
except:
return
def creep(arguments):
if arguments == [] or arguments == ['']:
return
elif arguments[0] == 'all':
activity = _ba.get_foreground_host_activity()
for players in activity.players:
node = players.actor.node
if node.head_model != None:
node.head_model = None
node.handlemessage(ba.PowerupMessage(poweruptype='punch'))
node.handlemessage(ba.PowerupMessage(poweruptype='shield'))
else:
try:
player = int(arguments[0])
activity = _ba.get_foreground_host_activity()
node = activity.players[player].actor.node
if node.head_model != None:
node.head_model = None
node.handlemessage(ba.PowerupMessage(poweruptype='punch'))
node.handlemessage(ba.PowerupMessage(poweruptype='shield'))
except:
return
def celeb(arguments):
if arguments == [] or arguments == ['']:
return
elif arguments[0] == 'all':
handlemsg_all(ba.CelebrateMessage())
else:
try:
player = int(arguments[0])
handlemsg(player, ba.CelebrateMessage())
except:
return

View file

@ -0,0 +1,54 @@
""" Some useful handlers to reduce lot of code """
import _ba, ba
import ba.internal
def send(msg, clientid):
"""Shortcut To Send Private Msg To Client"""
for m in msg.split("\n"):
ba.internal.chatmessage(str(m), clients=[clientid])
_ba.screenmessage(str(msg), transient=True, clients=[clientid])
def sendchatclid(msg, clientid):
"""Shortcut To Send Private Msg To Client"""
for m in msg.split("\n"):
ba.internal.chatmessage(str(m), clients=[clientid])
def sendmsgclid(msg, clientid):
"""Shortcut To Send Private Msg To Client"""
_ba.screenmessage(str(msg), transient=True, clients=[clientid])
def sendall(msg):
"""Shortcut To Send Private Msg To Client"""
for m in msg.split("\n"):
ba.internal.chatmessage(str(m))
_ba.screenmessage(str(msg), transient=True)
def sendchat(msg):
"""Shortcut To Send Private Msg To Client"""
for m in msg.split("\n"):
ba.internal.chatmessage(str(m))
def clientid_to_myself(clientid):
"""Return Player Index Of Self Player"""
for i , player in enumerate(_ba.get_foreground_host_activity().players):
if player.sessionplayer.inputdevice.client_id == clientid:
return i
def handlemsg(client, msg):
"""Handles Spaz Msg For Single Player"""
activity = _ba.get_foreground_host_activity()
activity.players[client].actor.node.handlemessage(msg)
def handlemsg_all(msg):
"""Handle Spaz message for all players in activity"""
activity = _ba.get_foreground_host_activity()
for i in activity.players:
i.actor.node.handlemessage(msg)

View file

@ -0,0 +1,810 @@
from .Handlers import handlemsg, handlemsg_all, send, clientid_to_myself, sendall, sendchat
from playersData import pdata
# from tools.whitelist import add_to_white_list, add_commit_to_logs
from serverData import serverdata
import ba
import _ba
import time
import setting
import ba.internal
import _thread
import random
from stats import mystats
from bastd.gameutils import SharedObjects
from tools import playlist
from tools import logger
Commands = ['recents', 'info', 'cm', 'createteam', 'unban', 'showid', 'hideid', 'lm', 'gp', 'party', 'quit', 'kickvote', 'maxplayers', 'playlist', 'server', 'ban', 'kick', 'remove', 'end', 'quit', 'mute', 'unmute', 'slowmo', 'nv', 'dv', 'pause',
'cameramode', 'createrole', 'ct', 'reflections', 'partyname', 'addrole', 'removerole', 'addcommand', 'addcmd', 'removecommand', 'getroles', 'removecmd', 'changetag', 'customtag', 'customeffect', 'removeeffect', 'removetag', 'add', 'spectators', 'lobbytime']
CommandAliases = ['max', 'rm', 'next', 'restart', 'mutechat', 'unmutechat', 'sm',
'slow', 'night', 'fr', 'floorReflection', 'frefl', 'day', 'pn', 'pausegame', 'camera_mode', 'rotate_camera', 'effect']
def ExcelCommand(command, arguments, clientid, accountid):
"""
Checks The Command And Run Function
Parameters:
command : str
arguments : str
clientid : int
accountid : int
Returns:
None
"""
if command in ['recents']:
get_recents(clientid)
if command in ['info']:
get_player_info(arguments, clientid)
if command in ['maxplayers', 'max']:
changepartysize(arguments)
if command in ['createteam', 'ct']:
create_team(arguments)
elif command == 'playlist':
changeplaylist(arguments)
elif command == 'server':
server(arguments, clientid)
elif command == 'kick':
kick(arguments, clientid, accountid)
elif command == 'ban':
ban(arguments, clientid, accountid)
elif command == 'unban':
unban(arguments, clientid, accountid)
elif command in ['end', 'next']:
end(arguments)
elif command == 'kickvote':
kikvote(arguments, clientid)
elif command == 'hideid':
hide_player_spec()
elif command == "showid":
show_player_spec()
elif command == 'lm':
last_msgs(clientid)
elif command == 'gp':
get_profiles(arguments, clientid)
elif command == 'cm':
cm(arguments, clientid)
elif command == 'party':
party_toggle(arguments)
elif command in ['quit', 'restart']:
quit(arguments)
elif command in ['mute', 'mutechat']:
mute(arguments)
elif command in ['unmute', 'unmutechat']:
un_mute(arguments)
elif command in ['remove', 'rm']:
remove(arguments)
elif command in ['sm', 'slow', 'slowmo']:
slow_motion()
elif command in ['fr', 'floorReflection', 'frefl']:
reflection(arguments)
elif command in ['nv', 'night']:
nv(arguments)
elif command in ['dv', 'day']:
dv(arguments)
elif command in ['pause', 'pausegame']:
pause()
elif command in ['cameraMode', 'camera_mode', 'rotate_camera']:
rotate_camera()
elif command == 'createrole':
create_role(arguments)
elif command == 'addrole':
add_role_to_player(arguments)
elif command == 'removerole':
remove_role_from_player(arguments)
elif command == 'getroles':
get_roles_of_player(arguments, clientid)
elif command == 'reflections':
reflections(arguments, clientid)
elif command in ['pn', 'partyname']:
partyname(arguments, clientid, accountid)
elif command in ['addcommand', 'addcmd']:
add_command_to_role(arguments)
elif command in ['removecommand', 'removecmd']:
remove_command_to_role(arguments)
elif command == 'changetag':
change_role_tag(arguments)
elif command == 'customtag':
set_custom_tag(arguments)
elif command in ['customeffect', 'effect']:
set_custom_effect(arguments)
elif command in ['removetag']:
remove_custom_tag(arguments)
elif command in ['removeeffect']:
remove_custom_effect(arguments)
# elif command in ['add', 'whitelist']:
# whitelst_it(accountid, arguments)
elif command == 'spectators':
spectators(arguments)
elif command == 'lobbytime':
change_lobby_check_time(arguments)
def create_team(arguments):
if len(arguments) == 0:
ba.internal.chatmessage("enter team name")
else:
from ba._team import SessionTeam
_ba.get_foreground_host_session().sessionteams.append(SessionTeam(team_id=len(_ba.get_foreground_host_session().sessionteams) + 1, name=str(arguments[0]), color=(random.uniform(0, 1.2), random.uniform(
0, 1.2), random.uniform(0, 1.2))))
from ba._lobby import Lobby
_ba.get_foreground_host_session().lobby = Lobby()
def hide_player_spec():
_ba.hide_player_device_id(True)
def show_player_spec():
_ba.hide_player_device_id(False)
def get_player_info(arguments, client_id):
if len(arguments) == 0:
send("invalid client id", client_id)
for account in serverdata.recents:
if account['client_id'] == int(arguments[0]):
send(pdata.get_detailed_info(account["pbid"]), client_id)
def get_recents(client_id):
for players in serverdata.recents:
send(
f"{players['client_id']} {players['deviceId']} {players['pbid']}", client_id)
def changepartysize(arguments):
if len(arguments) == 0:
ba.internal.chatmessage("enter number")
else:
ba.internal.set_public_party_max_size(int(arguments[0]))
ba.internal.chatmessage("Maximum players set to " + str(int(arguments[0])))
def changeplaylist(arguments):
if len(arguments) == 0:
ba.internal.chatmessage("enter list code or name")
else:
if arguments[0] == 'coop':
serverdata.coopmode = True
else:
serverdata.coopmode = False
playlist.setPlaylist(arguments[0])
return
def server(arguments, client_id):
if arguments == []:
ba.internal.chatmessage("Usage: /server [name] <text to send>", clients=[client_id])
else:
message = ""
for i in range(1, len(arguments)):
message += arguments[i] + ''
ba.internal.chatmessage(message, sender_override=arguments[0])
def partyname(arguments, client_id, ac_id):
if arguments == []:
ba.internal.chatmessage("Usage: /partyname Name of party", clients=[client_id])
else:
stats = mystats.get_stats_by_id(ac_id)
myself = stats["name"]
name = " "
for word in arguments:
name+= word+" "
try:
ba.internal.set_public_party_name(name)
_ba.screenmessage(f"{myself} Changed party Name To {name}", color=(1,1,1), transient=True)
except:
_ba.screenmessage("failed to change partys name", color=(1,1,1), transient=True, clients=[client_id])
def kick(arguments, clientid, ac_id):
cl_id = int(arguments[0])
for pla in ba.internal.get_foreground_host_session().sessionplayers:
if pla.inputdevice.client_id == clientid:
myself = pla.getname(full=True, icon=True)
for ros in ba.internal.get_game_roster():
if ros["client_id"] == cl_id:
logger.log(f'kicked {ros["display_string"]}')
sendchat(f'{myself} kicked {ros["display_string"]} Goodbye 👋')
ba.internal.disconnect_client(int(arguments[0]))
return
def kikvote(arguments, clientid):
if arguments == [] or arguments == [''] or len(arguments) < 2:
return
elif arguments[0] == 'enable':
if arguments[1] == 'all':
_ba.set_enable_default_kick_voting(True)
else:
try:
cl_id = int(arguments[1])
for ros in ba.internal.get_game_roster():
if ros["client_id"] == cl_id:
pdata.enable_kick_vote(ros["account_id"])
logger.log(
f'kick vote enabled for {ros["account_id"]} {ros["display_string"]}')
send(
"Upon server restart, Kick-vote will be enabled for this person", clientid)
return
except:
return
elif arguments[0] == 'disable':
if arguments[1] == 'all':
_ba.set_enable_default_kick_voting(False)
else:
try:
cl_id = int(arguments[1])
for ros in ba.internal.get_game_roster():
if ros["client_id"] == cl_id:
_ba.disable_kickvote(ros["account_id"])
send("Kick-vote disabled for this person", clientid)
logger.log(
f'kick vote disabled for {ros["account_id"]} {ros["display_string"]}')
pdata.disable_kick_vote(
ros["account_id"], 2, "by chat command")
return
except:
return
else:
return
def last_msgs(clientid):
for i in ba.internal.get_chat_messages():
send(i, clientid)
def get_profiles(arguments, clientid):
try:
playerID = int(arguments[0])
num = 1
for i in ba.internal.get_foreground_host_session().sessionplayers[playerID].inputdevice.get_player_profiles():
try:
send(f"{num})- {i}", clientid)
num += 1
except:
pass
except:
pass
def party_toggle(arguments):
if arguments == ['public']:
ba.internal.set_public_party_enabled(True)
ba.internal.chatmessage("party is public now")
elif arguments == ['private']:
ba.internal.set_public_party_enabled(False)
ba.internal.chatmessage("party is private now")
else:
pass
def end(arguments):
if arguments == [] or arguments == ['']:
try:
with _ba.Context(_ba.get_foreground_host_activity()):
_ba.get_foreground_host_activity().end_game()
except:
pass
def ban(arguments, clientid, ac_id):
try:
cl_id = int(arguments[0])
for pla in ba.internal.get_foreground_host_session().sessionplayers:
if pla.inputdevice.client_id == clientid:
myself = pla.getname(full=True, icon=True)
duration = int(arguments[1]) if len(arguments) >= 2 else 0.5
for ros in ba.internal.get_game_roster():
if ros["client_id"] == cl_id:
pdata.ban_player(ros['account_id'], duration,
"by chat command")
logger.log(f'banned {ros["display_string"]} by chat command')
sendchat(f'{myself} banned {ros["display_string"]} Goodbye 👋')
ba.internal.disconnect_client(int(arguments[0]))
## backup part
for account in serverdata.recents: # backup case if player left the server
if account['client_id'] == int(arguments[0]):
pdata.ban_player(
account["pbid"], duration, "by chat command")
logger.log(
f'banned {account["deviceId"]} by chat command, recents')
ba.internal.disconnect_client(account['client_id'])
except:
pass
def unban(arguments, clientid, ac_id):
try:
cl_id = int(arguments[0])
for pla in ba.internal.get_foreground_host_session().sessionplayers:
if pla.inputdevice.client_id == clientid:
myself = pla.getname(full=True, icon=True)
for account in serverdata.recents: # backup unban if u by mistakely ban anyone
if account['client_id'] == cl_id:
pdata.unban_player(account["pbid"])
logger.log(
f'unbanned {account["deviceId"]} by chat command')
sendchat(f'{myself} unbanned {account["deviceId"]} from recents')
except:
pass
def quit(arguments):
if arguments == [] or arguments == ['']:
logger.log(
f'Server Restarting, Please Join in a moment !')
sendall("Server Restarting, Please Join in a moment !")
ba.quit()
def mute(arguments):
if len(arguments) == 0:
serverdata.muted = True
try:
cl_id = int(arguments[0])
duration = int(arguments[1]) if len(arguments) >= 2 else 0.5
for ros in ba.internal.get_game_roster():
if ros["client_id"] == cl_id:
ac_id = ros['account_id']
logger.log(f'muted {ros["display_string"]}')
pdata.mute(ac_id, duration, "muted by chat command")
return
for account in serverdata.recents: # backup case if player left the server
if account['client_id'] == int(arguments[0]):
pdata.mute(account["pbid"], duration,
"muted by chat command, from recents")
except:
pass
return
def un_mute(arguments):
if len(arguments) == []:
serverdata.muted = False
try:
cl_id = int(arguments[0])
for ros in ba.internal.get_game_roster():
if ros["client_id"] == cl_id:
pdata.unmute(ros['account_id'])
logger.log(f'unmuted {ros["display_string"]} by chat command')
return
for account in serverdata.recents: # backup case if player left the server
if account['client_id'] == int(arguments[0]):
pdata.unmute(account["pbid"])
logger.log(
f'unmuted {ros["display_string"]} by chat command, recents')
except:
pass
def remove(arguments):
if arguments == [] or arguments == ['']:
return
elif arguments[0] == 'all':
session = ba.internal.get_foreground_host_session()
for i in session.sessionplayers:
i.remove_from_game()
else:
try:
session = ba.internal.get_foreground_host_session()
for i in session.sessionplayers:
if i.inputdevice.client_id == int(arguments[0]):
i.remove_from_game()
except:
return
def slow_motion():
activity = _ba.get_foreground_host_activity()
if activity.globalsnode.slow_motion != True:
activity.globalsnode.slow_motion = True
else:
activity.globalsnode.slow_motion = False
def reflection(arguments):
activity = _ba.get_foreground_host_activity()
if activity.globalsnode.floor_reflection != True:
activity.globalsnode.floor_reflection = arguments[0]
else:
activity.globalsnode.floor_reflection = False
def nv(arguments):
activity = _ba.get_foreground_host_activity()
if arguments == [] or arguments == ['']:
if activity.globalsnode.tint != (0.5, 0.7, 1.0):
activity.globalsnode.tint = (0.5, 0.7, 1.0)
else:
# will fix this soon
pass
elif arguments[0] == 'off':
if activity.globalsnode.tint != (0.5, 0.7, 1.0):
return
else:
pass
def dv(arguments):
activity = _ba.get_foreground_host_activity()
if arguments == [] or arguments == ['']:
if activity.globalsnode.tint != (1, 1, 1):
activity.globalsnode.tint = (1, 1, 1)
else:
# will fix this soon
pass
elif arguments[0] == 'off':
if activity.globalsnode.tint != (1, 1, 1):
return
else:
pass
def reflections(arguments, clientid):
if len(arguments) < 2:
ba.internal.chatmessage("Usage: /reflections type (1/0) scale", clients=[clientid])
else:
rs = [
int(arguments[1])]
typee = 'soft' if int(arguments[0]) == 0 else 'powerup'
try:
_ba.get_foreground_host_activity().map.node.reflection = typee
_ba.get_foreground_host_activity().map.node.reflection_scale = rs
except:
pass
else:
try:
_ba.get_foreground_host_activity().map.bg.reflection = typee
_ba.get_foreground_host_activity().map.bg.reflection_scale = rs
except:
pass
else:
try:
_ba.get_foreground_host_activity().map.floor.reflection = typee
_ba.get_foreground_host_activity().map.floor.reflection_scale = rs
except:
pass
else:
try:
_ba.get_foreground_host_activity().map.center.reflection = typee
_ba.get_foreground_host_activity().map.center.reflection_scale = rs
except:
pass
def cm(arguments, clientid):
with _ba.Context(_ba.get_foreground_host_activity()):
activity = _ba.get_foreground_host_activity()
if arguments == []:
time = 2
else:
time = int(arguments[0])
op = 0.08
std = activity.globalsnode.vignette_outer
ba.animate_array(activity.globalsnode, 'vignette_outer', 3, {0:activity.globalsnode.vignette_outer, 10.0:(0,1,0)})
try:
_ba.get_foreground_host_activity().map.node.opacity = op
except:
pass
try:
_ba.get_foreground_host_activity().map.bg.opacity = op
except:
pass
try:
_ba.get_foreground_host_activity().map.bg.node.opacity = op
except:
pass
try:
_ba.get_foreground_host_activity().map.node1.opacity = op
except:
pass
try:
_ba.get_foreground_host_activity().map.node2.opacity = op
except:
pass
try:
_ba.get_foreground_host_activity().map.node3.opacity = op
except:
pass
try:
_ba.get_foreground_host_activity().map.steps.opacity = op
except:
pass
try:
_ba.get_foreground_host_activity().map.floor.opacity = op
except:
pass
try:
_ba.get_foreground_host_activity().map.center.opacity = op
except:
pass
def off():
op = 0.57
try:
_ba.get_foreground_host_activity().map.node.opacity = op
except:
pass
try:
_ba.get_foreground_host_activity().map.bg.opacity = op
except:
pass
try:
_ba.get_foreground_host_activity().map.bg.node.opacity = op
except:
pass
try:
_ba.get_foreground_host_activity().map.node1.opacity = op
except:
pass
try:
_ba.get_foreground_host_activity().map.node2.opacity = op
except:
pass
try:
_ba.get_foreground_host_activity().map.node3.opacity = op
except:
pass
try:
_ba.get_foreground_host_activity().map.steps.opacity = op
except:
pass
try:
_ba.get_foreground_host_activity().map.floor.opacity = op
except:
pass
try:
_ba.get_foreground_host_activity().map.center.opacity = op
except:
pass
ba.animate_array(activity.globalsnode, 'vignette_outer', 3, {0:activity.globalsnode.vignette_outer, 100:std})
ba.Timer(2.0, ba.Call(off))
def pause():
activity = _ba.get_foreground_host_activity()
if activity.globalsnode.paused != True:
activity.globalsnode.paused = True
else:
activity.globalsnode.paused = False
def rotate_camera():
activity = _ba.get_foreground_host_activity()
if activity.globalsnode.camera_mode != 'rotate':
activity.globalsnode.camera_mode = 'rotate'
else:
activity.globalsnode.camera_mode = 'follow'
def create_role(arguments):
try:
pdata.create_role(arguments[0])
except:
return
def add_role_to_player(arguments):
try:
session = ba.internal.get_foreground_host_session()
for i in session.sessionplayers:
if i.inputdevice.client_id == int(arguments[1]):
roles = pdata.add_player_role(
arguments[0], i.get_v1_account_id())
except:
return
def remove_role_from_player(arguments):
try:
session = ba.internal.get_foreground_host_session()
for i in session.sessionplayers:
if i.inputdevice.client_id == int(arguments[1]):
roles = pdata.remove_player_role(
arguments[0], i.get_v1_account_id())
except:
return
def get_roles_of_player(arguments, clientid):
try:
session = ba.internal.get_foreground_host_session()
roles = []
reply = ""
for i in session.sessionplayers:
if i.inputdevice.client_id == int(arguments[0]):
roles = pdata.get_player_roles(i.get_v1_account_id())
print(roles)
for role in roles:
reply = reply+role+","
send(reply, clientid)
except:
return
def change_role_tag(arguments):
try:
pdata.change_role_tag(arguments[0], arguments[1])
except:
return
def set_custom_tag(arguments):
try:
session = ba.internal.get_foreground_host_session()
for i in session.sessionplayers:
if i.inputdevice.client_id == int(arguments[1]):
roles = pdata.set_tag(arguments[0], i.get_v1_account_id())
except:
return
def remove_custom_tag(arguments):
try:
session = ba.internal.get_foreground_host_session()
for i in session.sessionplayers:
if i.inputdevice.client_id == int(arguments[0]):
pdata.remove_tag(i.get_v1_account_id())
except:
return
def remove_custom_effect(arguments):
try:
session = ba.internal.get_foreground_host_session()
for i in session.sessionplayers:
if i.inputdevice.client_id == int(arguments[0]):
pdata.remove_effect(i.get_v1_account_id())
except:
return
def set_custom_effect(arguments):
try:
session = ba.internal.get_foreground_host_session()
for i in session.sessionplayers:
if i.inputdevice.client_id == int(arguments[1]):
pdata.set_effect(arguments[0], i.get_v1_account_id())
except:
return
all_commands = ["changetag", "createrole", "addrole", "removerole", "addcommand", "addcmd", "removecommand", "removecmd", "kick", "remove", "rm", "end", "next", "quit", "restart", "mute", "mutechat", "unmute", "unmutechat", "sm", "slow", "slowmo", "nv", "night", "dv", "day", "pause", "pausegame", "cameraMode",
"camera_mode", "rotate_camera", "kill", "die", "heal", "heath", "curse", "cur", "sleep", "sp", "superpunch", "gloves", "punch", "shield", "protect", "freeze", "ice", "unfreeze", "thaw", "gm", "godmode", "fly", "inv", "invisible", "hl", "headless", "creepy", "creep", "celebrate", "celeb", "spaz"]
def add_command_to_role(arguments):
try:
if len(arguments) == 2:
pdata.add_command_role(arguments[0], arguments[1])
else:
ba.internal.chatmessage("invalid command arguments")
except:
return
def remove_command_to_role(arguments):
try:
if len(arguments) == 2:
pdata.remove_command_role(arguments[0], arguments[1])
except:
return
# def whitelst_it(accountid : str, arguments):
# settings = setting.get_settings_data()
# if arguments[0] == 'on':
# if settings["white_list"]["whitelist_on"]:
# ba.internal.chatmessage("Already on")
# else:
# settings["white_list"]["whitelist_on"] = True
# setting.commit(settings)
# ba.internal.chatmessage("whitelist on")
# from tools import whitelist
# whitelist.Whitelist()
# return
# elif arguments[0] == 'off':
# settings["white_list"]["whitelist_on"] = False
# setting.commit(settings)
# ba.internal.chatmessage("whitelist off")
# return
# else:
# rost = ba.internal.get_game_roster()
# for i in rost:
# if i['client_id'] == int(arguments[0]):
# add_to_white_list(i['account_id'], i['display_string'])
# ba.internal.chatmessage(str(i['display_string'])+" whitelisted")
# add_commit_to_logs(accountid+" added "+i['account_id'])
def spectators(arguments):
if arguments[0] in ['on', 'off']:
settings = setting.get_settings_data()
if arguments[0] == 'on':
settings["white_list"]["spectators"] = True
setting.commit(settings)
ba.internal.chatmessage("spectators on")
elif arguments[0] == 'off':
settings["white_list"]["spectators"] = False
setting.commit(settings)
ba.internal.chatmessage("spectators off")
def change_lobby_check_time(arguments):
try:
argument = int(arguments[0])
except:
ba.internal.chatmessage("must type number to change lobby check time")
return
settings = setting.get_settings_data()
settings["white_list"]["lobbychecktime"] = argument
setting.commit(settings)
ba.internal.chatmessage(f"lobby check time is {argument} now")

View file

@ -0,0 +1,484 @@
from .Handlers import handlemsg, handlemsg_all, send, clientid_to_myself
from playersData import pdata
# from tools.whitelist import add_to_white_list, add_commit_to_logs
from serverData import serverdata
#from chatHandle.ChatCommands.commands import NormalCommands as nc
import ba
import _ba,os,json
import time
import setting
import ba.internal
import _thread
import random
from stats import mystats
from bastd.gameutils import SharedObjects
from tools import playlist
from tools import logger
Commands = ['hug', 'icy', 'spaz', 'zombieall', 'boxall', 'texall', 'kickall', 'ooh', 'spazall', 'acl', 'vcl']
CommandAliases = ['cc', 'ccall', 'control', 'zombie', 'rainbow', 'ooh', 'playsound', 'tex', 'hugall', 'box', 'ac', 'exchange', 'tint', 'say', 'playsound', 'admincmdlist', 'vipcmdlist']
def NewCommands(command, arguments, clientid, accountid):
"""
Checks The Command And Run Function
Parameters:
command : str
arguments : str
clientid : int
accountid : int
Returns:
None
"""
if command == 'hug':
hug(arguments, clientid)
elif command == 'hugall':
hugall(arguments, clientid)
elif command in ['control', 'exchange']:
control(arguments, clientid)
elif command == 'icy':
icy(arguments, clientid)
elif command in ['cc', 'spaz']:
spaz(arguments, clientid)
elif command in ['ccall', 'spazall']:
spazall(arguments, clientid)
elif command == 'ac':
ac(arguments, clientid)
elif command == 'tint':
tint(arguments, clientid)
elif command == 'box':
box(arguments, clientid)
elif command == 'boxall':
boxall(arguments, clientid)
elif command == 'kickall':
kickall(arguments, clientid)
elif command == 'tex':
tex(arguments, clientid)
elif command == 'zombie':
zombie(arguments, clientid)
elif command == 'zombieall':
zombieall(arguments, clientid)
elif command == 'texall':
texall(arguments, clientid)
elif command == 'say':
server_chat(arguments, clientid)
elif command in ['acl', 'admincmdlist']:
acl(arguments, clientid)
elif command == 'ooh':
play_ooh_sound(arguments)
elif command == 'playsound':
play_sound(arguments, clientid)
elif command in ['vcl', 'vipcmdlist']:
vcl(arguments, clientid)
def hug(arguments, clientid):
players = _ba.get_foreground_host_activity().players
player = _ba.get_foreground_host_activity()
if arguments == [] or arguments == ['']:
with ba.Context(player):
send(f"Using: /hugall [or] /hug [player1Index] [player2Index]", clientid)
else:
try:
players[int(arguments[0])].actor.node.hold_node = players[int(arguments[1])].actor.node
except:
pass
def hugall(arguments, clientid):
players = _ba.get_foreground_host_activity().players
player = _ba.get_foreground_host_activity()
with ba.Context(player):
try:
players[0].actor.node.hold_node = players[1].actor.node
except:
pass
try:
players[1].actor.node.hold_node = players[0].actor.node
except:
pass
try:
players[2].actor.node.hold_node = players[3].actor.node
except:
pass
try:
players[3].actor.node.hold_node = players[2].actor.node
except:
pass
try:
players[4].actor.node.hold_node = players[5].actor.node
except:
pass
try:
players[5].actor.node.hold_node = players[4].actor.node
except:
pass
try:
players[6].actor.node.hold_node = players[7].actor.node
except:
pass
try:
players[7].actor.node.hold_node = players[6].actor.node
except:
pass
#KICK ALL :)))))))))
def kickall(arguments, clientid):
try:
for i in _ba.get_game_roster():
if i['client_id'] != clientid:
_ba.disconnect_client(i['client_id'])
except:
pass
def server_chat(arguments, clientid):
if arguments == []:
ba.screenmessage('Usage: /say <text to send>', transient=True, clients=[clientid])
else:
message = " ".join(arguments)
_ba.chatmessage(message)
def box(arguments, clientid):
players = _ba.get_foreground_host_activity().players
player = _ba.get_foreground_host_activity()
with ba.Context(player):
try:
try:
if arguments != []:
n = int(arguments[0])
players[n].actor.node.torso_model = ba.getmodel("tnt");
players[n].actor.node.color_mask_texture = ba.gettexture("tnt");
players[n].actor.node.color_texture = ba.gettexture("tnt")
players[n].actor.node.highlight = (1,1,1)
players[n].actor.node.color = (1,1,1);
players[n].actor.node.head_model = None;
players[n].actor.node.style = "cyborg";
except:
send(f"Using: /boxall [or] /box [PlayerID]", clientid)
except:
send(f"Using: /boxall [or] /box [PlayerID]", clientid)
#BOXALL
def boxall(arguments, clientid):
players = _ba.get_foreground_host_activity().players
player = _ba.get_foreground_host_activity()
with ba.Context(player):
try:
for i in players:
try:
i.actor.node.torso_model = ba.getmodel("tnt");
i.actor.node.color_mask_texture = ba.gettexture("tnt");
i.actor.node.color_texture = ba.gettexture("tnt")
i.actor.node.highlight = (1,1,1);
i.actor.node.color = (1,1,1);
i.actor.node.head_model = None;
i.actor.node.style = "cyborg";
except:
pass
except:
pass
def ac(arguments, clientid):
players = _ba.get_foreground_host_activity().players
player = _ba.get_foreground_host_activity()
a = arguments
with ba.Context(player):
try:
if arguments[0] == 'r':
m = 1.3 if a[1] is None else float(a[1])
s = 1000 if a[2] is None else float(a[2])
ba.animate_array(player.globalsnode, 'ambient_color',3, {0: (1*m,0,0), s: (0,1*m,0),s*2:(0,0,1*m),s*3:(1*m,0,0)},True)
else:
try:
if a[1] is not None:
player.globalsnode.ambient_color = (float(a[0]),float(a[1]),float(a[2]))
except:
pass
except:
send(f"Using: '/ac [Red] [Green] [Blue]' or '/ac r [brightness] [speed]'", clientid)
def tint(arguments, clientid):
players = _ba.get_foreground_host_activity().players
player = _ba.get_foreground_host_activity()
a = arguments
with ba.Context(player):
try:
if arguments[0] == 'r':
m = 1.3 if a[1] is None else float(a[1])
s = 1000 if a[2] is None else float(a[2])
ba.animate_array(player.globalsnode, 'tint',3, {0: (1*m,0,0), s: (0,1*m,0),s*2:(0,0,1*m),s*3:(1*m,0,0)},True)
else:
try:
if a[1] is not None:
player.globalsnode.tint = (float(a[0]),float(a[1]),float(a[2]))
except:
pass
except:
send(f"Using: '/tint [Red] [Green] [Blue]' or '/tint r [brightness] [speed]'", clientid)
def spaz(arguments, clientid):
players = _ba.get_foreground_host_activity().players
player = _ba.get_foreground_host_activity()
a = arguments
with ba.Context(player):
try:
try:
if arguments != []:
n = int(a[0])
players[n].actor.node.color_texture = ba.gettexture(a[1]+"Color")
players[n].actor.node.color_mask_texture = ba.gettexture(a[1]+"ColorMask")
players[n].actor.node.head_model = ba.getmodel(a[1]+"Head")
players[n].actor.node.torso_model = ba.getmodel(a[1]+"Torso")
players[n].actor.node.pelvis_model = ba.getmodel(a[1]+"Pelvis")
players[n].actor.node.upper_arm_model = ba.getmodel(a[1]+"UpperArm")
players[n].actor.node.forearm_model = ba.getmodel(a[1]+"ForeArm")
players[n].actor.node.hand_model = ba.getmodel(a[1]+"Hand")
players[n].actor.node.upper_leg_model = ba.getmodel(a[1]+"UpperLeg")
players[n].actor.node.lower_leg_model = ba.getmodel(a[1]+"LowerLeg")
players[n].actor.node.toes_model = ba.getmodel(a[1]+"Toes")
players[n].actor.node.style = (a[1])
except:
send(f"Using: /spazall [AppearanceName] [or] /spaz [PlayerID] [AppearanceName] \n________________|_AppearanceName_|_______________\n {'ali, wizard, cyborg, penguin, agent, pixie, bear, bunny'}", clientid)
except:
send(f"Using: /spazall [AppearanceName] [or] /spaz [PlayerID] [AppearanceName] \n________________|_AppearanceName_|________________\n {'ali, wizard, cyborg, penguin, agent, pixie, bear, bunny'}", clientid)
def spazall(arguments, clientid):
players = _ba.get_foreground_host_activity().players
player = _ba.get_foreground_host_activity()
a = arguments
with ba.Context(player):
for i in players:
try:
i.actor.node.color_texture = ba.gettexture(a[0]+"Color")
i.actor.node.color_mask_texture = ba.gettexture(a[0]+"ColorMask")
i.actor.node.head_model = ba.getmodel(a[0]+"Head")
i.actor.node.torso_model = ba.getmodel(a[0]+"Torso")
i.actor.node.pelvis_model = ba.getmodel(a[0]+"Pelvis")
i.actor.node.upper_arm_model = ba.getmodel(a[0]+"UpperArm")
i.actor.node.forearm_model = ba.getmodel(a[0]+"ForeArm")
i.actor.node.hand_model = ba.getmodel(a[0]+"Hand")
i.actor.node.upper_leg_model = ba.getmodel(a[0]+"UpperLeg")
i.actor.node.lower_leg_model = ba.getmodel(a[0]+"LowerLeg")
i.actor.node.toes_model = ba.getmodel(a[0]+"Toes")
i.actor.node.style = a[0]
except:
send(f"Using: /spazall [AppearanceName] \n________________|_AppearanceName_|________________\n {'ali, wizard, cyborg, penguin, agent, pixie, bear, bunny'}", clientid)
def zombie(arguments, clientid):
players = _ba.get_foreground_host_activity().players
player = _ba.get_foreground_host_activity()
a = arguments
with ba.Context(player):
try:
try:
if arguments != []:
n = int(a[0])
players[n].actor.node.color_texture = ba.gettexture("agentColor")
players[n].actor.node.color_mask_texture = ba.gettexture("pixieColorMask")
players[n].actor.node.head_model = ba.getmodel("zoeHead")
players[n].actor.node.torso_model = ba.getmodel("bonesTorso")
players[n].actor.node.pelvis_model = ba.getmodel("pixiePelvis")
players[n].actor.node.upper_arm_model = ba.getmodel("frostyUpperArm")
players[n].actor.node.forearm_model = ba.getmodel("frostyForeArm")
players[n].actor.node.hand_model = ba.getmodel("bonesHand")
players[n].actor.node.upper_leg_model = ba.getmodel("bonesUpperLeg")
players[n].actor.node.lower_leg_model = ba.getmodel("pixieLowerLeg")
players[n].actor.node.toes_model = ba.getmodel("bonesToes")
players[n].actor.node.color = (0,1,0)
players[n].actor.node.highlight = (0.6,0.6,0.6)
players[n].actor.node.style = "spaz"
except:
send(f"Using: /zombieall [or] /zombie [PlayerID]", clientid)
except:
send(f"Using: /zombieall [or] /zombie [PlayerID]", clientid)
def zombieall(arguments, clientid):
players = _ba.get_foreground_host_activity().players
player = _ba.get_foreground_host_activity()
a = arguments
with ba.Context(player):
for i in players:
try:
i.actor.node.color_texture = ba.gettexture("agentColor")
i.actor.node.color_mask_texture = ba.gettexture("pixieColorMask")
i.actor.node.head_model = ba.getmodel("zoeHead")
i.actor.node.torso_model = ba.getmodel("bonesTorso")
i.actor.node.pelvis_model = ba.getmodel("pixiePelvis")
i.actor.node.upper_arm_model = ba.getmodel("frostyUpperArm")
i.actor.node.forearm_model = ba.getmodel("frostyForeArm")
i.actor.node.hand_model = ba.getmodel("bonesHand")
i.actor.node.upper_leg_model = ba.getmodel("bonesUpperLeg")
i.actor.node.lower_leg_model = ba.getmodel("pixieLowerLeg")
i.actor.node.toes_model = ba.getmodel("bonesToes")
i.actor.node.color = (0,1,0)
i.actor.node.highlight = (0.6,0.6,0.6)
i.actor.node.style = "spaz"
except:
send(f"Using: /zombieall [or] /zombie [PlayerID]", clientid)
def tex(arguments, clientid):
players = _ba.get_foreground_host_activity().players
player = _ba.get_foreground_host_activity()
a = arguments
with ba.Context(player):
try:
if len(a) > 1: n = int(a[0])
color = None
if (len(a) > 1) and (str(a[1]) == 'kronk'): color = str(a[1])
else:color = str(a[1]) + 'Color'
try:
players[n].actor.node.color_mask_texture= ba.gettexture(str(a[1]) + 'ColorMask')
players[n].actor.node.color_texture= ba.gettexture(color)
except:
send(f"Using: /texall [texture] [or] /tex [PlayerID] [texture]", clientid)
except:
send(f"Using: /texall [texture] [or] /tex [PlayerID] [texture]", clientid)
def texall(arguments, clientid):
players = _ba.get_foreground_host_activity().players
player = _ba.get_foreground_host_activity()
a = arguments
with ba.Context(player):
try:
color = None
if str(a[0]) == 'kronk':
color = str(a[0])
else:color = str(a[0]) + 'Color'
for i in players:
try:
i.actor.node.color_mask_texture= ba.gettexture(str(a[0]) + 'ColorMask')
i.actor.node.color_texture= ba.gettexture(color)
except:
pass
except:
send(f"Using: /texall [texture] [or] /tex [PlayerID] [texture]", clientid)
def control(arguments, clientid):
players = _ba.get_foreground_host_activity().players
player = _ba.get_foreground_host_activity()
a = arguments
with ba.Context(player):
try:
if True:
try:
player1 = int(a[0])
except:
pass
try:
player2 = int(a[1])
except:
pass
node1 = players[player1].actor.node
node2 = players[player2].actor.node
players[player1].actor.node = node2
players[player2].actor.node = node1
except:
send(f"Using: /exchange [PlayerID1] [PlayerID2]", clientid)
def icy(arguments, clientid):
players = _ba.get_foreground_host_activity().players
player = _ba.get_foreground_host_activity()
a = arguments
with ba.Context(player):
try:
if True:
try:
player1 = int(a[0])
except:
pass
try:
player2 = int(a[1])
except:
pass
node1 = players[player2].actor.node
players[player1].actor.node = node1
except:
send(f"Using: /icy [PlayerID1] [PlayerID2]", clientid)
def play_ooh_sound(arguments):
players = _ba.get_foreground_host_activity().players
player = _ba.get_foreground_host_activity()
with ba.Context(player):
try:
a = arguments
if a is not None and len(a) > 0:
times = int(a[0])
def ooh_recursive(c):
ba.playsound(ba.getsound('ooh'), volume=2)
c -= 1
if c > 0:
ba.Timer(int(a[1]) if len(a) > 1 and a[1] is not None else 1000, ba.Call(ooh_recursive, c=c))
ooh_recursive(c=times)
else:
ba.playsound(ba.getsound('ooh'), volume=2)
except Exception as e:
pass
def play_sound(arguments, clientid):
players = _ba.get_foreground_host_activity().players
player = _ba.get_foreground_host_activity()
with ba.Context(player):
try:
a = arguments # Assign arguments to 'a'
if a is not None and len(a) > 0:
sound_name = str(a[0])
times = int(a[1]) if len(a) > 1 else 1 # Set default times to 1 if not provided
volume = float(a[2]) if len(a) > 2 else 2.0 # Set default volume to 2.0 if not provided
def play_sound_recursive(c):
ba.playsound(ba.getsound(sound_name), volume=volume)
c -= 1
if c > 0:
ba.Timer(int(a[3]) if len(a) > 3 and a[3] is not None else 1000, ba.Call(play_sound_recursive, c=c))
play_sound_recursive(c=times)
else:
send(f"Using: /playsound [music sound] [time] [volume]", clientid)
except Exception as e:
send(f"Using: /playsound [music sound] [time] [volume]", clientid)
def acl(arguments, clientid):
send(f"\ue046____________|ADMIN-CMDS-LISTS|______________\ue046", clientid)
send(f"\ue046|| kick, kill, heal, curse, ooh, sleep, superpunch or sp, gloves, tint", clientid)
send(f"\ue046|| shield, ice, thaw, gm, playsound, inv, hl, speed, sm, dv, nv, creepy, ac", clientid)
send(f"\ue046|| hug, tex, icy, celebrate, end, fly, lm, gp, remove, zombie, reflections", clientid)
def vcl(arguments, clientid):
send(f"\ue046___________|VIP-CMDS-LISTS|______________\ue046", clientid)
send(f"\ue046|| kill, heal, curse, sleep, ooh, gloves, creepy, hug, shield, thaw, fly", clientid)
send(f"\ue046|| box, tex, inv, hl, zombie, playsound, nv, dv, sm, ice, lm, end, remove", clientid)

View file

@ -0,0 +1,303 @@
from .Handlers import send, sendall, sendchat
import ba,os
import _ba,json
from features import discord_bot as dc
from datetime import datetime, timedelta
import discord, requests, asyncio
from playersData import pdata
import setting
import ba.internal
from stats import mystats
from ba._general import Call
import _thread
Commands = ['me', 'list', 'uniqeid', 'ping', 'vp', 'uid', 'pbid', 'comp', 'complaintstep']
CommandAliases = ['stats', 'score', 'rank',
'myself', 'l', 'id', 'pb-id', 'pme', 'pb', 'accountid', 'coinhelp', 'voting-playlist', 'complaint', 'cs']
def ExcelCommand(command, arguments, clientid, accountid, ARGUMENTS):
"""
Checks The Command And Run Function
Parameters:
command : str
arguments : str
ARGUMENTS : str
clientid : int
accountid : int
Returns:
None
"""
if command in ['me', 'rank', 'stats', 'score', 'myself']:
fetch_send_stats(accountid, clientid)
elif command in ['list', 'l']:
list(clientid)
elif command in ['uniqeid', 'uid', 'pb-id', 'pbid', 'accountid']:
accountid_request(arguments, clientid, accountid)
elif command in ['id', 'pb']:
accountid_clientid(arguments, clientid, accountid)
elif command in ['ping']:
get_ping(arguments, clientid)
elif command in ['voting-playlist', 'vp']:
voting_playlist(arguments, clientid)
elif command in ['cs', 'complaintstep']:
complaint_step(arguments, clientid)
elif command == 'pme':
stats_to_clientid(arguments, clientid, accountid)
elif command == 'coinhelp':
coinhelp(arguments, clientid)
elif command in ['comp', 'complaint']:
get_complaint(arguments, clientid, accountid, ARGUMENTS)
settings = setting.get_settings_data()
tic = settings["CurrencyType"]["YourCurrency"] #dont change this or it will give an error
def get_ping(arguments, clientid):
if arguments == [] or arguments == ['']:
send(f"Your ping {_ba.get_client_ping(clientid)}ms ", clientid)
elif arguments[0] == 'all':
pingall(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
#added tickets in stats :))
def getcoins(account_id: str):
BANK_PATH = _ba.env().get("python_directory_user", "") + "/bank.json"
with open(BANK_PATH, 'r') as f:
coins = json.loads(f.read())
if account_id in coins:
return coins[account_id]
def stats(ac_id, clientid):
stats = mystats.get_stats_by_id(ac_id)
if stats:
tickets = getcoins(ac_id)
reply = (
f"\ue048| Name: {stats['name']}\n"
f"\ue048| PB-ID: {stats['aid']}\n"
f"\ue048| Tickets: {tickets}{tic}\n"
f"\ue048| Rank: {stats['rank']}\n"
f"\ue048| Score: {stats['scores']}\n"
f"\ue048| Games: {stats['games']}\n"
f"\ue048| Kills: {stats['kills']}\n"
f"\ue048| Deaths: {stats['deaths']}\n"
f"\ue048| Avg.: {stats['avg_score']}\n"
)
else:
reply = "Not played any match yet."
_ba.pushcall(Call(send, reply, clientid), from_other_thread=True)
def fetch_send_stats(ac_id, clientid):
_thread.start_new_thread(stats, (ac_id, clientid,))
def stats_to_clientid(arguments, clid, acid):
players = _ba.get_foreground_host_activity().players
player = _ba.get_foreground_host_activity()
if arguments == [] or arguments == ['']:
with ba.Context(player):
send(f"Using: /pme [Clientid of player]", clid)
else:
cl_id = int(arguments[0])
for pla in ba.internal.get_foreground_host_session().sessionplayers:
if pla.inputdevice.client_id == cl_id:
fname = pla.getname(full=True, icon=True)
for roe in ba.internal.get_game_roster():
if roe["client_id"] == cl_id:
pbid = roe["account_id"]
stats = mystats.get_stats_by_id(pbid)
if stats:
tickets = getcoins(pbid)
reply = (
f"\ue048| Name: {fname}\n"
f"\ue048| PB-ID: {stats['aid']}\n"
f"\ue048| Tickets: {tickets}{tic}\n"
f"\ue048| Rank: {stats['rank']}\n"
f"\ue048| Score: {stats['scores']}\n"
f"\ue048| Games: {stats['games']}\n"
f"\ue048| Kills: {stats['kills']}\n"
f"\ue048| Deaths: {stats['deaths']}\n"
f"\ue048| Avg.: {stats['avg_score']}\n"
)
send(reply, clid)
else:
areply = "Not played any match yet."
send(areply, clid)
def pingall(clientid):
"""Returns The List Of Players Clientid and index"""
p = u'{0:^16}{1:^34}ms'
seprator = '\n______________________________\n'
list = p.format('Name', 'Ping (ms)')+seprator
session = ba.internal.get_foreground_host_session()
for index, player in enumerate(session.sessionplayers):
list += p.format(player.getname(icon=True),
_ba.get_client_ping(int(player.inputdevice.client_id)))+"\n"
send(list, clientid)
def list(clientid):
"""Returns The List Of Players Clientid and index"""
p = u'{0:^16}{1:^15}{2:^10}'
seprator = '\n______________________________\n'
list = p.format('Name', 'Client ID', 'Player ID')+seprator
session = ba.internal.get_foreground_host_session()
for index, player in enumerate(session.sessionplayers):
list += p.format(player.getname(icon=False),
player.inputdevice.client_id, index)+"\n"
send(list, clientid)
def voting_playlist(arguments, clientid):
"""Voting playlist list"""
if arguments == [] or arguments == ['']:
send(f"\ue048| VOTING GAMES LISTS ", clientid)
send(f"\ue048| PLAYLIST EPIC SMASH TYPE PES ", clientid)
send(f"\ue048| PLAYLIST EPIC TEAMS TYPE PET ", clientid)
send(f"\ue048| PLAYLIST DEFAULTS GAMES TYPE PDG ", clientid)
send(f"\ue048| PLAYLIST DEATHMATCH AND ELIMINATION ONLY TYPE PDEG ", clientid)
def complaint_step(arguments, clientid):
"""Voting playlist list"""
if arguments == [] or arguments == ['']:
send(f"\ue048| COMPLAINTS STEPS: ", clientid)
send(f"\ue048| Type /complaint (clientid of offender) (complaint) or", clientid)
send(f"\ue048| /comp (clientid of offender) (complaint)", clientid)
send(f"\ue048| For Example: /comp 113 betraying etc!!. ", clientid)
send(f"\ue048| Your Complaint will get sent to discord server immediately!!", clientid)
send(f"Note - Don't spam with this command or u will get a ban permanently..!!!!!", clientid)
def coinhelp(arguments, clientid):
send(f"\ue048| COINSYSTEM CMDz", clientid)
send(f"\ue048| Type /shop effects to know which effects are available to buy", clientid)
send(f"\ue048| Type /jct to check next join claim time", clientid)
send(f"\ue048| Type /rpe to remove paid effect..", clientid)
send(f"\ue048| Type /buy (effect) to buy effects ", clientid)
send(f"\ue048| Type /donate (amount of coins) (clientid of player) to donate your coins to a player", clientid)
#send(f"\ue048| Type /stc (amount) to convert score to cash (not available)", clientid)
#send(f"ue048| Type /cts (amount) to convert cash to score (not available)", clientid)
def accountid_request(arguments, clientid, accountid):
"""Returns The Account Id Of Players"""
if arguments == [] or arguments == ['']:
send(f"Your account id is {accountid} ", clientid)
else:
try:
session = ba.internal.get_foreground_host_session()
player = session.sessionplayers[int(arguments[0])]
name = player.getname(full=True, icon=True)
accountid = player.get_v1_account_id()
send(f" {name}'s account id is '{accountid}' ", clientid)
except:
return
def accountid_clientid(arguments, clientid, accountid):
"""accountid request by clientid """
players = _ba.get_foreground_host_activity().players
session = ba.internal.get_foreground_host_session()
player = _ba.get_foreground_host_activity()
a = arguments
with ba.Context(player):
if True:
clld = int(a[0])
for i in session.sessionplayers:
if i.inputdevice.client_id == clld:
names = i.getname(full=True, icon=True)
accountid = i.get_v1_account_id()
send(f" {names}'s account id is '{accountid}' ", clientid)
def get_complaint(arguments, clientid, acid, ARGUMENTS):
players = _ba.get_foreground_host_activity().players
player = _ba.get_foreground_host_activity()
server = _ba.app.server._config.party_name
customers = pdata.get_custom()['complainter']
a = arguments
b = ARGUMENTS
if not arguments or arguments == ['']:
with ba.Context(player):
send(f"Using: /comp [Clientid of offender] [complaint reason]", clientid)
else:
cl_id = int(arguments[0])
complaint = " ".join(b[1:])
# Check if the user is trying to complain against themselves
if cl_id == clientid:
send("You can't file a complaint against yourself.", clientid)
return
for pla in ba.internal.get_foreground_host_session().sessionplayers:
if pla.inputdevice.client_id == clientid:
name = pla.getname(full=True, icon=True)
if pla.inputdevice.client_id == cl_id:
fname = pla.getname(full=True, icon=True)
for ros in ba.internal.get_game_roster():
if ros['account_id'] == acid:
myself = ros["display_string"]
for roe in ba.internal.get_game_roster():
if roe["client_id"] == cl_id:
offendr = roe["display_string"]
pbid = roe["account_id"]
otheraccounts = pdata.get_detailed_pinfo(pbid)
now = datetime.now().strftime('%d-%m-%Y %I:%M:%S %p')
if acid not in customers:
if not complaint:
send("Please provide a complaint reason.", clientid)
return
expiry = datetime.now() + timedelta(hours=3)
customers[acid] = {'expiry': expiry.strftime('%d-%m-%Y %I:%M:%S %p')}
# Call the send_complaint_to_channel function
asyncio.ensure_future(dc.send_complaint_to_channel(server_name=server, time=now, myself=myself, ign=name, useracid=acid, fign=fname, acid=pbid, linkedaccount=otheraccounts, offender=offendr, complaint=complaint))
send("A complaint has been sent on the Discord server. Please wait for Staff to take action...!!", clientid)
else:
till = customers[acid]['expiry']
send(f"You can use the complaint command again at {till}", clientid)