def collectedMsg(msg, clientID): isAccAccesible = False #check is account id accesible if bsInternal._getForegroundHostActivity() is not None: if bsInternal._getForegroundHostActivity( ).players: # check if player exists for i in bsInternal._getForegroundHostActivity().players: if i.getInputDevice().getClientID() == clientID: isAccAccesible = True accountID = i.get_account_id() nick = i.getName().encode('utf8') t.collector(msg, nick, accountID) break if not isAccAccesible: # if not, go without account id for s in bsInternal._getGameRoster(): if s['clientID'] == clientID: nick = s['displayString'] accountID = 'NOT FOUND' t.collector(msg, nick, accountID) break else: #if not, continue from here for s in bsInternal._getGameRoster(): if s['clientID'] == clientID: nick = s['displayString'] accountID = 'NOT FOUND' t.collector(msg, nick, accountID) break
def hug(a, b): try: bsInternal._getForegroundHostActivity().players[int( a)].actor.node.holdNode = bsInternal._getForegroundHostActivity( ).players[int(b)].actor.node except: print 'error'
def chatLogg(msg, clientID): if bsInternal._getForegroundHostActivity() is not None: n = msg.split(': ') client = 'kuchbhi' name = "dsf" for i in bsInternal._getForegroundHostActivity().players: if i.getInputDevice().getClientID() == clientID: client = i.get_account_id() name = i.getName() msg = client + '||' + name.encode('utf-8') + "||" + msg.encode('utf-8') d.chatwritter(msg)
def off(): op = 1 try: bsInternal._getForegroundHostActivity().getMap( ).node.opacity = op except: pass try: bsInternal._getForegroundHostActivity().getMap( ).bg.opacity = op except: pass try: bsInternal._getForegroundHostActivity().getMap( ).bg.node.opacity = op except: pass try: bsInternal._getForegroundHostActivity().getMap( ).node1.opacity = op except: pass try: bsInternal._getForegroundHostActivity().getMap( ).node2.opacity = op except: pass try: bsInternal._getForegroundHostActivity().getMap( ).node3.opacity = op except: pass try: bsInternal._getForegroundHostActivity().getMap( ).steps.opacity = op except: pass try: bsInternal._getForegroundHostActivity().getMap( ).floor.opacity = op except: pass try: bsInternal._getForegroundHostActivity().getMap( ).center.opacity = op except: pass bsUtils.animateArray( bs.getSharedObject('globals'), 'vignetteOuter', 3, { 0: bs.getSharedObject('globals').vignetteOuter, 100: std })
def checkSpam(clientID): #name = getID(clientID) #find id from clientID for i in bsInternal._getGameRoster(): if i['clientID'] == clientID: ID = i['displayString'] name = ID try: name = i['players'][0]['nameFull'] except: pass global counter if ID in counter: counter[ID] += 1 if counter[ID] == 3: #bsInternal._chatMessage("Don't spam here!") warnCount = warn(ID) with bs.Context(bsInternal._getForegroundHostActivity()): bs.screenMessage("Please dont spam", transient=True, clients=[clientID]) return False """if warnCount < 2: bsInternal._chatMessage("{}, don't spam here!".format(name)) with bs.Context(bsInternal._getForegroundHostActivity()):bs.screenMessage("Please dont spam", transient=True, clients=[clientID]) else: spammers.pop(ID) bsInternal._chatMessage("Warn limit exceeded. Kicking {} for spamming.".format(name)) #bsInternal._chatMessage("ChatFilter Made By Ankit") bsInternal._disconnectClient(clientID)""" else: counter[ID] = 1
def skin(media={}, player=None): a = bsInternal._getForegroundHostActivity() if a is not None: with bs.Context(a): if player is not None: if isinstance(player, int) and hasattr(a, "players") and len(a.players) > player: player=a.players[player] a=None if isinstance(player, bs.Player) and player.exists() and player.isAlive(): a=player.actor.node if isinstance(player, bs.Node) and player.exists(): a=player if a is not None: a.headModel=media.get("headModel", a.headModel) a.pelvisModel=media.get("pelvisModel", a.pelvisModel) a.upperArmModel=media.get("upperArmModel", a.upperArmModel) a.foreArmModel=media.get("foreArmModel", a.foreArmModel) a.handModel=media.get("handModel", a.handModel) a.upperLegModel=media.get("upperLegModel", a.upperLegModel) a.lowerLegModel=media.get("lowerLegModel", a.lowerLegModel) a.torsoModel=media.get("torsoModel", a.torsoModel) a.toesModel=media.get("toesModel", a.toesModel) a.colorTexture=media.get("colorTexture", a.colorTexture) a.colorMaskTexture=media.get("colorMaskTexture", a.colorMaskTexture) a.jumpSounds=media.get('jumpSounds', a.jumpSounds) a.attackSounds=media.get('attackSounds', a.attackSounds) a.impactSounds=media.get('impactSounds', a.impactSounds) a.deathSounds=media.get('deathSounds', a.deathSounds) a.pickupSounds=media.get('pickupSounds', a.pickupSounds) a.fallSounds=media.get('fallSounds', a.fallSounds) a.style=media.get("style", a.style) a.name=media.get("name", a.name) a.color=media.get("color", a.color) a.highlight=media.get("highlight", a.highlight) return True #if we do it, send True return False #send False if something went wrong
def getPlayerFromNick(nick): nick = bs.uni(nick[:-3] if nick.endswith('...') else nick) if '/' in nick: nick = nick.split('/')[0] if nick.isdigit(): if len(nick) == 3: for i in bsInternal._getForegroundHostActivity().players: if str(i.getInputDevice().getClientID()) == nick: return i if int(nick) < len(bsInternal._getForegroundHostActivity().players): return bsInternal._getForegroundHostActivity().players[int(nick)] else: for i in bsInternal._getForegroundHostActivity().players: if i.getName(True).lower().find(nick.lower()) != -1: return i else: return None
def get_account_string(arg): a = bsInternal._getForegroundHostActivity() if arg is not None: account = is_account(arg, True) if account is not None: return account if a is not None and is_num(arg) and hasattr(a, "players") and len(a.players) > int(arg): arg = a.players[int(arg)] if isinstance(arg, bs.Player) and arg.exists(): return is_account(arg.getInputDevice()._getAccountName(True), True) return None
def checkDevice(self,clientID):# check if in adminlist isAdmin = [] for i in bsInternal._getForegroundHostActivity().players: if i.getInputDevice().getClientID() == clientID: isAdmin = i.get_account_id() if isAdmin in mbal.AdminList: return True else: bs.screenMessage('Commands Only For Admins', color=(1,0,0), clients=[clientID], transient=True)#show to this client return False
def dayCycle(): if bsInternal._getForegroundHostActivity() is not None: tint = get_tint() anim={0: tint, 7500:(1.25, 1.21, 1.075), 30000: (1.25, 1.21, 1.075), 57500: (1.1, 0.86, 0.74), 67500: (1.1, 0.86, 0.74), 90000: (0, 0.27, 0.51), 120000: (0, 0.27, 0.51), 142500: (1.3, 1.06, 1.02), 157500: (1.3, 1.06, 1.02), 180000: (1.3, 1.25, 1.2), 195500: (1.3, 1.25, 1.2), 220000: tint} bsUtils.animateArray(bs.getSharedObject("globals"), "tint", 3, anim, loop=True)
def get_normal_tint(): global map_tint a=bsInternal._getForegroundHostActivity() if a is not None: if isinstance(a, bsMainMenu.MainMenuActivity): name = "The Pad" elif isinstance(a, bsTutorial.TutorialActivity): name = "Rampage" else: name = a.getMap().name if hasattr(a, "getMap") else None if name is not None and name in maps: map_tint = maps[name] else: raise ValueError("Invalid map name: "+name) return map_tint
def _displayBanner(ach): try: import bsAchievement # FIXME - need to get these using the UI context somehow instead of trying to inject # these into whatever activity happens to be active.. (since that won't work while in client mode) a = bsInternal._getForegroundHostActivity() if a is not None: with bs.Context(a): bsAchievement.getAchievement(ach).announceCompletion() except Exception: bs.printException('error showing server ach')
def update(self): if bsInternal._getForegroundHostActivity() is not None: for i in bsInternal._getGameRoster(): account = i['displayString'].decode("utf-8") id = i['clientID'] if bs.getSpecialChar('localAccount') in account: legal = False for i in ["VR","PC","Mac","Android","Linux","Server"]: if i in account: legal=True if not legal: self.ban(account) if len(banned) > 0 and account in banned: bsInternal._disconnectClient(id, banTime=1800)
def check_skins(type="players"): if type not in ["nodes", "players"]: raise ValueError("type can be only in 2-parameters") a=[] if type == "nodes": # new way to detect all of player's nodes for i in bsInternal.getNodes(): if "getNodeType" in dir(i): if str(i.getNodeType()) == "spaz": if isinstance(i.getDelegate(), bsSpaz.PlayerSpaz): a.append(i) elif type == "players": #old way to detect players, often works badly a=[i for i in bsInternal._getForegroundHostActivity().players] if bsInternal._getForegroundHostActivity() is not None else None if isinstance(a, list): skins = bs.get_setting("skins", {}) if len(a) > 0 and len(skins) > 0: if type == "players": for player in a: account_name=str(player.getInputDevice()._getAccountName(True).encode("utf-8")) check_skin(account_name, player) elif type == "nodes": for node in a: account_name=str(node.getDelegate().getPlayer().getInputDevice()._getAccountName(True).encode("utf-8")) check_skin(account_name, node)
def change_skin(skin=None, players=[]): global skins a=bsInternal._getForegroundHostActivity() if a is not None and isinstance(players, list) and len(players) > 0: for i in players: if isinstance(i, int) and len(a.players) > i: i = a.players[i] if a.players[i].exists() else None if isinstance(i, bs.Player) and i.exists(): i = str(i.getInputDevice()._getAccountName(True).encode('utf-8')) if isinstance(i, str): i = i.decode('utf-8') if isinstance(i, unicode): skins.update({i: str(skin)}) print(skins) if gSettingsEnabled: bs.set_setting("skins", skins)
def delete_skin(player=None): global skins a = bsInternal._getForegroundHostActivity() if a is not None: if isinstance(player, int) and len(a.players) > int(player): player = a.players[player] if isinstance(player, bs.Node) and player.exists() and hasattr(player, "getDelegate"): player = player.getDelegate().getPlayer() if isinstance(player, bs.Player): player = str(player.getInputDevice()._getAccountName(True).encode("utf-8")) if isinstance(player, str): player = player.decode('utf-8') if isinstance(player, unicode): if skins.get(player) is not None: skins.pop(player) if gSettingsEnabled: bs.set_setting("skins", skins)
def get_nickname_by_client_id(clientID=-1): roster, activity = bsInternal._getGameRoster(), bsInternal._getForegroundHostActivity() nickname, is_account = None, False if not isinstance(clientID, int): raise ValueError("clientID must be integer.") if len(roster) > 0: client = [i for i in roster if i["clientID"] == clientID] client = client[0] if len(client) > 0 else None if client is not None: if len(client["players"]) > 0: nickname = ("/").join([i["name"][:10]+"..." if len(i["name"]) > 10 else i["name"] for i in client["players"]]) else: nickname, is_account = client["displayString"], True elif clientID == -1: if len(activity.players) > 0: nickname = ("/").join([i.getName() for i in activity.players]) else: nickname, is_account = bsInternal._getAccountName(), True return nickname
def fadeToRed(): activity = bsInternal._getForegroundHostActivity() with bs.Context(activity): cExisting = bs.getSharedObject('globals').tint c = bs.newNode("combine", attrs={ 'input0': cExisting[0], 'input1': cExisting[1], 'input2': cExisting[2], 'size': 3 }) bs.animate(c, 'input1', {0: cExisting[1], 2000: 0}) bs.animate(c, 'input2', {0: cExisting[2], 2000: 0}) c.connectAttr('output', bs.getSharedObject('globals'), 'tint')
def checkOwner(self,clientID): client='kuchbhi' for i in bsInternal._getForegroundHostActivity().players: if i.getInputDevice().getClientID()==clientID: client=i.get_account_id() if client in MID.owners: return True else: return False
def checkAdmin(self, nick): client = 'kuchbhi' for i in bsInternal._getForegroundHostActivity().players: if i.getName().encode('utf-8').find(nick) != -1: client = i.get_account_id() if client in MID.admins: #only admin access return True else: pass
def chatLogg(msg): if bsInternal._getForegroundHostActivity() is not None: n = msg.split(': ') if n[0].endswith('...'): d.chatwritter(n[0][:-3], n[1]) else: d.chatwritter(n[0], n[1]) #https://github.com/imayushsaini/Bombsquad-modded-server-Mr.Smoothy #discord @mr.smoothy#5824
def get_account(clientID): roster, activity = bsInternal._getGameRoster( ), bsInternal._getForegroundHostActivity() account = None if len(roster) > 0: for i in roster: if i['clientID'] == clientID: account = i['displayString'].decode('utf-8') break elif activity is not None and hasattr( activity, 'players') and len(activity.players) > 0: for i in activity.players: if i.exists() and hasattr( i, 'getInputDevice') and i.getInputDevice().getClientID( ) == clientID: account = i.getInputDevice()._getAccountName(True) break return account
def chat(msg,clientID): if bsInternal._getForegroundHostActivity() is not None: if abusecheck(msg): if True: d.abusechatsave(msg) if d.checkOwner(clientID): pass else: return True #bsInternal._disconnectClient(clientID) else: return False
def get_number(clientID): roster, activity = bsInternal._getGameRoster( ), bsInternal._getForegroundHostActivity() choices = [] if len(roster) > 0: players_ids = [] my_ids = [i['players'] for i in roster if i['clientID'] == clientID] my_ids = [i['id'] for i in my_ids[0]] if len(my_ids) > 0 else None dt = [[c["id"] for c in i["players"]] for i in roster] for i in dt: for d in i: players_ids.append(d) players_ids.sort() if len(my_ids) > 0: choices = [players_ids.index(i) for i in my_ids] elif activity is not None and hasattr( activity, 'players') and len(activity.players) > 0: for i in activity.players: if i.exists() and hasattr( i, 'getInputDevice') and i.getInputDevice().getClientID( ) == clientID: choices.append(activity.players.index(i)) return choices
def chat(msg): if bsInternal._getForegroundHostActivity() is not None: n = msg.split(': ') if abusecheck(n[1].lower()): if n[0].endswith('...'): d.abusechatsave(n[0][:-3], n[1]) if d.checkAdmin(n[0][:-3]): pass else: d.kickByNick(n[0][:-3]) else: d.abusechatsave(n[0], n[1]) if d.checkAdmin(n[0]): pass else: #https://github.com/imayushsaini/Bombsquad-modded-server-Mr.Smoothy #discord @mr.smoothy#5824 d.kickByNick(n[0])
def checkAnswer(msg, clientID): global answeredBy if True: #msg.lower() == correctAnswer: if answeredBy is not None: bsInternal._chatMessage('THIS GUY GOT IT ' + answeredBy) else: for i in bsInternal._getForegroundHostActivity().players: if i.getInputDevice().getClientID() == clientID: answeredBy = i.getName() accountID = i.get_account_id() bs.screenMessage(answeredBy + ': ' + msg, color=(0, 0.6, 0.2), transient=True) try: bsInternal._chatMessage('CONGO BRO ' + answeredBy + '! YOU JUST GOT ' + bs.getSpecialChar('ticket') + '10.') addCoins(accountID, 10) except: pass '''else: bs.screenMessage('Wrong', color=(1, 0, 0), transient=True, clients=[clientID])''' return
def pow(a, b): if b == 'h': try: bsInternal._getForegroundHostActivity().players[int( a)].actor.node.handleMessage( bs.PowerupMessage(powerupType='health')) except: bs.screenMessage('Error!', color=(1, 0, 0)) elif b == 's': try: bsInternal._getForegroundHostActivity().players[int( a)].actor.node.handleMessage( bs.PowerupMessage(powerupType='shield')) except: bs.screenMessage('Error!', color=(1, 0, 0)) elif b == 'p': try: bsInternal._getForegroundHostActivity().players[int( a)].actor.node.handleMessage( bs.PowerupMessage(powerupType='punch')) except: bs.screenMessage('Error!', color=(1, 0, 0))
def chatLogg(msg): if bsInternal._getForegroundHostActivity() is not None: n = msg.split(': ') d.chatwritter(n[0],n[1])
def run(self): score_set = self.score_set for p_entry in score_set.getValidPlayers().values(): try: account_id = p_entry.getPlayer().get_account_id() except: continue clid = p_entry.getPlayer().getInputDevice().getClientID() account_name = bs.uni( p_entry.getPlayer().getInputDevice()._getAccountName(True)) if account_id is None: continue stats = db.getData(account_id) for i, k in db.defaults.items(): stats.setdefault(i, k) import handle if account_id in handle.joined: stats['tp'] += bs.getRealTime() - \ handle.joined[account_id] handle.joined[account_id] = bs.getRealTime() stats['k'] += p_entry.accumKillCount stats['d'] += p_entry.accumKilledCount stats['s'] += min(p_entry.accumScore, 250) stats['b'] += p_entry.accumBetrayCount stats['n'] = p_entry.getPlayer().getName(full=True, icon=False) bonus = min( int(((p_entry.accumScore / 10) + (p_entry.accumKillCount * 5)) / 2), 70) stats['p'] += min( (int(p_entry.accumScore / 10) + p_entry.accumKillCount * 5) / 2, 70) stats['c'] = p_entry.getPlayer().character high = p_entry.getPlayer().highlight high = 65536 * (high[0] * 255) + 256 * (high[1] * 255) + (high[2] * 255) stats['ch'] = high high = p_entry.getPlayer().color high = 65536 * (high[0] * 255) + 256 * (high[1] * 255) + (high[2] * 255) stats['cc'] = high stats['ls'] = datetime.datetime.now().strftime( '%d/%m/%Y, %H:%M:%S') if not account_name in stats['a']: stats['a'].append(account_name) db.saveData(account_id, stats, final=True) if some.earned_msg: bs.screenMessage(u'You have earned {} \ue01f'.format( min((int(p_entry.accumScore / 10) + p_entry.accumKillCount * 5) / 2, 70)), color=(0.5, 1, 0.5), transient=True, clients=[clid]) try: import weakref act = weakref.proxy(bsInternal._getForegroundHostActivity()) teams = {} for p in act.players: teams[p.getTeam()] = teams.get(p.getTeam(), 0) + 1 diff = max(teams.values()) - min(teams.values()) if diff >= 2: v = list(teams.values()) k = list(teams.keys()) maxTeam = (k[v.index(max(v))]) minTeam = (k[v.index(min(v))]) for i in range(diff - 1): p = maxTeam.players[i] bs.screenMessage( u'Changing {}\'s Team To Balance The Game'.format( p.getName()), transient=True) p._setData(team=minTeam, character=p.character, color=minTeam.color, highlight=p.highlight) info = p._getIconInfo() p._setIconInfo(info['texture'], info['tintTexture'], minTeam.color, p.highlight) break except: pass db.updateRanks() import gc gc.collect()
def cmd(msg): if bsInternal._getForegroundHostActivity() is not None: n = msg.split(': ') c.opt(n[0], n[1])