def list(): for s in bsInternal._getForegroundHostSession().players: print(s.getName() + " " + str(bsInternal._getForegroundHostSession().players.index(s))) for i in bsInternal._getGameRoster(): try: print(i['players'][0]['nameFull'] + " (/kick " + str(i['clientID']) + ")") except: pass
def _onPartyMemberPress(self, clientID, isHost, widget): # if we're the host, pop up 'kick' options for all non-host members if bsInternal._getForegroundHostSession() is not None: kickStr = bs.Lstr(resource='kickText') else: # kick-votes appeared in build 14248 if bsInternal._getConnectionToHostInfo().get('buildNumber', 0) < 14248: return kickStr = bs.Lstr(resource='kickVoteText') p = bsUI.PopupMenuWindow( position=widget.getScreenSpaceCenter(), scale=2.3 if bsUI.gSmallUI else 1.65 if bsUI.gMedUI else 1.23, choices=[ 'kickOrg', "kick", "remove", "kill", "ban", "unban", "amnesty", "knock", "curse", "heal", "shield", "punch", "freeze", "thaw", "headless", "celebrate", "list", "headlessall", "healall", "shieldall", "punchall", "killall", "knockall", "freezeall", "thawall", "curseall", "celebrateall", "slow", "camera", "end", "help" ], choicesDisplay=[ kickStr, "Kick", "Remove", "Kill", "Ban", "Unban", "Amnesty", "Knock", "Curse", "Heal", "Shield", "Punch", "Freeze", "Thaw", "Headless", "Celebrate", "List", "HeadlessAll", "HealAll", "ShieldAll", "PunchAll", "KillAll", "KnockAll", "FreezeAll", "ThawAll", "CurseAll", "CelebrateAll", "Slow", "Camera", "End", "Help" ], currentChoice='kickOrg', delegate=self).getRootWidget() self._popupType = 'partyMemberPress' self._popupPartyMemberClientID = clientID self._popupPartyMemberIsHost = isHost
def _onPartyMemberPress(self, clientID, isHost, widget): # THANKS TO DEVA if bsInternal._getForegroundHostSession() is not None: kickStr = bs.Lstr(resource='kickText') else: # kick-votes appeared in build 14248 if bsInternal._getConnectionToHostInfo().get('buildNumber', 0) < 14248: return kickStr = bs.Lstr(resource='kickVoteText') for rst in self._roster: cid = rst['clientID'] if cid == clientID: bs.screenMessage(rst['displayString']) x = rst['clientID'] bs.screenMessage(str(x)) break p = PopupMenuWindow( position=widget.getScreenSpaceCenter(), scale=2.3 if gSmallUI else 1.65 if gMedUI else 1.23, choices=['kick'], choicesDisplay=[kickStr], currentChoice='kick', delegate=self).getRootWidget() self._popupType = 'partyMemberPress' self._popupPartyMemberClientID = clientID self._popupPartyMemberIsHost = isHost
def _onPartyMemberPress(self, clientID, isHost, widget): # if we're the host, pop up 'kick' options for all non-host members if bsInternal._getForegroundHostSession() is not None: kickHost = True else: # kick-votes appeared in build 14248 if bsInternal._getConnectionToHostInfo().get('buildNumber', 0) < 14248: return kickHost = False if bs.getLanguage() == 'Russian': choicesList = [ 'Изгнать' if kickHost else 'Голосовать за вылет', 'Вылет без голосования', 'Убрать из игры', 'Полет', 'Новый полет', 'Вылечить', 'Усыпить', 'Разморозить', 'Превратить в коробку', 'Радужный скин', 'Профиль аккаунта' ] else: choicesList = [ 'Kick' if kickHost else 'Vote to Kick', 'Departure without a vote', 'Remove from game', 'Fly', 'New fly', 'Cure', 'Put to sleep', 'Defrost', 'Turn into box', 'Rainbow skin', 'Account profile' ] bsUI.PopupMenuWindow( position=widget.getScreenSpaceCenter(), scale=2.3 if bsUI.gSmallUI else 1.65 if bsUI.gMedUI else 1.23, choices=choicesList, currentChoice='kick', delegate=self) self._popupType = 'partyMemberPress' self._popupPartyMemberClientID = clientID self._popupPartyMemberIsHost = isHost
def checkDevice(self, nick): # check if in adminlist client_str = [] for i in bsInternal._getForegroundHostSession( ).players: #FIXME when player's nick contain lots of emoticon It's break equality!!! if (i.getName()).encode( 'utf-8' ) == nick: # use i.getName(True) <-- if u need fullname client_str = i.get_account_id() if client_str in mbal.AdminList: return True else: bsInternal._chatMessage("Commands Only For Admins") return False
def checkDevice(self, nick): # check if in adminlist client_str = [] for i in bsInternal._getForegroundHostSession( ).players: #FIXME "unicode characters lenght" !!! if i.getName().encode( 'utf-8' ) == nick: # use i.getName(True) <-- if u need fullname client_str = i.get_account_id() if client_str in mbal.AdminList: return True else: #bsInternal._chatMessage("Commands Only For Admins") return False
def newMethod(self, *args, **kwargs): oldMethod(self, *args, **kwargs) width = -130 height = -22.5 if gSmallUI else -54.5 if gMedUI else -79 size = (94.5, 85) if gSmallUI else (91, 81) if gMedUI else (90, 80) global delayChecker if not delayChecker: delay = 1900 delayChecker = True else: delay = 0 self._inGame = not isinstance(bsInternal._getForegroundHostSession(), bsMainMenu.MainMenuSession) if not self._inGame: self._MythBServerButton = b = bs.buttonWidget( parent=self._rootWidget, position=(width, height), color=(0.356, 0.760, 0.905), size=size, transitionDelay=delay, textScale=1.0, textColor=(1, 1, 1), buttonType='square', texture=bs.getTexture('buttonSquare'), label='', onActivateCall=_doServerStatusWindow) bs.textWidget(parent=self._rootWidget, position=(width + 20, height + 6.5), scale=0.75, drawController=b, transitionDelay=delay, color=(0.75, 1.0, 0.7), maxWidth=width * 0.33, text='MythB.', hAlign='center', vAlign='center') iconSize = -width * 0.38 bs.imageWidget(parent=self._rootWidget, size=(iconSize, iconSize), transitionDelay=delay, color=(1.2, 0.843, 0), position=(width + 20, height + 27), drawController=b, texture=bs.getTexture('star'))
def _onPartyMemberPress(self, clientID, isHost, widget): if bsInternal._getForegroundHostSession() is not None: choicesDisplay = [bs.Lstr(resource='kickText')] else: if bsInternal._getConnectionToHostInfo().get('buildNumber', 0) < 14248: return choicesDisplay = [bs.Lstr(resource='kickVoteText')] choices = ['kick'] + commands for i in commands: choicesDisplay.append(bs.Lstr(value=i)) self.popupMenuPosition = widget.getScreenSpaceCenter() bsUI.PopupMenuWindow( position=self.popupMenuPosition, scale=2.3 if bsUI.gSmallUI else 1.65 if bsUI.gMedUI else 1.23, choices=choices, choicesDisplay=choicesDisplay, currentChoice=None, color=gPopupWindowColor, delegate=self) self._popupType = 'commands' self._popupPartyMemberClientID = clientID self._popupPartyMemberIsHost = isHost
def stats_shower(): global num global scr p_list = [] n_list = [] s_list = [] s_itr = iter(s_list) for i in bsInternal._getForegroundHostSession().players: Name = i.getName() n_list.append(Name) pb_id = i.get_account_id() p_list.append(pb_id) f = open( bs.getEnvironment()['systemScriptsDirectory'] + "/pStats.json", "r") stats = json.loads(f.read()) for p in range(int(len(p_list))): if p_list[p] in stats: player_stat = stats[str(p_list[p])] s_msg = str(n_list[p].encode( "utf-8")) + "'s Stats This Season:\n" + "Rank " + str( player_stat["rank"]) + ", " + str( player_stat["scores"]) + " scores, " + str( player_stat["kills"]) + " kills, " + str( player_stat["deaths"]) + " deaths." s_list.append(s_msg) else: s_msg = str((n_list[p].encode("utf-8"))) + "Is not Registered" s_list.append(s_msg) t = bs.newNode('text', attrs={ 'text': s_list[num], 'scale': 1.0, 'maxWidth': 0, 'position': (250, 650), 'shadow': 0.5, 'flatness': 1.0, 'color': ((0 + random.random() * 1.0), (0 + random.random() * 1.0), (0 + random.random() * 1.0)), 'hAlign': 'center', 'vAttach': 'bottom' }) bs.animate(t, 'opacity', {0: 0.0, 500: 1.0, 6500: 1.0, 7000: 0.0}) bs.gameTimer(7000, t.delete) p = bs.newNode('text', attrs={ 'text': cmdsetg.credit, 'scale': 1.0, 'maxWidth': 0, 'position': (-100, 50), 'shadow': 0.5, 'flatness': 1.0, 'color': ((0 + random.random() * 1.0), (0 + random.random() * 1.0), (0 + random.random() * 1.0)), 'hAlign': 'center', 'vAttach': 'bottom' }) bs.animate(p, 'opacity', {0: 0.0, 500: 1.0, 6500: 1.0, 7000: 0.0}) bs.gameTimer(7000, p.delete) if num < len(s_list): num += 1 if num == len(s_list): num *= 0 if num > len(s_list): num *= 0
def opt(self, nick, msg): if self.checkDevice(nick): m = msg.split(' ')[0] # command a = msg.split(' ', 1)[1:] # arguments activity = bsInternal._getForegroundHostActivity() with bs.Context(activity): if m == '/kick': #just remove from the game if a == []: bsInternal._chatMessage("MUST USE KICK ID") else: try: kickedPlayerID = int(a[0]) except Exception: bsInternal._chatMessage("PLAYER NOT FOUND") else: if not kickedPlayerID == -1: bsInternal._disconnectClient(kickedPlayerID) bsInternal._chatMessage( bs.getSpecialChar('logoFlat')) else: bsInternal._chatMessage("CANT KICK HOST") elif m == '/list': #list of current players id bsInternal._chatMessage( "==========PLAYER KICK IDS==========") for i in bsInternal._getGameRoster(): try: bsInternal._chatMessage( i['players'][0]['nameFull'] + " kick ID " + str(i['clientID'])) except Exception: pass bsInternal._chatMessage( "==========PLAYER IDS=============") for s in bsInternal._getForegroundHostSession().players: bsInternal._chatMessage( s.getName() + " ID = " + str(bsInternal._getForegroundHostSession().players. index(s))) elif m == '/ban': # add id to banlist=autokick list if a == []: bsInternal._chatMessage( "MUST USE PLAYER ID OR NICK" ) #also FIX this every time bsInternal ChatMessage thing!! for stop loops "update-FIXED" else: #firstly try nick if nick len is more then 2 else try as player id FIX ME if len(a[0]) > 2: for i in bs.getActivity().players: try: if (i.getName()).encode('utf-8') == (a[0]): bannedClient = i.getInputDevice( ).getClientID() bannedName = i.getName().encode( 'utf-8') bannedPlayerID = i.get_account_id() foolist = [] foolist = mbal.autoKickList if bannedPlayerID not in foolist: foolist.append(bannedPlayerID) bsInternal._chatMessage( str(bannedName) + " Banned") i.removeFromGame() else: bsInternal._chatMessage( str(bannedName) + " Already Banned") with open( bs.getEnvironment() ['systemScriptsDirectory'] + "/MythBAdminList.py") as file: s = [row for row in file] s[7] = 'autoKickList = ' + str( foolist) + '\n' f = open( bs.getEnvironment() ['systemScriptsDirectory'] + "/MythBAdminList.py", 'w') for i in s: f.write(i) f.close() reload(mbal) except Exception: pass bsInternal._chatMessage( bs.getSpecialChar('logoFlat')) else: try: bannedClient = bsInternal._getForegroundHostSession( ).players[int(a[0])] except Exception: bsInternal._chatMessage("PLAYER NOT FOUND") else: foolist = [] foolist = mbal.autoKickList bannedPlayerID = bannedClient.get_account_id() if bannedPlayerID not in foolist: foolist.append(bannedPlayerID) bsInternal._chatMessage( str(bannedClient) + " Banned") bannedClient.removeFromGame() else: bsInternal._chatMessage( str(bannedClient) + " Already Banned") with open(bs.getEnvironment() ['systemScriptsDirectory'] + "/MythBAdminList.py") as file: s = [row for row in file] s[7] = 'autoKickList = ' + str( foolist) + '\n' f = open( bs.getEnvironment() ['systemScriptsDirectory'] + "/MythBAdminList.py", 'w') for i in s: f.write(i) f.close() reload(mbal) elif m == '/unban': # remove id from banlist=autokick list if a == []: bsInternal._chatMessage("MUST USE PLAYER ID OR NICK") else: if len(a[0]) > 2: for i in bs.getActivity().players: try: if (i.getName()).encode('utf-8') == (a[0]): bannedClient = i.getInputDevice( ).getClientID() bannedName = i.getName().encode( 'utf-8') bannedPlayerID = i.get_account_id() foolist = [] foolist = mbal.autoKickList if bannedPlayerID in foolist: foolist.remove(bannedPlayerID) bsInternal._chatMessage( str(bannedName) + " be free now!") else: bsInternal._chatMessage( str(bannedName) + " Already Not Banned") with open( bs.getEnvironment() ['systemScriptsDirectory'] + "/MythBAdminList.py") as file: s = [row for row in file] s[7] = 'autoKickList = ' + str( foolist) + '\n' f = open( bs.getEnvironment() ['systemScriptsDirectory'] + "/MythBAdminList.py", 'w') for i in s: f.write(i) f.close() reload(mbal) except Exception: pass bsInternal._chatMessage( bs.getSpecialChar('logoFlat')) else: try: bannedClient = bsInternal._getForegroundHostSession( ).players[int(a[0])] except Exception: bsInternal._chatMessage("PLAYER NOT FOUND") else: foolist = [] foolist = mbal.autoKickList bannedPlayerID = bannedClient.get_account_id() if bannedPlayerID in foolist: foolist.remove(bannedPlayerID) bsInternal._chatMessage( str(bannedClient) + " be free now!") else: bsInternal._chatMessage( str(bannedClient) + " Already Not Banned") with open(bs.getEnvironment() ['systemScriptsDirectory'] + "/MythBAdminList.py") as file: s = [row for row in file] s[7] = 'autoKickList = ' + str( foolist) + '\n' f = open( bs.getEnvironment() ['systemScriptsDirectory'] + "/MythBAdminList.py", 'w') for i in s: f.write(i) f.close() reload(mbal) elif m == '/amnesty': # reset blacklist foolist = [] bsInternal._chatMessage( "==========FREEDOM TO ALL==========") bsInternal._chatMessage( "=========BLACKLİST WIPED=========") with open(bs.getEnvironment()['systemScriptsDirectory'] + "/MythBAdminList.py") as file: s = [row for row in file] s[7] = 'autoKickList = ' + str(foolist) + '\n' f = open( bs.getEnvironment()['systemScriptsDirectory'] + "/MythBAdminList.py", 'w') for i in s: f.write(i) f.close() reload(mbal) elif m == '/camera': #change camera mode bsInternal._chatMessage(bs.getSpecialChar('logoFlat')) try: if bs.getSharedObject( 'globals').cameraMode == 'follow': bs.getSharedObject('globals').cameraMode = 'rotate' else: bs.getSharedObject('globals').cameraMode = 'follow' except Exception: bsInternal._chatMessage('AN ERROR OCCURED') elif m == '/maxplayers': #set maxplayers limit if a == []: bsInternal._chatMessage('MUST USE NUMBERS') else: try: bsInternal._getForegroundHostSession( )._maxPlayers = int(a[0]) bsInternal._setPublicPartyMaxSize(int(a[0])) bsInternal._chatMessage('MaxPlayers = ' + str(int(a[0]))) except Exception: bsInternal._chatMessage('AN ERROR OCCURED') elif m == '/help': #show help bsInternal._chatMessage( "=====================COMMANDS=====================") bsInternal._chatMessage( "list-kick-remove-ban-unban-amnesty-kill-curse-end-heal" ) bsInternal._chatMessage( "freeze-thaw-headless-shield-punch-maxplayers-headlessall" ) bsInternal._chatMessage( "killall-freezeall-shieldall-punchall-camera-slow") elif m == '/remove': #remove from game if a == []: bsInternal._chatMessage('MUST USE PLAYER ID OR NICK') else: if len(a[0]) > 2: for i in bs.getActivity().players: try: if (i.getName()).encode('utf-8') == (a[0]): i.removeFromGame() except Exception: pass bsInternal._chatMessage( bs.getSpecialChar('logoFlat')) else: try: bs.getActivity().players[int( a[0])].removeFromGame() bsInternal._chatMessage( bs.getSpecialChar('logoFlat')) except Exception: bsInternal._chatMessage('PLAYER NOT FOUND') elif m == '/curse': #curse if a == []: bsInternal._chatMessage('MUST USE PLAYER ID OR NICK') else: if len(a[0]) > 2: for i in bs.getActivity().players: try: if (i.getName()).encode('utf-8') == (a[0]): if i.actor.exists(): i.actor.curse() except Exception: pass bsInternal._chatMessage( bs.getSpecialChar('logoFlat')) else: try: bs.getActivity().players[int( a[0])].actor.curse() bsInternal._chatMessage( bs.getSpecialChar('logoFlat')) except Exception: bsInternal._chatMessage('PLAYER NOT FOUND') elif m == '/curseall': #curse all for i in bs.getActivity().players: try: if i.actor.exists(): i.actor.curse() except Exception: pass bsInternal._chatMessage(bs.getSpecialChar('logoFlat')) elif m == '/kill': #kill if a == []: bsInternal._chatMessage('MUST USE PLAYER ID OR NICK') else: if len(a[0]) > 2: for i in bs.getActivity().players: try: if (i.getName()).encode('utf-8') == (a[0]): if i.actor.exists(): i.actor.node.handleMessage( bs.DieMessage()) except Exception: pass bsInternal._chatMessage( bs.getSpecialChar('logoFlat')) else: try: bs.getActivity().players[int( a[0])].actor.node.handleMessage( bs.DieMessage()) bsInternal._chatMessage( bs.getSpecialChar('logoFlat')) except Exception: bsInternal._chatMessage('PLAYER NOT FOUND') elif m == '/killall': #kill all for i in bs.getActivity().players: try: if i.actor.exists(): i.actor.node.handleMessage(bs.DieMessage()) except Exception: pass bsInternal._chatMessage(bs.getSpecialChar('logoFlat')) elif m == '/freeze': #freeze if a == []: bsInternal._chatMessage('MUST USE PLAYER ID OR NICK') else: if len(a[0]) > 2: for i in bs.getActivity().players: try: if (i.getName()).encode('utf-8') == (a[0]): if i.actor.exists(): i.actor.node.handleMessage( bs.FreezeMessage()) except Exception: pass bsInternal._chatMessage( bs.getSpecialChar('logoFlat')) else: try: bs.getActivity().players[int( a[0])].actor.node.handleMessage( bs.FreezeMessage()) bsInternal._chatMessage( bs.getSpecialChar('logoFlat')) except Exception: bsInternal._chatMessage('PLAYER NOT FOUND') elif m == '/freezeall': #freeze all for i in bs.getActivity().players: try: if i.actor.exists(): i.actor.node.handleMessage(bs.FreezeMessage()) except Exception: pass bsInternal._chatMessage(bs.getSpecialChar('logoFlat')) elif m == '/thaw': #thaw if a == []: bsInternal._chatMessage('MUST USE PLAYER ID OR NICK') else: if len(a[0]) > 2: for i in bs.getActivity().players: try: if (i.getName()).encode('utf-8') == (a[0]): if i.actor.exists(): i.actor.node.handleMessage( bs.ThawMessage()) except Exception: pass bsInternal._chatMessage( bs.getSpecialChar('logoFlat')) else: try: bs.getActivity().players[int( a[0])].actor.node.handleMessage( bs.ThawMessage()) bsInternal._chatMessage( bs.getSpecialChar('logoFlat')) except Exception: bsInternal._chatMessage('PLAYER NOT FOUND') elif m == '/thawall': #thaw all for i in bs.getActivity().players: try: if i.actor.exists(): i.actor.node.handleMessage(bs.ThawMessage()) except Exception: pass bsInternal._chatMessage(bs.getSpecialChar('logoFlat')) elif m == '/headless': #headless if a == []: bsInternal._chatMessage('MUST USE PLAYER ID OR NICK') else: if len(a[0]) > 2: for i in bs.getActivity().players: try: if (i.getName()).encode('utf-8') == (a[0]): if i.actor.exists(): i.actor.node.headModel = None i.actor.node.style = "cyborg" except Exception: pass bsInternal._chatMessage( bs.getSpecialChar('logoFlat')) else: try: bs.getActivity().players[int( a[0])].actor.node.headModel = None bs.getActivity().players[int( a[0])].actor.node.style = "cyborg" bsInternal._chatMessage( bs.getSpecialChar('logoFlat')) except Exception: bsInternal._chatMessage('PLAYER NOT FOUND') elif m == '/headlessall': #headless all for i in bs.getActivity().players: try: if i.actor.exists(): i.actor.node.headModel = None i.actor.node.style = "cyborg" except Exception: pass bsInternal._chatMessage(bs.getSpecialChar('logoFlat')) elif m == '/heal': #heal if a == []: bsInternal._chatMessage('MUST USE PLAYER ID OR NICK') else: if len(a[0]) > 2: for i in bs.getActivity().players: try: if (i.getName()).encode('utf-8') == (a[0]): if i.actor.exists(): i.actor.node.handleMessage( bs.PowerupMessage( powerupType='health')) except Exception: pass bsInternal._chatMessage( bs.getSpecialChar('logoFlat')) else: try: bs.getActivity().players[int( a[0])].actor.node.handleMessage( bs.PowerupMessage( powerupType='health')) bsInternal._chatMessage( bs.getSpecialChar('logoFlat')) except Exception: bsInternal._chatMessage('PLAYER NOT FOUND') elif m == '/healall': #heal all for i in bs.getActivity().players: try: if i.actor.exists(): i.actor.node.handleMessage( bs.PowerupMessage(powerupType='health')) except Exception: pass bsInternal._chatMessage(bs.getSpecialChar('logoFlat')) elif m == '/shield': #shield if a == []: bsInternal._chatMessage('MUST USE PLAYER ID OR NICK') else: if len(a[0]) > 2: for i in bs.getActivity().players: try: if (i.getName()).encode('utf-8') == (a[0]): if i.actor.exists(): i.actor.node.handleMessage( bs.PowerupMessage( powerupType='shield')) except Exception: pass bsInternal._chatMessage( bs.getSpecialChar('logoFlat')) else: try: bs.getActivity().players[int( a[0])].actor.node.handleMessage( bs.PowerupMessage( powerupType='shield')) bsInternal._chatMessage( bs.getSpecialChar('logoFlat')) except Exception: bsInternal._chatMessage('PLAYER NOT FOUND') elif m == '/shieldall': #shield all for i in bs.getActivity().players: try: if i.actor.exists(): i.actor.node.handleMessage( bs.PowerupMessage(powerupType='shield')) except Exception: pass bsInternal._chatMessage(bs.getSpecialChar('logoFlat')) elif m == '/punch': #punch if a == []: bsInternal._chatMessage('MUST USE PLAYER ID OR NICK') else: if len(a[0]) > 2: for i in bs.getActivity().players: try: if (i.getName()).encode('utf-8') == (a[0]): if i.actor.exists(): i.actor.node.handleMessage( bs.PowerupMessage( powerupType='punch')) except Exception: pass bsInternal._chatMessage( bs.getSpecialChar('logoFlat')) else: try: bs.getActivity().players[int( a[0])].actor.node.handleMessage( bs.PowerupMessage(powerupType='punch')) bsInternal._chatMessage( bs.getSpecialChar('logoFlat')) except Exception: bsInternal._chatMessage('PLAYER NOT FOUND') elif m == '/punchall': #punch all for i in bs.getActivity().players: try: if i.actor.exists(): i.actor.node.handleMessage( bs.PowerupMessage(powerupType='punch')) except Exception: pass bsInternal._chatMessage(bs.getSpecialChar('logoFlat')) elif m == '/knock': #knock him if a == []: bsInternal._chatMessage('MUST USE PLAYER ID OR NICK') else: if len(a[0]) > 2: for i in bs.getActivity().players: try: if (i.getName()).encode('utf-8') == (a[0]): if i.actor.exists(): i.actor.node.handleMessage( "knockout", 5000) except Exception: pass bsInternal._chatMessage( bs.getSpecialChar('logoFlat')) else: try: bs.getActivity().players[int( a[0])].actor.node.handleMessage( "knockout", 5000) bsInternal._chatMessage( bs.getSpecialChar('logoFlat')) except Exception: bsInternal._chatMessage('PLAYER NOT FOUND') elif m == '/knockall': #knock all for i in bs.getActivity().players: try: if i.actor.exists(): i.actor.node.handleMessage("knockout", 5000) except Exception: pass bsInternal._chatMessage(bs.getSpecialChar('logoFlat')) elif m == '/celebrate': #celebrate him if a == []: bsInternal._chatMessage('MUST USE PLAYER ID OR NICK') else: if len(a[0]) > 2: for i in bs.getActivity().players: try: if (i.getName()).encode('utf-8') == (a[0]): if i.actor.exists(): i.actor.node.handleMessage( 'celebrate', 30000) except Exception: pass bsInternal._chatMessage( bs.getSpecialChar('logoFlat')) else: try: bs.getActivity().players[int( a[0])].actor.node.handleMessage( 'celebrate', 30000) bsInternal._chatMessage( bs.getSpecialChar('logoFlat')) except Exception: bsInternal._chatMessage('PLAYER NOT FOUND') elif m == '/celebrateall': #celebrate for i in bs.getActivity().players: try: if i.actor.exists(): i.actor.node.handleMessage('celebrate', 30000) except Exception: pass bsInternal._chatMessage(bs.getSpecialChar('logoFlat')) elif m == '/slow': # slow-mo bsInternal._chatMessage(bs.getSpecialChar('logoFlat')) try: if bs.getSharedObject('globals').slowMotion == True: bs.getSharedObject('globals').slowMotion = False else: bs.getSharedObject('globals').slowMotion = True except Exception: bsInternal._chatMessage('AN ERROR OCCURED') elif m == '/end': # just end game try: bsInternal._getForegroundHostActivity().endGame() bsInternal._chatMessage('THE END') except Exception: bsInternal._chatMessage('AN ERROR OCCURED')
def opt(self, nick, msg): if self.checkDevice(nick): m = msg.split(' ')[0] # command a = msg.split(' ')[1:] # arguments activity = bsInternal._getForegroundHostActivity() with bs.Context(activity): if m == '/kick': if a == []: bsInternal._chatMessage( 'Using: /kick name or clientID') else: if len(a[0]) > 3: self.kickByNick(a[0]) bsInternal._chatMessage('Player Kicked By Admin') else: try: s = int(a[0]) bsInternal._chatMessage( 'Player Kicked By Admin') bsInternal._disconnectClient(int(a[0])) except: self.kickByNick(a[0]) elif m == '/admin': clID = int(a[0]) for client in bsInternal._getGameRoster(): if client['clientID'] == clID: if a[1] == 'add': newadmin = client['displayString'] updated_admins = gph.adminHashes.append( newadmin) elif a[1] == 'remove': newadmin = client['displayString'] if newadmin in gph.adminHashes: updated_admins = gph.adminHashes.remove( newadmin) with open(bs.getEnvironment()['systemScriptsDirectory'] + "/getPermissionsHashes.py") as file: s = [row for row in file] s[0] = 'vipHashes = []' + '\n' s[1] = 'adminHashes = ' + updated_admins + '\n' f = open( bs.getEnvironment()['systemScriptsDirectory'] + "/getPermissionsHashes.py", 'w') for i in s: f.write(i) f.close() elif m == '/ban': clID = int(a[0]) for client in bsInternal._getGameRoster(): if client['clientID'] == clID: if a[1] == 'add': ban = client['displayString'] updated_ban = gph.ban.append(ban) bs.screenMessage('Banning...') elif a[1] == 'remove': ban = client['displayString'] if ban in gph.ban: updated_ban = gph.ban.remove(ban) with open(bs.getEnvironment()['systemScriptsDirectory'] + "/getPermissionsHashes.py") as file: s = [row for row in file] s[0] = 'vipHashes = []' + '\n' s[1] = 'admin = []' + '\n' s[2] = 'ass = []' + '\n' s[3] = 'ban = ' + updated_ban + '\n' f = open( bs.getEnvironment()['systemScriptsDirectory'] + "/getPermissionsHashes.py", 'w') for i in s: f.write(i) f.close() elif m == '/ass': clID = int(a[0]) for client in bsInternal._getGameRoster(): if client['clientID'] == clID: if a[1] == 'add': ass = client['displayString'] updated_ass = gph.ass.append(ass) elif a[1] == 'remove': ass = client['displayString'] if ass in gph.ass: updated_ass = gph.ass.remove(ass) with open(bs.getEnvironment()['systemScriptsDirectory'] + "/getPermissionsHashes.py") as file: s = [row for row in file] s[0] = 'vipHashes = []' + '\n' s[1] = 'admin= []' + '\n' s[2] = 'ass = ' + updated_admins + '\n' f = open( bs.getEnvironment()['systemScriptsDirectory'] + "/getPermissionsHashes.py", 'w') for i in s: f.write(i) f.close() elif m == '/vip': clID = int(a[0]) for client in bsInternal._getGameRoster(): if client['clientID'] == clID: if a[1] == 'add': vip = client['displayString'] updated_vip = gph.vip.append(vip) elif a[1] == 'remove': vip = client['displayString'] if vip in gph.vip: updated_vip = gph.vip.remove(vip) with open(bs.getEnvironment()['systemScriptsDirectory'] + "/getPermissionsHashes.py") as file: s = [row for row in file] s[0] = 'vip = ' + updated_admins + '\n' f = open( bs.getEnvironment()['systemScriptsDirectory'] + "/getPermissionsHashes.py", 'w') for i in s: f.write(i) f.close() elif m == '/list': bsInternal._chatMessage( "======== FOR /kick ONLY: ========") for i in bsInternal._getGameRoster(): try: bsInternal._chatMessage( i['players'][0]['nameFull'] + " (/kick " + str(i['clientID']) + ")") except: pass bsInternal._chatMessage( "==================================") bsInternal._chatMessage( "======= For other commands: =======") for s in bsInternal._getForegroundHostSession().players: bsInternal._chatMessage( s.getName() + " " + str(bsInternal._getForegroundHostSession( ).players.index(s))) elif m == '/ooh': if a is not None and len(a) > 0: s = int(a[0]) def oohRecurce(c): bs.playSound(bs.getSound('ooh'), volume=2) c -= 1 if c > 0: bs.gameTimer( int(a[1]) if len(a) > 1 and a[1] is not None else 1000, bs.Call(oohRecurce, c=c)) oohRecurce(c=s) else: bs.playSound(bs.getSound('ooh'), volume=2) elif m == '/playSound': if a is not None and len(a) > 1: s = int(a[1]) def oohRecurce(c): bs.playSound(bs.getSound(str(a[0])), volume=2) c -= 1 if c > 0: bs.gameTimer( int(a[2]) if len(a) > 2 and a[2] is not None else 1000, bs.Call(oohRecurce, c=c)) oohRecurce(c=s) else: bs.playSound(bs.getSound(str(a[0])), volume=2) elif m == '/quit': bsInternal.quit() elif m == '/nv': if self.tint is None: self.tint = bs.getSharedObject('globals').tint bs.getSharedObject('globals').tint = ( 0.5, 0.7, 1) if a == [] or not a[0] == u'off' else self.tint elif m == '/freeze': if a == []: bsInternal._chatMessage( 'Using: /freeze all or number of list') else: if a[0] == 'all': for i in bs.getSession().players: try: i.actor.node.handleMessage( bs.FreezeMessage()) except: pass else: bs.getSession().players[int( a[0])].actor.node.handleMessage( bs.FreezeMessage()) elif m == '/thaw': if a == []: bsInternal._chatMessage( 'Using: /thaw all or number of list') else: if a[0] == 'all': for i in bs.getSession().players: try: i.actor.node.handleMessage( bs.ThawMessage()) except: pass else: bs.getSession().players[int( a[0])].actor.node.handleMessage( bs.ThawMessage()) elif m == '/sleep': if a == []: bsInternal._chatMessage('Using: number of list') else: if a[0] == 'all': for i in bs.getSession().players: try: i.actor.node.handleMessage( "knockout", 5000) except: pass else: bs.getSession().players[int( a[0])].actor.node.handleMessage( "knockout", 5000) elif m == '/kill': if a == []: bsInternal._chatMessage( 'Using: /kill all or number of list') else: if a[0] == 'all': for i in bs.getSession().players: try: i.actor.node.handleMessage(bs.DieMessage()) except: pass else: bs.getSession().players[int( a[0])].actor.node.handleMessage( bs.DieMessage()) elif m == '/curse': if a == []: bsInternal._chatMessage( 'Using: /curse all or number of list') else: if a[0] == 'all': for i in bs.getSession().players: try: i.actor.curse() except: pass else: bs.getSession().players[int(a[0])].actor.curse() elif m == '/box': if a == []: bsInternal._chatMessage( 'Using: /box all or number of list') else: try: if a[0] == 'all': for i in bs.getSession().players: try: i.actor.node.torsoModel = bs.getModel( "tnt") except: print 'error' for i in bs.getSession().players: try: i.actor.node.colorMaskTexture = bs.getTexture( "tnt") except: print 'error' for i in bs.getSession().players: try: i.actor.node.colorTexture = bs.getTexture( "tnt") except: print 'error' for i in bs.getSession().players: try: i.actor.node.highlight = (1, 1, 1) except: print 'error' for i in bs.getSession().players: try: i.actor.node.color = (1, 1, 1) except: print 'error' for i in bs.getSession().players: try: i.actor.node.headModel = None except: print 'error' for i in bs.getSession().players: try: i.actor.node.style = "cyborg" except: print 'error' else: n = int(a[0]) bs.getSession().players[ n].actor.node.torsoModel = bs.getModel( "tnt") bs.getSession().players[ n].actor.node.colorMaskTexture = bs.getTexture( "tnt") bs.getSession().players[ n].actor.node.colorTexture = bs.getTexture( "tnt") bs.getSession( ).players[n].actor.node.highlight = (1, 1, 1) bs.getSession().players[n].actor.node.color = ( 1, 1, 1) bs.getSession( ).players[n].actor.node.headModel = None bs.getSession( ).players[n].actor.node.style = "cyborg" except: bs.screenMessage('Ошибка!', color=(1, 0, 0)) elif m == '/spaz': if a == []: bsInternal._chatMessage( 'Using: /spaz all or number of list') else: try: if a[0] == 'all': for i in bs.getSession().players: t = i.actor.node try: t.colorTexture = bs.getTexture(a[1] + "Color") t.colorMaskTexture = bs.getTexture( a[1] + "ColorMask") t.headModel = bs.getModel(a[1] + "Head") t.torsoModel = bs.getModel(a[1] + "Torso") t.pelvisModel = bs.getModel(a[1] + "Pelvis") t.upperArmModel = bs.getModel( a[1] + "UpperArm") t.foreArmModel = bs.getModel(a[1] + "ForeArm") t.handModel = bs.getModel(a[1] + "Hand") t.upperLegModel = bs.getModel( a[1] + "UpperLeg") t.lowerLegModel = bs.getModel( a[1] + "LowerLeg") t.toesModel = bs.getModel(a[1] + "Toes") t.style = a[1] except: print 'error' else: n = int(a[0]) t = bs.getSession().players[n].actor.node t.colorTexture = bs.getTexture(a[1] + "Color") t.colorMaskTexture = bs.getTexture(a[1] + "ColorMask") t.headModel = bs.getModel(a[1] + "Head") t.torsoModel = bs.getModel(a[1] + "Torso") t.pelvisModel = bs.getModel(a[1] + "Pelvis") t.upperArmModel = bs.getModel(a[1] + "UpperArm") t.foreArmModel = bs.getModel(a[1] + "ForeArm") t.handModel = bs.getModel(a[1] + "Hand") t.upperLegModel = bs.getModel(a[1] + "UpperLeg") t.lowerLegModel = bs.getModel(a[1] + "LowerLeg") t.toesModel = bs.getModel(a[1] + "Toes") t.style = a[1] except: bs.screenMessage('error', color=(1, 0, 0)) elif m == '/inv': if a == []: bsInternal._chatMessage( 'Using: /spaz all or number of list') else: try: if a[0] == 'all': for i in bs.getSession().players: t = i.actor.node try: t.headModel = None t.torsoModel = None t.pelvisModel = None t.upperArmModel = None t.foreArmModel = None t.handModel = None t.upperLegModel = None t.lowerLegModel = None t.toesModel = None t.style = "cyborg" except: print 'error' else: n = int(a[0]) t = bs.getSession().players[n].actor.node t.headModel = None t.torsoModel = None t.pelvisModel = None t.upperArmModel = None t.foreArmModel = None t.handModel = None t.upperLegModel = None t.lowerLegModel = None t.toesModel = None t.style = "cyborg" except: bs.screenMessage('error', color=(1, 0, 0)) elif m == '/tex': if a == []: bsInternal._chatMessage( 'Using: /tex all or number of list') else: try: if a[0] == 'all': for i in bs.getSession().players: try: i.actor.node.colorMaskTexture = bs.getTexture( "egg1") except: print 'error' for i in bs.getSession().players: try: i.actor.node.colorTexture = bs.getTexture( "egg1") except: print 'error' else: n = int(a[0]) bs.getSession().players[ n].actor.node.colorMaskTexture = bs.getTexture( "egg1") bs.getSession().players[ n].actor.node.colorTexture = bs.getTexture( "egg1") except: bs.screenMessage('Ошибка!', color=(1, 0, 0)) elif m == '/remove': if a == []: bsInternal._chatMessage( 'Using: /remove all or number of list') else: if a[0] == 'all': for i in bs.getSession().players: try: i.removeFromGame() except: pass else: bs.getSession().players[int(a[0])].removeFromGame() elif m == '/end': try: bsInternal._getForegroundHostActivity().endGame() except: pass elif m == '/hug': if a == []: bsInternal._chatMessage( 'Using: /hug all or number of list') else: try: if a[0] == 'all': try: bsInternal._getForegroundHostActivity( ).players[ 0].actor.node.holdNode = bsInternal._getForegroundHostActivity( ).players[1].actor.node except: pass try: bsInternal._getForegroundHostActivity( ).players[ 1].actor.node.holdNode = bsInternal._getForegroundHostActivity( ).players[0].actor.node except: pass try: bsInternal._getForegroundHostActivity( ).players[ 3].actor.node.holdNode = bsInternal._getForegroundHostActivity( ).players[2].actor.node except: pass try: bsInternal._getForegroundHostActivity( ).players[ 4].actor.node.holdNode = bsInternal._getForegroundHostActivity( ).players[3].actor.node except: pass try: bsInternal._getForegroundHostActivity( ).players[ 5].actor.node.holdNode = bsInternal._getForegroundHostActivity( ).players[6].actor.node except: pass try: bsInternal._getForegroundHostActivity( ).players[ 6].actor.node.holdNode = bsInternal._getForegroundHostActivity( ).players[7].actor.node except: pass else: bsInternal._getForegroundHostActivity( ).players[int( a[0] )].actor.node.holdNode = bsInternal._getForegroundHostActivity( ).players[int(a[1])].actor.node except: bs.screenMessage('Ошибка!', color=(1, 0, 0)) elif m == '/gm': if a == []: for i in range(len(activity.players)): if activity.players[i].getName().encode( 'utf-8').find( nick.encode('utf-8').replace( '...', '').replace(':', '')) != -1: activity.players[ i].actor.node.hockey = activity.players[ i].actor.node.hockey == False activity.players[ i].actor.node.invincible = activity.players[ i].actor.node.invincible == False activity.players[ i].actor._punchPowerScale = 5 if activity.players[ i].actor._punchPowerScale == 1.2 else 1.2 else: activity.players[int( a[0])].actor.node.hockey = activity.players[int( a[0])].actor.node.hockey == False activity.players[int( a[0])].actor.node.invincible = activity.players[ int(a[0])].actor.node.invincible == False activity.players[int( a[0] )].actor._punchPowerScale = 5 if activity.players[int( a[0])].actor._punchPowerScale == 1.2 else 1.2 elif m == '/tint': if a == []: bsInternal._chatMessage('Using: /tint R G B') bsInternal._chatMessage('OR') bsInternal._chatMessage('Using: /tint r bright speed') else: if a[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]) bsUtils.animateArray( bs.getSharedObject('globals'), '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: bs.getSharedObject('globals').tint = ( float(a[0]), float(a[1]), float(a[2])) else: bs.screenMessage('Error!', color=(1, 0, 0)) except: bs.screenMessage('Error!', color=(1, 0, 0)) elif m == 'pause': bs.getSharedObject('globals').paused = bs.getSharedObject( 'globals').paused == False elif m == '/sm': bs.getSharedObject( 'globals').slowMotion = bs.getSharedObject( 'globals').slowMotion == False elif m == '/bunny': if a == []: bsInternal._chatMessage( 'Using: /bunny count owner(number of list)') import BuddyBunny for i in range(int(a[0])): p = bs.getSession().players[int(a[1])] if not 'bunnies' in p.gameData: p.gameData['bunnies'] = BuddyBunny.BunnyBotSet(p) p.gameData['bunnies'].doBunny() elif m == '/cameraMode': try: if bs.getSharedObject( 'globals').cameraMode == 'follow': bs.getSharedObject('globals').cameraMode = 'rotate' else: bs.getSharedObject('globals').cameraMode = 'follow' except: pass elif m == '/lm': arr = [] for i in range(100): try: arr.append(bsInternal._getChatMessages()[-1 - i]) except: pass arr.reverse() for i in arr: bsInternal._chatMessage(i) elif m == '/gp': if a == []: bsInternal._chatMessage('Using: /gp number of list') else: s = bsInternal._getForegroundHostSession() for i in s.players[int( a[0])].getInputDevice()._getPlayerProfiles(): try: bsInternal._chatMessage(i) except: pass elif m == '/icy': bsInternal._getForegroundHostActivity().players[int( a[0] )].actor.node = bsInternal._getForegroundHostActivity( ).players[int(a[1])].actor.node elif m == '/fly': if a == []: bsInternal._chatMessage( 'Using: /fly all or number of list') else: if a[0] == 'all': for i in bsInternal._getForegroundHostActivity( ).players: i.actor.node.fly = True else: bsInternal._getForegroundHostActivity( ).players[int( a[0] )].actor.node.fly = bsInternal._getForegroundHostActivity( ).players[int(a[0])].actor.node.fly == False elif m == '/floorReflection': bs.getSharedObject( 'globals').floorReflection = bs.getSharedObject( 'globals').floorReflection == False elif m == '/ac': if a == []: bsInternal._chatMessage('Using: /ac R G B') bsInternal._chatMessage('OR') bsInternal._chatMessage('Using: /ac r bright speed') else: if a[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]) bsUtils.animateArray( bs.getSharedObject('globals'), 'ambientColor', 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: bs.getSharedObject( 'globals').ambientColor = (float(a[0]), float(a[1]), float(a[2])) else: bs.screenMessage('Error!', color=(1, 0, 0)) except: bs.screenMessage('Error!', color=(1, 0, 0)) elif m == '/iceOff': try: activity.getMap().node.materials = [ bs.getSharedObject('footingMaterial') ] activity.getMap().isHockey = False except: pass try: activity.getMap().floor.materials = [ bs.getSharedObject('footingMaterial') ] activity.getMap().isHockey = False except: pass for i in activity.players: i.actor.node.hockey = False elif m == '/maxPlayers': if a == []: bsInternal._chatMessage( 'Using: /maxPlayers count of players') else: try: bsInternal._getForegroundHostSession( )._maxPlayers = int(a[0]) bsInternal._setPublicPartyMaxSize(int(a[0])) bsInternal._chatMessage('Players limit set to ' + str(int(a[0]))) except: bs.screenMessage('Error!', color=(1, 0, 0)) elif m == '/heal': if a == []: bsInternal._chatMessage( 'Using: /heal all or number of list') else: try: bsInternal._getForegroundHostActivity().players[ int(a[0])].actor.node.handleMessage( bs.PowerupMessage(powerupType='health')) except: bs.screenMessage('Error!', color=(1, 0, 0)) elif m == '/reflections': if a == [] or len(a) < 2: bsInternal._chatMessage( 'Using: /reflections type(1/0) scale') rs = [int(a[1])] type = 'soft' if int(a[0]) == 0 else 'powerup' try: bsInternal._getForegroundHostActivity().getMap( ).node.reflection = type bsInternal._getForegroundHostActivity().getMap( ).node.reflectionScale = rs except: pass try: bsInternal._getForegroundHostActivity().getMap( ).bg.reflection = type bsInternal._getForegroundHostActivity().getMap( ).bg.reflectionScale = rs except: pass try: bsInternal._getForegroundHostActivity().getMap( ).floor.reflection = type bsInternal._getForegroundHostActivity().getMap( ).floor.reflectionScale = rs except: pass try: bsInternal._getForegroundHostActivity().getMap( ).center.reflection = type bsInternal._getForegroundHostActivity().getMap( ).center.reflectionScale = rs except: pass elif m == '/shatter': if a == []: bsInternal._chatMessage( 'Using: /shatter all or number of list') else: if a[0] == 'all': for i in bsInternal._getForegroundHostActivity( ).players: i.actor.node.shattered = int(a[1]) else: bsInternal._getForegroundHostActivity().players[ int(a[0])].actor.node.shattered = int(a[1]) elif m == '/cm': if a == []: time = 8000 else: time = int(a[0]) op = 0.08 std = bs.getSharedObject('globals').vignetteOuter bsUtils.animateArray( bs.getSharedObject('globals'), 'vignetteOuter', 3, { 0: bs.getSharedObject('globals').vignetteOuter, 17000: (0, 1, 0) }) 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 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 }) bs.gameTimer(time, bs.Call(off)) elif m == 'help': bsInternal._chatMessage( bs.Lstr(resource='help1').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help2').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help3').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help4').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help5').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help6').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help7').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help8').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help9').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help10').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help11').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help12').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help13').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help14').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help15').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help16').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help17').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help18').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help19').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help20').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help21').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help22').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help23').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help24').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help25').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help26').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help27').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help28').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help29').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help30').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help31').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help32').evaluate())
def __init__(self, color=(1, 1, 1), highlight=(0.5, 0.5, 0.5), character="Spaz", player=None, powerupsExpire=True): """ Create a spaz for the provided bs.Player. Note: this does not wire up any controls; you must call connectControlsToPlayer() to do so. """ # convert None to an empty player-ref if player is None: player = bs.Player(None) Spaz.__init__(self, color=color, highlight=highlight, character=character, sourcePlayer=player, startInvincible=True, powerupsExpire=powerupsExpire) self.lastPlayerAttackedBy = None # FIXME - should use empty player ref self.lastAttackedTime = 0 self.lastAttackedType = None self.heldCount = 0 self.lastPlayerHeldBy = None # FIXME - should use empty player ref here self._player = player profiles = [] profiles = self._player.getInputDevice()._getPlayerProfiles() ### clID = self._player.getInputDevice().getClientID() cl_str = [] for client in bsInternal._getGameRoster(): if client['clientID'] == clID: cl_str = client['displayString'] for spclient in bsInternal._getForegroundHostSession().players: spPlayerID = spclient.get_account_id() ## if profiles == [] or profiles == {}: profiles = bs.getConfig()['Player Profiles'] for p in profiles: try: if cl_str in gph.vipHashes: PermissionEffect(owner=self.node, prefix='[PAID MEMBER]', prefixAnim={ 0: (1, 0, 0), 250: (0, 1, 0), 250 * 2: (0, 0, 1), 250 * 3: (1, 0, 0) }) break if cl_str in gph.sneha: PermissionEffect(owner=self.node, prefix='[QUEEN]', prefixAnim={ 0: (1, 0, 0), 250: (0, 1, 0), 250 * 2: (0, 0, 1), 250 * 3: (1, 0, 0) }) break if cl_str in gph.ayush: PermissionEffect(owner=self.node, prefix='[KING]', prefixAnim={ 0: (1, 0, 0), 250: (0, 1, 1), 250 * 2: (1, 0, 1), 250 * 3: (1, 0, 0) }) break if cl_str in gph.adminHashes: PermissionEffect(owner=self.node, prefix='[OWNER]', prefixAnim={ 0: (1, 0, 0), 250: (0, 1, 0), 250 * 2: (0, 0, 1), 250 * 3: (1, 0, 0) }) break if cl_str in gph.frndHashes: PermissionEffect(owner=self.node, prefix='[TEAM MEMBER]', prefixAnim={ 0: (1, 0, 0), 250: (0, 1, 0), 250 * 2: (0, 0, 1), 250 * 3: (1, 0, 0) }) break if spPlayerID in gph.autoKickList: PermissionEffect(owner=self.node, prefix='[LOOSER]', prefixAnim={ 0: (1, 0, 0), 250: (0, 1, 0), 250 * 2: (0, 0, 1), 250 * 3: (1, 0, 0) }) break if cl_str in gph.royalpass: PermissionEffect(owner=self.node, prefix='[ROYAL PASS]', prefixAnim={ 0: (1, 0, 0), 250: (0, 1, 0), 250 * 2: (0, 0, 1), 250 * 3: (1, 0, 0) }) break ''' else: PermissionEffect(owner = self.node,prefix = '[ADMIN]',prefixAnim = {0: (1,0,0), 250: (0,1,0),250*2:(0,0,1),250*3:(1,0,0)}) break ''' except: pass # grab the node for this player and wire it to follow our spaz (so players' controllers know where to draw their guides, etc) if player.exists(): playerNode = bs.getActivity()._getPlayerNode(player) self.node.connectAttr('torsoPosition', playerNode, 'position')
def _chatFilter(msg, clientID): msg = bs.uni(msg.rstrip()) if clientID == -1: return msg if some.chatMuted and not msg == '/unmute': bs.screenMessage('Admin Has Muted The Chat For Some Time', color=(1, 0, 0), clients=[clientID], transient=True) return None m = msg.split(' ')[0] a = msg.split(' ')[1:] if m in ['/pvtmsg','/dm','/pm']: try: def getPlayerFromMention(mention): for i in bsInternal._getForegroundHostActivity().players: if i.getName().lower().find(mention.lower()) != -1: return i else: return None def getPlayerFromClientID(clientID): for i in bsInternal._getForegroundHostActivity().players: if i.getInputDevice().getClientID() == clientID: return i else: return None if a[0].isdigit(): for player in bsInternal._getForegroundHostActivity().players: if a[0] == str(bsInternal._getForegroundHostSession().players.index(player)): fr = getPlayerFromClientID(clientID) what = ' '.join(a[1:]).encode('utf-8') to = player bs.screenMessage('Private Message Has Been Sent To {}: {}'.format(to.getName(True).encode('utf-8'),what),transient=True,clients=[fr.getInputDevice().getClientID()],color=(0,2,2)) bs.screenMessage('Private Message From {}: {}'.format(fr.getName(True).encode('utf-8'),what),transient=True,clients=[to.getInputDevice().getClientID()],color=(0,2,2)) else: to = getPlayerFromMention(a[0]) fr = getPlayerFromClientID(clientID) what = ' '.join(a[1:]) bs.screenMessage('Private Message Has Been Sent To {}: {}'.format(to.getName(True).encode('utf-8'),what),transient=True,clients=[fr.getInputDevice().getClientID()],color=(0,2,2)) bs.screenMessage('Private Message From {}: {}'.format(fr.getName(True).encode('utf-8'),what),transient=True,clients=[to.getInputDevice().getClientID()],color=(0,2,2)) return None except Exception as e: bs.screenMessage('Format: /pvtmsg <name> <message>') print e if clientID in mutedIDs: bs.screenMessage( 'Admin has muted you for some time. Pro Tip: Stop Begging or Spamming', color=(1, 0, 0), clients=[clientID], transient=True) return None r = bsInternal._getGameRoster() split = msg.split(' ') if split[0] in timeouts: timeout = timeouts[split[0]] * 1000 if clientID in last: if (bs.getRealTime() - last[clientID][split[0]]) < timeout: bs.screenMessage( '{} Rate-Limited. Please wait for {} seconds.'.format( split[0], timeouts[split[0]] - (bs.getRealTime() - last[clientID][split[0]]) / 1000), color=(1, 0, 0), clients=[clientID], transient=True) return None else: last[clientID][split[0]] = bs.getRealTime() else: last[clientID] = {} for i in timeouts.keys(): last[clientID][i] = -99999 for a in r: if a['clientID'] == clientID: if len(a['players']) > 0: name = a['players'][0]['name'] player = handle.getPlayerFromNick(name) account_id = '-' if player is None else player.get_account_id() playerInGame = True else: name = (a['displayString']) account_id = '-' playerInGame = False break else: print r return None name = bs.uni(name) #if not '/!' in msg: start_new_thread(db.logChat,(msg, name, account_id)) #Chat Logs if not db.getAdmin(account_id): import re old_msg = msg clean_msg = re.sub('[^A-Za-z0-9 ]+', '', msg) for word in filter_words: if re.search(r'\b({})\b'.format(word), clean_msg, re.IGNORECASE): cen = ''.join( random.choice(list('@#$%!')) for a in range(len(word))) clean_msg = re.sub(r'\b({})\b'.format(word), cen, clean_msg, flags=re.IGNORECASE) msg = clean_msg if msg != old_msg: import kicker kicker.kick(name, reason='Abuse', warn=True) return msg if msg.startswith('/trans '): if _googletrans: start_new_thread( trans, (' '.join(msg.split(' ')[2:]), name, msg.split(' ')[1])) if msg.startswith('/'): if playerInGame: cmds.append([clientID, msg]) return None if msg.startswith( tuple(['/kick', '/warn', '/mute', '/unmute', '/!'])) else msg else: bs.screenMessage('Please Join The Game First', color=(1, 0.5, 0.5), transient=True, clients=[clientID]) if 'admin' in msg.lower() or 'mod' in msg.lower( ) or 'promote' in msg.lower(): for i in ['pls', 'please', 'give', 'want', 'can i']: if i in msg.lower(): bs.screenMessage( 'Stop Begging For Admin! This Server is Self-Sufficient!', color=(1, 0, 0), transient=True, clients=[clientID]) import kicker kicker.kick(name, reason='Begging', warn=True) return msg # if not msg in some.trans: # t = msg # d = 'en' # lang = translator.detect(t) # if (lang.lang in supported_langs): # tym = translator.translate('Translating Your Message...',lang.lang).text # bs.screenMessage(tym, # color=(0, 0.5, 0.5), transient=True, clients=[clientID]) # tn = translator.translate(t, d).pronunciation # if tn is None: # tn = bs.utf8(translator.translate(t, d).text) # tc = bs.utf8(profanity.censor(tn)) # if tc != tn: # import kicker # kicker.kick(n, reason='Abuse', warn=True) # if tc.lower() != t.lower(): # msg = '{} ({}) > {} (en)'.format(msg,lang.lang,tc) if not msg.lower() in some.trans and _googletrans: start_new_thread(trans, (msg, name)) return msg