def finish_initialization(): '''Tries to finish GunGame's initialization''' # Fire the gg_server.cfg es.server.cmd('exec gungame51/gg_server.cfg') # Clear out the GunGame system reset_players() # Restart map msg('#human', 'Loaded') # Prune the DB prune_winners_db() # Load error logging delayed(3.50, make_log_file) # Fire gg_load event GG_Load().fire() # Send message that loading has completed es.dbgmsg(0, langstring("Load_Completed")) # Change the value of gg_weapon_order_file to make sure we call # server_cvar when reloading gungame51 gg_weapon_order_file_backup = str(gg_weapon_order_file) gg_weapon_order_file.set(0) gg_weapon_order_file.set(gg_weapon_order_file_backup) # See if we need to fire event gg_start after everything is loaded delayed(2, check_first_gg_start)
def __call__(self, *args, **kw): es.dbgmsg(1, '[ESThread] Method.__call__(%s, %s)' % (args, kw)) self.thread.args = args self.thread.kw = kw self.thread.start() self.thread.join() return self.thread.result
def load(): dbg( '') dbg( 'XS: Loading...') if not callable(getattr(popuplib,'easylist',None)): es.dbgmsg(0,'XS: Popuplib version too old! Please update!') es.unload('extendedstats') return loadPackages() loadAddons() fillDatabase() loadToplist() saycommands[re.compile('\A%s%s' % (scfg.say_command_prefix,scfg.command_help))] = cmd_help es.addons.registerSayFilter(sayfilter) es.regclientcmd(scfg.command_help,'extendedstats/cmd_help') loadCVARS() loadMenus() es.regcmd('xs_resetlog','extendedstats/resetlog') #es.regcmd('xs_cleandb','extendedstats/cleandb') es.regcmd('xs_checkversion','extendedstats/checkversion') es.regcmd('xs_cfgsync','extendedstats/cfgsync') es.regcmd('xs_dbsync','extendedstats/dbsync') es.server.queuecmd('es_load extendedstats/events/%s' % (game)) dbg('XS: Registered methods:') for method in methods: dbg( ' %s' % method) dcfg.sync() dbg('XS: Loaded successfully (%s)' % (info.version)) dbg(' ')
def initialize(): '''Tries to initialize GunGame''' # Load GunGame's events load_events() # Load custom events gg_resource_file.declare_and_load() # Load the base translations load_translation('gungame', 'gungame') # Send message about GunGame loading es.dbgmsg(0, langstring("Load_Start", {'version': gungame_info('version')})) # Load config files load_configs() # Load weapon orders WeaponOrderManager().load_orders() # Load menus MenuManager().load_menus() # Make the sounds downloadable make_downloadable(True) # Pause a moment for the configs to be loaded (OB engine requires this) delayed(0.1, complete_initialization)
def dbg(text,write_to_file=False): if write_to_file or dcfg['debuglevel'] == '1': errorlog.write_lines([' ','XS: Extra debug info:',text,' '] + errorlog.lines(retain=False)) if dcfg['debuglevel'] == '-1': return if dcfg['debuglevel'] in ('0','1'): es.dbgmsg(0,text)
def map_check(mapname): if mapname in gDefaultMaps or os.path.isfile(xa.gamedir() + "/maps/%s.bsp" % mapname): return True else: if not mapname.startswith("//") and mapname != "": es.dbgmsg(0, "XAMapManagement: Unable to find map: %s." % mapname) return False
def update_cmd(args): """ es_update <basename> [force update] Uses installlib to update an addon by basename """ argc = len(args) if argc in (1, 2): basename = args[0] force = (args[1] != '0') if argc == 2 else False installer = installlib.getInstaller(basename) if installer is None: log.write('es_install: Unable find addon on ESAM -- please ensure you have an active internet connection and the basename is valid', 0) else: status = installer.update(force) if status == installer.STATUS_SUCCESSFUL: log.write('es_update: %s updated successfully' % basename, 0) elif status == installer.STATUS_NO_DOWNLOAD: log.write('es_update: Unable to download %s -- please ensure you have an active internet connection' % basename, 0) elif status == installer.STATUS_NO_INSTALL_INFO: log.write('es_update: %s not installed with es_install' % basename, 0) elif status == installer.STATUS_ALREADY_DONE: log.write('es_update: %s already up to date' % basename, 0) elif status == installer.STATUS_NOT_APPROVED: log.write('es_update: %s not approved for install' % basename, 0) else: log.write('es_update: Unknown error (%s)' % status, 0) else: es.dbgmsg(0, 'Syntax: es_update <basename> [force update]')
def clientAddXp(self, userid, args=None): """ This method is a client command callback when an admin runs the command rpgaddxp <steamid> <amount>. This will be generally called from the custom menu with the escape input box. Execute the addition of the experience @PARAM userid - the admin's id who executed the command @PARAM args - any additional arguments after the command """ if args is None: args = userid userid = None if len(args) != 2: if len(args) == 6: args = ("".join(args[:5]), args[5]) else: es.dbgmsg(0, "rpgaddxp <steamid> <amount>") return steamid, amount = args if not str(amount).isdigit(): es.dbgmsg(0, "rpgaddxp <steamid> <amount>") return if not steamid.lower().startswith("steam"): userid = es.getuserid(steamid) if userid is None: return steamid = es.getplayersteamid(userid) amount = int(amount) popup.addXp(userid, amount, "sourcerpg_addxp_player%s" % steamid)
def es_dumpusermessages(argv): for index in range(maxmessages_cvar.get_int()): name = get_message_name(index) size = get_message_size(index) if name is not None: es.dbgmsg(0, ' Id: {:02d}, Size: {}, Message: {}'.format( index, size, name))
def connect(self): """ Executed when we want to connect to an object. Return a urllib2 connection object, or None if the connection was unsuccessful. """ if self.status == self.__class__.CONNECTED: return self.connection try: if self.data is not None: formattedData = "" for key, value in self.data.iteritems(): formattedData += "%s=%s&" % (key, value) formattedData = formattedData[:-1] self.connection = urllib2.urlopen(self.url, formattedData) else: self.connection = urllib2.urlopen(self.url) self.status = self.__class__.CONNECTED return self.connection except Exception, e: # An error occured, pass it to debug message to be logged. error = "[EventScripts] ERROR: Cannot retrieve data from the url: %s" es.dbgmsg(1, error % self.url) es.dbgmsg(1, str(e)) update_notice.set(error % self.url) return None
def _punish_player(userid, punishment, adminid, args = [], force = False): if adminid == 0 or xapunishments.isUseridAuthorized(adminid, punishment+"_player") or force: if (not xapunishments.isUseridAuthorized(userid, "immune_"+punishment)) or (userid == adminid) or force: if userid in playerlib.getUseridList("#alive") or True == punishment_ondead[punishment]: if callable(punishment_method[punishment]): xapunishments.logging.log("used punishment %s on user %s [%s]" % (punishment, es.getplayername(userid), es.getplayersteamid(userid)), adminid, True) try: punishment_method[punishment](userid, adminid, args, force) except TypeError: try: punishment_method[punishment](userid, adminid, args) except TypeError: punishment_method[punishment](userid, adminid) return True else: es.dbgmsg(0, "xapunishments.py: Cannot find method '"+str(punishment_method[punishment])+"'!") return False else: if userid not in dead_delayed: dead_delayed[userid] = [] dead_delayed[userid].append(punishment,adminid,args,force) xapunishments.logging.log("will be punished when he next spawns", userid) es.tell(adminid, xalanguage("dead", {'username':es.getplayername(userid)}, playerlib.getPlayer(adminid).get("lang"))) return False else: es.tell(adminid, xalanguage("immune", {'username':es.getplayername(userid)}, playerlib.getPlayer(adminid).get("lang"))) return False else: es.tell(adminid, xalanguage("not allowed", (), playerlib.getPlayer(adminid).get("lang"))) return False
def _capgroup_set(userid,choice,popupid): es.dbgmsg(1,'*****_capgroup_set') if choice[0] == 'go': _groupcaps_list(userid,choice[2],None) else: es.server.queuecmd('gauth power %s %s %s' %(choice[0],choice[1],choice[2])) capmain.send(userid)
def __exit__(self, exc_type, exc_value, _traceback): '''Verifies that certain attributes have values on exit''' # Was an error encountered? if _traceback: # Print the traceback es.dbgmsg(0, _traceback) return False # Does the cvar have a name value? if self.name is None: # Raise an error raise ValueError('No "name" set for "' + self.cvarname + '"') # Does the cvar have a default value? if self.default is None: # Raise an error raise ValueError( 'No default value set for "' + self.cvarname + '"') # Does the cvar have a text value? if self.text is None: # Raise an error raise ValueError('No "text" set for "' + self.cvarname + '"') # Add the cvar with it's default value to CvarDefaults CvarDefaults[self.cvarname] = self.default # Return return True
def load(self, priority=False): if self.scriptname in addons: raise RuntimeError('[EventScripts] %s already loaded, try to es_unload it first' % self.scriptname) if not self.scriptexists(): raise IOError('Could not open script for %s' % self.scriptname) with open(self.scriptfile, encoding='utf-8') as f: code = splitblocks(f.readlines()) for blockname, block in code['block'].items(): newblock = self.blocks[blockname] = self.Block('%s/%s' % (self.scriptname, blockname), block) es.addons.registerBlock(self.scriptname, blockname, newblock) for eventname, event in code['event'].items(): newevent = self.events[eventname] = self.Event('%s/%s' % (self.scriptname, eventname), event) es.addons.registerForEvent(self, eventname, newevent) self.disabled = False addons[self.scriptname] = self if self.loadblock in self.blocks: self.blocks[self.loadblock].run(priority) es.dbgmsg('corelib' in self.scriptname, '[EventScripts] Loaded %s' % self.scriptname) return True
def getLangAbbreviation(full): myl = str(full).lower() if myl in languages: return languages[myl]["id"] else: es.dbgmsg(0, 'langlib: Unrecognized language "' + myl + '"') return getDefaultLang()
def reCacheConnection(forceRecache=False): """ Reconnect to the server to check for updates. This overwrites the cache. Sends version variables to the server to warn of any version issues for security updates, etc. @param bool forceRecache Whether or not it will ignore if the connection already has a cache. """ if not connection.hasCache() or forceRecache is True: data = {} data["eventscripts_ver"] = str(es.getString("eventscripts_ver")) data["es_corelib_ver"] = str(es.getString("es_corelib_ver")) data["eventscripts_ver_revision"] = str(es.getString("eventscripts_ver_revision")) data["eventscripts_xa"] = str(es.getString("eventscripts_xa")) data["os.name"] = os.name data["game"] = es.getGameName() data["hostport"] = str(es.getString("hostport")) try: l = es.getInt("hostip") data["hostip"] = '%d.%d.%d.%d' % (l>>24 & 255, l>>16 & 255, l>>8 & 255, l & 255) except: # oh well, skip the IP address es.dbgmsg(1, "es_checkversion: Couldn't get IP address properly") pass connection.data = data connection.connect() connection.reCacheUpdate() connection.disconnect()
def _groupuser_remove(userid,choice=None,popupid=None): es.dbgmsg(1,'*****_groupuser_remove') es.server.queuecmd('gauth user leave %s %s' %(choice[0],choice[1])) if popupid == 'groupusers': groupsmain.send(userid) if popupid == 'usergroups': _userslist(userid)
def _inputbox_handle(): es.dbgmsg(1,'*****_inputbox_handle') userid = es.getcmduserid() count = int(es.getargc()) if count == 3: groupname = es.getargv(1) level = es.getargv(2) level = level.lower() if level in ('root','admin','poweruser','known','all'): if level == 'root': level = 0 if level == 'admin': level = 1 if level == 'poweruser': level = 2 if level == 'known': level = 4 if level == 'all': level = 128 es.server.queuecmd('gauth group create %s %d' %(groupname,level)) es.esctextbox(10, userid, "New group added", "You have added group: %s with access level %s" %(groupname,level)) else: es.esctextbox(10, userid, "Invalid level", "Accepted levels:\n -admin\n -poweruser\n -known\n -all") else: es.esctextbox(10, userid, "Invalid Entry", "<groupname-no spaces> <level>")
def load(): es.dbgmsg(0, "[SH] Loading.....") es.doblock('corelib/noisy_on') config.execute() # Executes the .cfg to register changes global popup_language popup_language = es.ServerVar('popup_language') global rounds_played rounds_played = 0 es.server.queuecmd('es_xload superhero/heroes') es.server.queuecmd('es_xload superhero/admins') # Create a group global heroes heroes = [] ### Get the Strings the popup cmdlist_popup = langlib.Strings(es.getAddonPath("superhero") + "/languages/cmdlist_popup.ini") # Create popups global commandlist commandlist = popuplib.easymenu('commandlist','choice',commandlist_selection) commandlist.settitle('All Commands') commandlist.addoption('help',cmdlist_popup('cmd_help',lang=str(popup_language))) # Done commandlist.addoption('herolist',cmdlist_popup('cmd_herolist',lang=str(popup_language))) # Done commandlist.addoption('playerinfo',cmdlist_popup('cmd_playerinfo',lang=str(popup_language))) commandlist.addoption('myheroes',cmdlist_popup('cmd_myheroes',lang=str(popup_language))) # Done commandlist.addoption('clearpowers',cmdlist_popup('cmd_clearpowers',lang=str(popup_language))) # Done commandlist.addoption('showmenu',cmdlist_popup('cmd_showmenu',lang=str(popup_language))) # Done commandlist.addoption('showxp',cmdlist_popup('cmd_showxp',lang=str(popup_language))) # Done commandlist.addoption(None,cmdlist_popup('cmd_drop',lang=str(popup_language))) # Done commandlist.addoption(None,cmdlist_popup('cmd_buyxp',lang=str(popup_language))) commandlist.addoption(None,cmdlist_popup('cmd_binding',lang=str(popup_language))) helpbox_popup = langlib.Strings(es.getAddonPath("superhero") + "/languages/helpbox_popup.ini") global helpbox helpbox = popuplib.create('helpbox') helpbox.addline(helpbox_popup('helpbox_1',lang=str(popup_language))) helpbox.addline(helpbox_popup('helpbox_2',lang=str(popup_language))) helpbox.addline('\n\n') helpbox.addline(helpbox_popup('helpbox_3',lang=str(popup_language))) helpbox.addline(helpbox_popup('helpbox_4',lang=str(popup_language))) helpbox.addline(helpbox_popup('helpbox_5',lang=str(popup_language))) helpbox.addline(helpbox_popup('helpbox_6',lang=str(popup_language))) # Saycommands register etc. cmdlib.registerSayCommand('/commandlist', 'superhero/commandlist', 'COMMANDLIST') cmdlib.registerSayCommand('/shmenu', 'superhero/commandlist', 'SHMENU') cmdlib.registerSayCommand('/sh', 'superhero/commandlist', 'SH') cmdlib.registerSayCommand('/help', superherohelp, 'HELP') cmdlib.registerSayCommand('/showmenu', showmenu, 'SHOWMENU') cmdlib.registerSayCommand('/drop', drop, 'DROP') cmdlib.registerSayCommand('/showxp', showxp, 'SHOWXP') cmdlib.registerSayCommand('/myheroes', myheroes, 'MYHEROES') cmdlib.registerSayCommand('hashero', 'superhero/hashero', 'HASHERO') cmdlib.registerSayCommand('/buyxp', buyxp, 'BUYXP') cmdlib.registerSayCommand('/herolist', herolist, 'HEROLIST') cmdlib.registerSayCommand('/clearpowers', clearpowers, 'CLEARPOWERS') cmdlib.registerSayCommand('/playerinfo', playerinfo, 'PLAYERINFO') cmdlib.registerClientCommand('+power1', power, "+power1") cmdlib.registerClientCommand('-power1', poweroff, "-power1") cmdlib.registerClientCommand('+power2', power, "+power2") cmdlib.registerClientCommand('-power2', poweroff, "-power2") cmdlib.registerClientCommand('+power3', power, "+power3") cmdlib.registerClientCommand('-power3', poweroff, "-power3") es.dbgmsg(0, "[SH] Loading Done.")
def unload(): es.dbgmsg(1,'*****unload') if authaddon == 'basic_auth': popuplib.delete('admindetail') if int(popuplib.exists('adminlistmenu')): popuplib.delete('adminlistmenu') es.dbgmsg(1,'basicadmins_default=%s' %basicadmins_default) es.set('BASIC_AUTH_ADMIN_LIST', basicadmins_default) elif authaddon == 'group_auth': popuplib.delete('groupsmainmenu') popuplib.delete('usermenu') popuplib.delete('capmain') if int(popuplib.exists('groupsmenu')): popuplib.delete('groupsmenu') if int(popuplib.exists('groupslist')): popuplib.delete('groupslist') if int(popuplib.exists('groupsusers')): popuplib.delete('groupsusers') if int(popuplib.exists('groupcaps')): popuplib.delete('groupcaps') if int(popuplib.exists('playermenu')): popuplib.delete('playermenu') xa.unregister(xaauthmanage)
def showInfo(self, args=None): self.showCheckedUpdate() es.dbgmsg(0, "[UltiRank] UltiRank %s has been loaded!" % info.version) es.dbgmsg(0, "[UltiRank] UltiRank DB Version: %.2f" % self.actualdbversion) es.dbgmsg(0, "[UltiRank] UltiRank Identify Method: %s" % self.identifyMethod) es.dbgmsg(0, "[UltiRank] UltiRank currently had %d players on file!" % len(self.ranklist)) es.dbgmsg(0, "[UltiRank] UltiRank created by ultimatebuster. http://thekks.net")
def _punish_player(userid, punishment, adminid, args = [], force = False): if adminid == 0 or xapunishments.isUseridAuthorized(adminid, punishment+"_player") or force: if (not xapunishments.isUseridAuthorized(userid, "immune_"+punishment)) or (userid == adminid) or force: if userid in playerlib.getUseridList("#alive"): if callable(punishment_method[punishment]): xapunishments.logging.log("Player "+es.getplayername(adminid)+ " used punishment "+str(punishment)+" on player "+es.getplayername(userid)) try: punishment_method[punishment](userid, adminid, args, force) except TypeError: try: punishment_method[punishment](userid, adminid, args) except TypeError: punishment_method[punishment](userid, adminid) return True else: es.dbgmsg(0, "xapunishments.py: Cannot find method '"+str(punishment_method[punishment])+"'!") return False else: es.tell(adminid, xalanguage("dead", {'username':es.getplayername(userid)}, playerlib.getPlayer(adminid).get("lang"))) return False else: es.tell(adminid, xalanguage("immune", {'username':es.getplayername(userid)}, playerlib.getPlayer(adminid).get("lang"))) return False else: es.tell(adminid, xalanguage("not allowed", (), playerlib.getPlayer(adminid).get("lang"))) return False
def _dump_entity_table(entity, table, path, offset=0): import es ptr = entity.pointer for prop in table: current_offset = offset + prop.offset current_path = '{}.{}'.format(path, prop.name) if prop.type == SendPropType.DATATABLE: _dump_entity_table( entity, prop.data_table, current_path, current_offset) continue if prop.type == SendPropType.INT: value = ptr.get_int(current_offset) elif prop.type == SendPropType.FLOAT: value = ptr.get_float(current_offset) elif prop.type == SendPropType.VECTOR: value = '{},{},{}'.format( ptr.get_float(), ptr.get_float(4), ptr.get_float(8)) elif prop.type == SendPropType.STRING: # Not really a TODO for SP, but ES didn't implement it value = '(TODO: string)' elif prop.type == SendPropType.ARRAY: # Not really a TODO for SP, but ES didn't implement it value = '(TODO: array)' else: value = '(Unknown)' es.dbgmsg(0, '{} = {}'.format(current_path, value))
def unload(): es.dbgmsg(0, "[SH] UnLoading...") es.doblock('corelib/noisy_off') es.unload('superhero/heroes') es.unload('superhero/admins') helpbox.delete() commandlist.delete() cmdlib.unregisterSayCommand('/myheroes') cmdlib.unregisterSayCommand('/showmenu') cmdlib.unregisterSayCommand('/showxp') cmdlib.unregisterSayCommand('/drop') cmdlib.unregisterSayCommand('/commandlist') cmdlib.unregisterSayCommand('/help') cmdlib.unregisterSayCommand('/buyxp') cmdlib.unregisterSayCommand('/clearpowers') cmdlib.unregisterSayCommand('/herolist') cmdlib.unregisterSayCommand('/playerinfo') cmdlib.unregisterSayCommand('/sh') cmdlib.unregisterSayCommand('/shmenu') cmdlib.unregisterClientCommand('+power1') cmdlib.unregisterClientCommand('+power2') cmdlib.unregisterClientCommand('+power3') cmdlib.unregisterClientCommand('-power1') cmdlib.unregisterClientCommand('-power2') cmdlib.unregisterClientCommand('-power3') connection.commit() # Commit changes to table connection.close() # Close our connection es.dbgmsg(0, "[SH] Unloading Done.")
def memoryExecuteCommand(pathToConfigFile): """ This function copies a configuration file from outside the ../cfg/ file to the ../cfg/ file to be executed by Valve's exec command. The reason why we need to copy the file is to ensure backwards compatibility as es_(x)mexec used to allow functionality of having configuration files outside of the ../cfg/ directory. Since the Valve console broke this functionality in the OB update, we need to simulate the functionality by copying the directory to a temporary unique file in the ../cfg/ directory. """ pathToConfigFile = pathToConfigFile.strip('"') if not pathToConfigFile.startswith('..'): es.server.cmd('exec "%s"' % pathToConfigFile) return cfgFolder = path(str(es.ServerVar('eventscripts_gamedir'))).joinpath('cfg') individualCFGFile = cfgFolder.joinpath(pathToConfigFile) uniqueString = hashlib.md5(str(time.time())).hexdigest() configName = '%s.%s.mexec.cfg' % (individualCFGFile.namebase, uniqueString) newFile = cfgFolder.joinpath(configName) try: individualCFGFile.copyfile(newFile) es.server.cmd('exec "%s"' % configName) newFile.remove() except IOError: es.dbgmsg(0, "ERROR: es_mexec cannot find the file path %s" % pathToConfigFile)
def load(): #Load Function for Chat Flood Control for XA. if str(chat_flood_time) != '0': if not floodcontrol in es.addons.SayListeners: es.addons.registerSayFilter(floodcontrol) else: es.dbgmsg(0, 'chat_flood_time set to 0, exiting...')
def convertFromSQLite(args): """ Convert the SQLite database into the MySQL database ensuring that all stats are made consistent throughout. """ sourcerpg.players.clearList() tempDB = sourcerpg.SQLiteManager(sourcerpg.databasePath) uidinsert = "INSERT INTO Player (steamid, level, xp, credits, popup, name, lastConnected) VALUES (\"%s\", %s, %s, %s, %s, \"%s\", %s)" skillinsert = "INSERT INTO Skill (UserID, name, level) VALUES (%s, \"%s\", %s)" query = "SELECT UserID, steamid, level, xp, credits, popup, name, lastConnected FROM Player" tempDB.execute(query) players = map(lambda x: list(x[:6]) + [x[6].replace('"', '\\"').replace("'", "\\'")] + [int(float(x[7]))], tempDB.cursor.fetchall()) for player in players: try: query = "SELECT name, level FROM Skill WHERE UserID=?" tempDB.cursor.execute(query, (player[0],)) skills = tempDB.cursor.fetchall() sourcerpg.database.cursor.execute(uidinsert, tuple(player[1:])) uid = sourcerpg.database.cursor.lastrowid skills = tuple(map(lambda x: tuple([uid] + list(x)), skills)) sourcerpg.database.cursor.executemany(skillinsert, skills) except: es.dbgmsg(0, "[SourceRPG] Error converting SteamID %s" % (player[1])) continue sourcerpg.database.save(True) for player in es.getUseridList(): sourcerpg.players.addPlayer(player) sourcerpg.es_map_start({}) es.server.queuecmd('mp_restartgame 1')
def loadConfig(): global serverId, websiteAddy, banAppealMessage, hashCode, teachAdmins, clanName, allowAdminBanning gbanLog('GBAN: Attempting to load values from GlobalBan.cfg') # Look for the GlobalBan config file and load the values from it if os.path.isfile(es.getAddonPath('GlobalBan') + '/GlobalBan.cfg'): cfg = ConfigObj(es.getAddonPath('GlobalBan') + '/GlobalBan.cfg') serverId = cfg['serverId'] websiteAddy = cfg['websiteAddy'] banAppealMessage = cfg['banAppealMessage'] hashCode = cfg['hash'] teachAdmins = int(cfg['teachAdmins']) clanName = cfg['clanName'] allowAdminBanning = cfg['allowAdminBanning'] es.set("GlobalBan_Web", websiteAddy) else: es.dbgmsg(0, 'GlobalBan: Unable to load GlobalBan.cfg! Please ensure it is in the ./GlobalBan/ directory.') gbanLog('GBAN: The GlobalBan.cfg file is not set up correctly!!') es.msg('#lightgreen', 'The GlobalBan.cfg file is not set up correctly!!') es.msg('#lightgreen', 'The GlobalBan.cfg file is not set up correctly!!') gbanLog('GBAN: Please execute a "Save Configuration" from the web, or update the file manually') es.msg('#lightgreen', 'Please execute a "Save Configuration" from the web, or update the file manually') gbanLog('GBAN: Please save from the web again, or update manually') # If the website addy is the default... then the cfg file did not load if websiteAddy == "http://yourdomain.com/banned/": gbanLog('GBAN: The GlobalBan.cfg file is not set up correctly!!') es.msg('#lightgreen', 'The GlobalBan.cfg file is not set up correctly!!') es.msg('#lightgreen', 'The GlobalBan.cfg file is not set up correctly!!') gbanLog('GBAN: Please execute a "Save Configuration" from the web, or update the file manually') es.msg('#lightgreen', 'Please execute a "Save Configuration" from the web, or update the file manually') gbanLog('GBAN: Please save from the web again, or update manually')
def services_cmd(): # handles all of the service related functions cmd = es.getargv(1) cmd = cmd.lower() if cmd == "register": # create a fake service # //services register auth myauth # // services.register("auth", myauth) servicename = es.getargv(2) cmdname = es.getargv(3) leg = LegacyAuthorizationService() leg.setCommandName(cmdname) services.register(servicename, leg) elif cmd == "unregister": servicename = es.getargv(2) services.unregister(servicename) # // services unregister auth pass elif cmd == "isregistered": # //services isregistered myvar auth returnvar = es.ServerVar(es.getargv(2)) servicename = es.getargv(3) returnvar.set(int(services.isRegistered(servicename))) elif cmd == "getlist": pass elif cmd == "getregistered": pass elif cmd == "type": pass elif cmd == "list": pass else: es.dbgmsg(0, "services: Invalid option.")
def returnMenu(userid, choice, popupid): function = vote_list[choice]['function'] if callable(function): xavote.logging.log("Admin "+ es.getplayername(userid)+ " selected vote " + str(choice)) function(userid, choice) else: es.dbgmsg(0, "xavote.py: Cannot find method '"+str(function)+"'!")
def echo(self): """ Outputs stored log lines to the console """ for line in self.lines: es.dbgmsg(0, line)
def write(self, text, dbglvl=None): """ Writes the text to log, echoing to the console if necessary """ if not dbglvl is None: es.dbgmsg(dbglvl, text) self.lines.append(text)
import es
def information(self, listlevel): es.dbgmsg(0, self.name) if listlevel >= 1: es.dbgmsg(0, " Keygroup: "+str(self.keygroup)) es.dbgmsg(0, " Block: "+str(self.block)) es.dbgmsg(0, " Variable: "+str(self.returnvar)) es.dbgmsg(0, " Titletext: "+str(self.titletext)) es.dbgmsg(0, " Menudisplay: "+' '.join(self.menudisplay)) es.dbgmsg(0, " Menureturn: "+' '.join(self.menureturn)) es.dbgmsg(0, " Backpopup: "+str(self.backpopup)) es.dbgmsg(0, " Linecount: "+str(self.linecount)) es.dbgmsg(0, " Pagecount: "+str(self.getpages())) es.dbgmsg(0, " ")
def getpages(self): if self.popup: self.pagecount = self.popup.getPageCount() else: es.dbgmsg(0, f"keymenu: Could not get pagecount of keymenu '{self.name}', the popup object was not created!") return self.pagecount
def gungame_except_hook(tb_type, value, trace_back, mute_console=False): # If this error was called to stop an attribute from being set, do not log # it. if str(value) == "gg_cancel_callback": return tb = traceback.format_exception(tb_type, value, trace_back) # If not a gungame error, send to ES and return if 'gungame51' not in str(tb).lower(): es.excepter(tb_type, value, trace_back) return # Format the traceback for i in range(len(tb)): # Remove long file names ? if tb[i].strip().startswith('File "'): tb[i] = (tb[i].replace( tb[i][(tb[i].find('File "') + 6):tb[i].find('eventscripts')], '../')).replace('\\', '/') tb[-2] = tb[-2] + '\n' # turn tb into a string tb = reduce((lambda a, b: a + b), tb) # Is the length under 255 chars? if len(tb) < 255: db_tb = [tb] # Length over 255 chars else: db_tb = [x.strip() for x in tb.split('\n') if x != ''] # Print traceback to console? if not mute_console: es.dbgmsg(0, ' \n') es.dbgmsg(0, '# ' + '=' * 48) es.dbgmsg(0, '# >>' + 'GunGame 5.1 Exception Caught!'.rjust(50)) es.dbgmsg(0, '# ' + '=' * 48) # Divide up for 255 line limit for db_line in db_tb: es.dbgmsg(0, db_line) es.dbgmsg(0, '# ' + '=' * 48) es.dbgmsg(0, ' \n') # Does the log file exist yet? if not file_created: gamethread.delayed(5, gungame_except_hook, (tb_type, value, trace_back, True)) return # Use Log File with file_name.open('r+') as log_file: # Get contents log_contents = log_file.read() # Look for duplicate error find_error_index = log_contents.find(tb) # File has no duplicate error ? if find_error_index == -1: # Error template error_format = [ '-=' * 39 + '-\n', (('LAST EVENT: ' + '%s' % strftime('[%m/%d/%Y @ %H:%M:%S]')) + ' ' * 9 + ' TOTAL OCCURENCES: [0001]').center(79) + '\n', '-=' * 39 + '-\n', '\n', tb, '\n', '\n' ] # No duplicate, appending to end of file ''' For some reason we get an error if we do not read again here if someone knows why, please let me know! - Monday ''' log_file.read() log_file.writelines(error_format) else: # Go to the back to the begining of the file log_file.seek(0) # Increase occurence count error_count = (int(log_contents[(find_error_index - 92):(find_error_index - 88)]) + 1) # Write change w/ new date and occurence count log_file.write( log_contents[:(find_error_index - 241)] + log_contents[(find_error_index + len(tb) + 2):] + '-=' * 39 + '-\n' + (('LAST EVENT: ' + '%s' % strftime('[%m/%d/%Y @ %H:%M:%S]')) + ' ' * 9 + ' TOTAL OCCURENCES:' + ' [%04i]' % error_count).center(79) + '\n' + '-=' * 39 + '-\n\n' + tb + '\n\n')
def load(): es.dbgmsg(0, "[SH] Successfully loaded Mystique")
def load(): es.dbgmsg(0, "[SH] Loading.....") es.doblock('corelib/noisy_on') config.execute() # Executes the .cfg to register changes global popup_language popup_language = es.ServerVar('popup_language') global rounds_played rounds_played = 0 es.server.queuecmd('es_xload superhero/heroes') es.server.queuecmd('es_xload superhero/admins') # Create a group global heroes heroes = [] ### Get the Strings the popup cmdlist_popup = langlib.Strings( es.getAddonPath("superhero") + "/languages/cmdlist_popup.ini") # Create popups global commandlist commandlist = popuplib.easymenu('commandlist', 'choice', commandlist_selection) commandlist.settitle('All Commands') commandlist.addoption('help', cmdlist_popup('cmd_help', lang=str(popup_language))) # Done commandlist.addoption('herolist', cmdlist_popup('cmd_herolist', lang=str(popup_language))) # Done commandlist.addoption( 'playerinfo', cmdlist_popup('cmd_playerinfo', lang=str(popup_language))) commandlist.addoption('myheroes', cmdlist_popup('cmd_myheroes', lang=str(popup_language))) # Done commandlist.addoption('clearpowers', cmdlist_popup('cmd_clearpowers', lang=str(popup_language))) # Done commandlist.addoption('showmenu', cmdlist_popup('cmd_showmenu', lang=str(popup_language))) # Done commandlist.addoption('showxp', cmdlist_popup('cmd_showxp', lang=str(popup_language))) # Done commandlist.addoption(None, cmdlist_popup('cmd_drop', lang=str(popup_language))) # Done commandlist.addoption(None, cmdlist_popup('cmd_buyxp', lang=str(popup_language))) commandlist.addoption( None, cmdlist_popup('cmd_binding', lang=str(popup_language))) helpbox_popup = langlib.Strings( es.getAddonPath("superhero") + "/languages/helpbox_popup.ini") global helpbox helpbox = popuplib.create('helpbox') helpbox.addline(helpbox_popup('helpbox_1', lang=str(popup_language))) helpbox.addline(helpbox_popup('helpbox_2', lang=str(popup_language))) helpbox.addline('\n\n') helpbox.addline(helpbox_popup('helpbox_3', lang=str(popup_language))) helpbox.addline(helpbox_popup('helpbox_4', lang=str(popup_language))) helpbox.addline(helpbox_popup('helpbox_5', lang=str(popup_language))) helpbox.addline(helpbox_popup('helpbox_6', lang=str(popup_language))) # Saycommands register etc. cmdlib.registerSayCommand('/commandlist', 'superhero/commandlist', 'COMMANDLIST') cmdlib.registerSayCommand('/shmenu', 'superhero/commandlist', 'SHMENU') cmdlib.registerSayCommand('/sh', 'superhero/commandlist', 'SH') cmdlib.registerSayCommand('/help', superherohelp, 'HELP') cmdlib.registerSayCommand('/showmenu', showmenu, 'SHOWMENU') cmdlib.registerSayCommand('/drop', drop, 'DROP') cmdlib.registerSayCommand('/showxp', showxp, 'SHOWXP') cmdlib.registerSayCommand('/myheroes', myheroes, 'MYHEROES') cmdlib.registerSayCommand('hashero', 'superhero/hashero', 'HASHERO') cmdlib.registerSayCommand('/buyxp', buyxp, 'BUYXP') cmdlib.registerSayCommand('/herolist', herolist, 'HEROLIST') cmdlib.registerSayCommand('/clearpowers', clearpowers, 'CLEARPOWERS') cmdlib.registerSayCommand('/playerinfo', playerinfo, 'PLAYERINFO') cmdlib.registerClientCommand('+power1', power, "+power1") cmdlib.registerClientCommand('-power1', poweroff, "-power1") cmdlib.registerClientCommand('+power2', power, "+power2") cmdlib.registerClientCommand('-power2', poweroff, "-power2") cmdlib.registerClientCommand('+power3', power, "+power3") cmdlib.registerClientCommand('-power3', poweroff, "-power3") es.dbgmsg(0, "[SH] Loading Done.")
def load(): es.dbgmsg(0, "[SH] Successfully loaded Wolverine")
def information(self, listlevel): if listlevel >= 1: es.dbgmsg(0, ' ') es.dbgmsg(0, self.name) if listlevel >= 1: es.dbgmsg( 0, ' Description: ' + str(self.keyvalues['config']['descr'])) es.dbgmsg( 0, ' Re-Send: ' + str(self.keyvalues['config']['resend'])) es.dbgmsg( 0, ' Soundfile: ' + str(self.keyvalues['config']['sound'])) if listlevel >= 2: es.dbgmsg( 0, ' Players: ' + str(len(self.keyvalues['users'].keys()))) es.dbgmsg( 0, ' Options: ' + str(len(self.keyvalues['options'].keys()))) for option in self.keyvalues['options'].keys(): es.dbgmsg( 0, ' [' + str(self.keyvalues['options'][option]['keyname']) + ']: ' + self.keyvalues['options'][option]['display'])
def load(): es.dbgmsg(0, "[SH] Successfully loaded HobGoblin")
def error(self, commandname, error): n = self.currentline dbgmsg( 0, '[%s%s] %s: %s' % (self.currentblockname, ' %s' % n if n else '', commandname, error))
def echo(self): ''' Echos (prints) the current weapon order to console. ''' es.dbgmsg(0, ' ') es.dbgmsg(0, '[GunGame] ' + langstring('WeaponOrder:Echo', {'file': self.title})) es.dbgmsg(0, ' ') echo_string = langstring('WeaponOrder:Echo:TableColumns') echo_lengths = [len(x) for x in echo_string.split('|')[1:4]] echo_columns = '+'.join(['-' * x for x in echo_lengths]) + '+' es.dbgmsg(0, '[GunGame] +' + echo_columns) es.dbgmsg(0, '[GunGame] ' + echo_string) es.dbgmsg(0, '[GunGame] +' + echo_columns) for level in self.active: weapon = self.active[level].weapon multikill = self.active[level].kills es.dbgmsg(0, '[GunGame] |%s|%s|%s |' % ( str(level).center(echo_lengths[0]), str(multikill).center(echo_lengths[1]), weapon.rjust(echo_lengths[2] - 1))) es.dbgmsg(0, '[GunGame] +' + echo_columns)
def load(): es.dbgmsg(0, "[SH] Successfully loaded Invisible Man")
def load(): es.dbgmsg(0, "[SH] Successfully loaded Magneto")
def die(): stack.kill() es.dbgmsg(0, 'ESC code execution killed')
def printQueue(self): with self.lock: for i in self.nodes: es.dbgmsg(0, f"{i.name.rjust(8)} in {i.gotime - time.time()} seconds from now,\n {i.cmd}\n")
def clientcmd_cmd(args): """ Provides an easy way to create client or say commands that require authorization to use """ if len(args) > 1: arg0 = args[0].lower() # Creating commands if arg0 == 'create': if len(args) == 6: arg1 = args[1].lower() if arg1 in ('say', 'console'): permission = args[5].lower() if permission in flags: if arg1 == 'say': cmdlib.registerSayCommand( args[2].lower(), args[3], 'Permission-based say command', args[4], flags[permission]) else: cmdlib.registerClientCommand( args[2].lower(), args[3], 'Permission-based client console command', args[4], flags[permission]) else: # Sort flags for output from most restricted to least restricted sorted_flags = ', '.join( sorted(flags, key=lambda x: cmdlib.permissionToInteger( flags[x]))) es.dbgmsg( 0, '"' + permission + '" is an invalid permission flag for clientcmd.\nAcceptable flags are: ' + sorted_flags) else: es.dbgmsg( 0, 'Second parameter of clientcmd must be "say" or "console"' ) else: es.dbgmsg( 0, 'Incorrect number of parameters given to clientcmd create (expected 6, got %s)\nSyntax: clientcmd create <say/console> <command name> <block to call> <capability name> <permission level>' % len(args)) # Deleting commands elif arg0 == 'delete': if len(args) == 3: arg1 = args[1].lower() if arg1 == 'say': cmdlib.unregisterSayCommand(args[2]) elif arg1 == 'console': cmdlib.unregisterClientCommand(args[2]) else: es.dbgmsg( 0, 'Second parameter of clientcmd must be "say" or "console"' ) else: es.dbgmsg( 0, 'Incorrect number of parameters given to clientcmd delete (expected 3, got %s)\nSyntax: clientcmd delete <say/console> <command name>' % len(args)) else: es.dbgmsg( 0, 'First parameter of clientcmd must be "create" or "delete"') else: es.dbgmsg( 0, 'clientcmd must have "create" or "delete" as the first argument and "say" or "console" as the second' )
def exp_reg(args_dummy): argc = es.getargc() if argc > 3: global funcs global funcsregex global regex1 block = es.getargv(2) func = es.getargv(1) minargs = es.getargv(3) if not func in funcs: if re.match('^.+/.+(/.+)?$', block): if es.exists('block', block): if argc > 4: global funccmds userfunc = '_exp_userfunc' + str(len(funccmds) + 1) es.regcmd(userfunc, block, 'exp user function') funcs[func] = {} funccmds.append(userfunc) funcs[func]['function'] = userfunc funcs[func]['minargs'] = int(minargs) funcs[func]['var'] = es.getargv(4) funcsregex = '|'.join(funcs) regex1 = re.compile(funcsregex) else: es.dbgmsg( 0, 'exp_reg : input variable name must be given for function block' ) else: es.dbgmsg(0, 'exp_reg : invalid block given') elif re.match('^.+\\..+(\\..+)?$', block): temp = block.split('.') exec('temp = callable(' + block + ')') if temp: exec('funcs[func][\'function\'] = ' + block) funcs[func]['minargs'] = minargs funcsregex = '|'.join(funcs) regex1 = re.compile(funcsregex) else: es.dbgmsg(0, 'exp_reg : invalid function given') else: es.dbgmsg(0, 'exp_reg : invalid block/function given') else: es.dbgmsg(0, 'exp_reg : function already registered') else: es.dbgmsg( 0, 'Syntax : exp_reg <function-name> <function/block> <min-args> [var]' )
def load_menus(self): es.dbgmsg(0, langstring('Load_Commands')) for file_path in menu_folder.files('*_menu.py'): self._load(file_path)
def uxp_reg(args_dummy): argc = es.getargc() if argc > 2: global uxpfuncs global funcs global regex1 subcmd = es.getargv(1) if subcmd == 'create': if argc > 3: func = es.getargv(2) cmdstring = es.getargv(3) if func in funcs: es.dbgmsg(0, 'uxp_reg : function already registered') elif not '%var' in cmdstring: es.dbgmsg( 0, 'uxp_reg : %var MUST be included in command string') else: uxpfuncs.append(func) funcs[func] = {'uxp': cmdstring, 'minargs': 0} funcsregex = '|'.join(funcs) regex1 = re.compile(funcsregex) else: es.dbgmsg( 0, 'Syntax : uxp_reg create <function> <commandstring>') elif subcmd == 'delete': func = es.getargv(2) if func in uxpfuncs: del uxpfuncs[func] del funcs[func] funcsregex = '|'.join(funcs) regex1 = re.compile(funcsregex) elif subcmd == 'status': if argc > 3: var = es.getargv(2) func = es.getargv(3) if func in uxpfuncs: es.set(var, '1') else: es.set(var, '0') else: es.dbgmsg(0, 'Syntax : uxp_reg status <variable> <function>') else: es.dbgmsg(0, 'uxp_reg : invalid subcommand (create|delete|status)') else: es.dbgmsg(0, 'Syntax : uxp_reg <subcmd> <args>')
def load(): es.dbgmsg(0, "[SH] Successfully loaded Zeus")
def foreach_cmd(args): if len(args): subcmd = args[0].lower() if subcmd == 'player': if len(args) > 3: foreach_player(es.ServerVar(args[1], ''), args[2], args[3]) else: es.dbgmsg( 0, 'foreach player: Invalid arguments for foreach player. Syntax: foreach player <var> <identifier> "<command>"' ) elif subcmd == 'weapon': if len(args) > 3: foreach_weapon(es.ServerVar(args[1], ''), args[2], args[3]) else: es.dbgmsg( 0, 'foreach weapon: Invalid arguments for foreach weapon. Syntax: foreach weapon <var> <identifier> "<command>"' ) elif subcmd == 'entity': if len(args) > 4: foreach_entity(es.ServerVar(args[1], ''), es.ServerVar(args[2], ''), args[3], args[4]) else: es.dbgmsg( 0, 'foreach entity: Invalid arguments for foreach entity. Syntax: foreach entity <keyvar> <classvar> <classname> "<command>"' ) elif subcmd == 'token': if len(args) > 4: foreach_token(es.ServerVar(args[1], ''), args[2], args[3], args[4]) else: es.dbgmsg( 0, 'foreach: Invalid arguments for foreach token. Syntax: foreach token <var> "<string>" "<separator>" "<command>"' ) elif subcmd == 'part': if len(args) > 4: foreach_part(es.ServerVar(args[1], ''), args[2], args[3], args[4]) else: es.dbgmsg( 0, 'foreach: Invalid arguments for foreach part. Syntax: foreach part <var> "<string>" "<character count>" "<command>"' ) else: es.dbgmsg(0, 'foreach: Invalid subcommand for foreach') else: es.dbgmsg(0, 'foreach: Missing subcommand for foreach')
def load(): es.dbgmsg(0, "[SH] Successfully loaded Robin")
def printcount(argv): es.dbgmsg(0, str(global_vars.frame_count))
def default_event_registration(): import es es.dbgmsg(1, ' ** Registering files...') if not register_for_event_file('resource/modevents.res'): if not register_for_event_file('Resource/modevents.res'): es.dbgmsg(0, 'EventScripts] ERROR: Couldn\'t load modevents.res.') if not register_for_event_file('../hl2/resource/gameevents.res'): if not register_for_event_file('resource/gameevents.res'): es.dbgmsg(0, '[EventScripts] ERROR: Couldn\'t load gameevents.res.') if not register_for_event_file('../hl2/resource/serverevents.res'): if not register_for_event_file('resource/serverevents.res'): es.dbgmsg( 0, '[EventScripts] ERROR: Couldn\'t load serverevents.res.') if not register_for_event_file(str(ES_EVENTS_PATH)): es.dbgmsg(0, 'ERROR: COULDN\'T LOAD MATTIE CORE EVENTS!') es.dbgmsg(1, ' ** Done registering default event files.')
def consolecmd(): #Command from server console or non-python script subcmd = es.getargv(1).lower() pname = es.getargv(2) argc = es.getargc() if pname in popuplib.gPopups: p = popuplib.gPopups[pname] else: p = None debug = info if subcmd == "create": if pname: popuplib.create(pname) else: es.dbgmsg(0,"Syntax: popup create <popupname>") elif subcmd == "delete": if pname: if p: popuplib.delete(pname) else: es.dbgmsg(0,"Popup delete: No such popup: "+pname) else: es.dbgmsg(0,"Syntax: popup delete <popupname>") elif subcmd == "addline": if argc == 4: if p: text = str(es.getargv(3)) p.addline(text) else: es.dbgmsg(0,"Popup addline: No such popup: "+pname) else: es.dbgmsg(0,"Syntax: popup addline <popupname> <text>") elif subcmd == "delline": if argc == 4: if p: line = int(es.getargv(3)) p.delline(line) else: es.dbgmsg(0,"Popup delline: No such popup: "+pname) else: es.dbgmsg(0,"Syntax: popup delline <popupname> <line#>") elif subcmd == "insline": if argc == 5: if p: line = int(es.getargv(3)) text = str(es.getargv(4)) p.insline(line, text) else: es.dbgmsg(0,"Popup insline: No such popup: "+pname) else: es.dbgmsg(0,"Syntax: popup insline <popupname> <line#> <text>") elif subcmd == "modline": if argc == 5: if p: line = int(es.getargv(3)) text = str(es.getargv(4)) p.modline(line, text) else: es.dbgmsg(0,"Popup modline: No such popup: "+pname) else: es.dbgmsg(0,"Syntax: popup modline <popupname> <line#> <text>") elif subcmd == "prepuser": if argc == 4: if p: block = str(es.getargv(3)) if block == "0": block = "" p.prepuser = block else: es.dbgmsg(0,"Popup prepuser: No such popup: "+pname) else: es.dbgmsg(0,"Syntax: popup prepuser <popupname> <block>") elif subcmd == "menuselect": if argc == 4: if p: block = es.getargv(3) if block == "0": block = "" p.menuselect = block else: es.dbgmsg(0,"Popup menuselect: No such popup: "+pname) else: es.dbgmsg(0,"Syntax: popup menuselect <popupname> <block>") elif subcmd == "menuselectfb": if argc == 4: if p: block = es.getargv(3) if block == "0": block = "" p.menuselectfb = block else: es.dbgmsg(0,"Popup menuselectfb: No such popup: "+pname) else: es.dbgmsg(0,"Syntax: popup menuselectfb <popupname> <block>") elif subcmd == "select": if argc == 5: if p: item = int(es.getargv(3)) block = es.getargv(4) if block == "0": block = "" p.select(item, block) else: es.dbgmsg(0,"Popup select: No such popup: "+pname) else: es.dbgmsg(0,"Syntax: popup select <popupname> <choice#> <block>") elif subcmd == "submenu": if argc == 5: if p: item = int(es.getargv(3)) block = es.getargv(4) if block == "0": block = "" p.submenu(item, block) else: es.dbgmsg(0,"Popup submenu: No such popup: "+pname) else: es.dbgmsg(0,"Syntax: popup submenu <popupname> <choice#> <submenu>") elif subcmd == "menuvalue": if argc == 6: if p: item = int(es.getargv(4)) varn = es.getargv(3) varv = es.getargv(5) p.menuvalue(varn, item, varv) else: es.dbgmsg(0,"Popup menuvalue: No such popup: "+pname) else: es.dbgmsg(0,"Syntax: popup menuvalue <popupname> <variable> <choice#> <value>") elif subcmd == "timeout": if argc == 5: if p: tomode = es.getargv(3) time = float(es.getargv(4)) p.timeout(tomode, time) else: es.dbgmsg(0,"Popup timeout: No such popup: "+pname) else: es.dbgmsg(0,"Syntax: popup timeout <popupname> <mode> <time>") es.dbgmsg(0," mode: \"send\" or \"view\"") elif subcmd == "send": if argc == 5: try: prio = bool(int(es.getargv(4))) except ValueError: prio = False else: prio = False if argc >= 4: if p: users = es.getargv(3) p.send(playerlib.getUseridList(users),prio) else: es.dbgmsg(0,"Popup send:No such popup: "+pname) else: es.dbgmsg(0,"Syntax: popup send <popupname> <users>") elif subcmd == "unsendname": if argc == 4: if p: users = es.getargv(3) popuplib.unsendname(pname, playerlib.getUseridList(users)) else: es.dbgmsg(0,"Popup unsendname: No such popup: "+pname) else: es.dbgmsg(0,"Syntax: popup unsendname <popupname> <users>") elif subcmd == "close": if argc == 4: if p: users = es.getargv(3) popuplib.close(pname, playerlib.getUseridList(users)) else: es.dbgmsg(0,"Popup close: No such popup: "+pname) else: es.dbgmsg(0,"Syntax: popup close <popupname> <users>") elif subcmd == "isqueued": if argc == 5: if p: retvar = es.getargv(3) userid = int(es.getargv(4)) es.set(retvar,popuplib.isqueued(pname,userid)) else: es.dbgmsg(0,"Popup isqueued: No such popup: "+pname) else: es.dbgmsg(0,"Syntax: popup isqueued <popupname> <var> <userid>") elif subcmd == "active": if argc == 5: retvar = es.getargv(3) userid = int(es.getargv(4)) try: r = popuplib.active(userid) es.set(pname,r['name']) es.set(retvar,r['count']) except KeyError: es.dbgmsg(0,"Popup active: No userid "+str(userid)+" on server.") else: es.dbgmsg(0,"Syntax: popup active <name var> <count var> <userid>") elif subcmd == "exists": if argc == 4: retvar = es.getargv(3) es.set(retvar,int(popuplib.exists(pname))) else: es.dbgmsg(0,"Syntax: popup exists <popupname> <var>") elif subcmd == "addlinef": if argc > 3: if p: text = _formatv(3) p.addline(text) else: es.dbgmsg(0,"Popup addlinef: No such popup: "+pname) else: es.dbgmsg(0,"Syntax: popup addlinef <popupname> <format> [vartoken1] ... [vartoken9]") elif subcmd == "inslinef": if argc > 4: if p: line = int(es.getargv(3)) text = _formatv(4) p.insline(line,text) else: es.dbgmsg(0,"Popup inslinef: No such popup: "+pname) else: es.dbgmsg(0,"Syntax: popup inslinef <popupname> <line#> <format> [vartoken1] ... [vartoken9]") elif subcmd == "modlinef": if argc > 4: if p: line = int(es.getargv(3)) text = _formatv(4) p.modline(line,text) else: es.dbgmsg(0,"Popup modlinef: No such popup: "+pname) else: es.dbgmsg(0,"Syntax: popup modlinef <popupname> <line#> <format> [vartoken1] ... [vartoken9]") elif subcmd == "cachemode": if argc == 4: if p: tomode = es.getargv(3) p.cachemode = tomode else: es.dbgmsg(0,"Popup cachemode: No such popup: "+pname) else: es.dbgmsg(0,"Syntax: popup cachemode <popupname> <mode>") es.dbgmsg(0," mode: \"global\", \"static\" or \"user\"") elif subcmd == "recache": if argc > 2: if p: if argc == 4: users = playerlib.getUseridList(es.getargv(3)) p.recache(users) else: p.recache() else: es.dbgmsg(0,"Popup recache: No such popup: "+pname) else: es.dbgmsg(0,"Syntax: popup recache <popupname> [users]") elif subcmd == "update": if argc == 4: if p: users = playerlib.getUseridList(es.getargv(3)) p.update(users) else: es.dbgmsg(0,"Popup update: No such popup: "+pname) else: es.dbgsmg(0,"Syntax: popup update <popupname> <users>") elif subcmd == "displaymode": if argc == 4: if p: tomode = es.getargv(3) p.displaymode = tomode else: es.dbgmsg(0,"Popup displaymode: No such popup: "+pname) else: es.dbgmsg(0,"Syntax: popup displaymode <popupname> <mode>") es.dbgmsg(0," mode: \"normal\" or \"sticky\"") elif subcmd == "construct": if argc == 6: varp = es.getargv(5) else: varp = "_popup_choice" if argc >= 5: plist = es.getargv(3) pflags = es.getargv(4) nep = popuplib.construct(pname,plist,pflags) nep.c_savevar = varp else: es.dbgmsg(0,"Syntax: popup construct <popupname> <list> <flags> [var]") elif subcmd == "setvar": if argc == 5: if p: ok = False varp = es.getargv(3) if varp.isalnum(): ok = True else: if varp[:2] == "c_" and varp[2:].isalnum(): ok = True varv = es.getargv(4) if ok: p.__setattr__(varp,varv) else: es.dbgmsg(0,"Invalid popup variable name") else: es.dbgmsg(0,"Popup setvar: No such popup: "+pname) else: es.dbgmsg(0,"Syntax: popup setvar <popupname> <variable> <value>") elif subcmd == "getvar": if argc == 5: if p: ok = False varp = es.getargv(3) varv = es.getargv(4) if varv.isalnum(): ok = True else: if varv[:2] == "c_" and varv[2:].isalnum(): ok = True if ok: es.set(varp, p.__getattr__(varv)) else: es.dbgmsg(0,"Invalid popup variable name") else: es.dbgmsg(0,"Popup getvar: No such popup: "+pname) else: es.dbgmsg(0,"Syntax: popup getvar <popupname> <var> <variable>") elif subcmd == "easymenu": if argc == 5: varp = es.getargv(3) block = es.getargv(4) popuplib.easymenu(pname,varp,block) else: es.dbgmsg(0,"Syntax: popup easymenu <popupname> <var> <block>") elif subcmd == "addoption": if argc > 4: if p: item = str(es.getargv(3)) text = str(es.getargv(4)) if argc == 6: state = int(es.getargv(5)) else: state = 1 p.addoption(item, text, state) else: es.dbgmsg(0,"Easymenu addoption: No such popup: "+pname) else: es.dbgmsg(0,"Syntax: popup addoption <popupname> <value> <text> [state]") elif subcmd == "setoption": if argc > 3: if p: item = int(es.getargv(3)) if argc == 5: text = es.getargv(4) if int(text) > 0 and int(text) <= 2 or str(text) == '0': p.setoption(item,None,int(text)) else: p.setoption(item,text,None) elif argc == 6: text = es.getargv(4) state = int(es.getargv(5)) p.setoption(item,text,state) else: es.dbgmsg(0,"Easymenu setoption: No such popup: "+pname) else: es.dbgmsg(0,"Syntax: popup setoption <popupname> <item> [text] [state]") elif subcmd == "description": if argc == 4: if p: text = es.getargv(3) p.setdescription(text) else: es.dbgmsg(0,"Popup description: No such popup: "+pname) else: es.dbgmsg(0,"Usage: popup description <popupname> <text>") elif subcmd == "info": if argc >= 3: if argc == 4: listlevel = int(es.getargv(3)) else: listlevel = 4 if p: p.information(listlevel) else: es.dbgmsg(0, "Syntax: popup info <popupname> [level]") elif subcmd == "emulate": if argc == 5: if p: item = int(es.getargv(3)) users = es.getargv(4) popuplib.emulate(pname,item,users) else: es.dbgmsg(0,"Popup emulate: No such popup: "+pname) else: es.dbgmsg(0,"Syntax: popup emulate <popupname> <choice#> <users>") elif subcmd == "editlang": if argc == 4: if p: p.editlang = str(es.getargv(3)) else: es.dbgmsg(0,"Popup editlang: No such popup: "+pname) else: es.dbgmsg(0,"Syntax: popup editlang <popupname> <language>") elif subcmd == "setstyle": if argc >= 3: style = es.getargv(argc-1) passvalue = 0 if style.startswith("radio"): passvalue |= 1 if style.startswith("esc"): passvalue |= 2 if style.endswith("!"): passvalue |= 128 if argc == 4: if p: p.visualstyle = passvalue else: es.dbgmsg(0,"Popup setstyle: No such popup: "+pname) else: popuplib.gameSupportAdmin = passvalue else: es.dbgmsg(0,"Syntax: popup setstyle [popupname] {auto|radio|esc}[!]") elif subcmd == "quicksend": if argc == 6: block = str(es.getargv(5)) else: block = "" if argc > 4: time = float(es.getargv(2)) userid = float(es.getargv(3)) text = str(es.getargv(4)) popuplib.quicksend(time,userid,text,block) else: es.dbgmsg(0,"Syntax: popup quicksend <time> <userid> <text> [block]") elif subcmd == "list": es.dbgmsg(0,"---------- List of popups:") if argc == 2: listlevel = 0 else: listlevel = int(pname) for pname in popuplib.gPopups: p = popuplib.gPopups[pname] p.information(listlevel) if argc == 2: es.dbgmsg(0, " ") es.dbgmsg(0, "For more details, supply list level (0-4):") es.dbgmsg(0, "Syntax: popup list [level]") es.dbgmsg(0,"----------") else: es.dbgmsg(0,"Invalid popup subcommand, see http://www.eventscripts.com/pages/Popup/ for help")
def dbgmsg(argv): if len(argv) > 1: es.dbgmsg(atoi(argv[0]), ' '.join(argv[1:])) else: raise SyntaxError
def load_orders(self): es.dbgmsg(0, langstring("Load_WeaponOrders")) # Register for the server_cvar event es.addons.registerForEvent(self, 'server_cvar', self.server_cvar) for orderPath in weaponOrderFilesTXT: # + weaponOrderFilesINI weaponOrderStorage.add(orderPath)
def keymenu_cmd(args): if len(args): subcmd = args[0].lower() if len(args) > 1: kname = args[1] else: kname = '' if len(kname) and keymenulib.exists(kname): k = keymenulib.find(kname) else: k = None if subcmd == 'create': if len(args) > 6: index = 5 titletext = '' if args[index] == '#key': menudisplay = args[index] index += 1 elif args[index] == '#keyvalue': menudisplay = args[index] + ' ' + args[index+1] index += 2 if args[index] == '#key': menureturn = args[index] index += 1 elif args[index] == '#keyvalue': menureturn = args[index] + ' ' + args[index+1] index += 2 for subindex in range(index, len(args)): titletext += args[subindex] + ' ' keymenulib.create(kname, args[2], args[3], args[4], menudisplay, menureturn, titletext.rstrip()) else: es.dbgmsg(0, 'Syntax: keymenu create <name> <return var> <script/block> <keygroup> <menu display> <menu return> Menu Title Text') elif subcmd == 'delete': if kname and len(args) > 1: if k: keymenulib.delete(kname) else: es.dbgmsg(0, 'keymenu delete: No such keymenu: %s' % kname) else: es.dbgmsg(0, 'Syntax: keymenu delete <name>') elif subcmd == 'send': if kname and len(args) > 2: if k: if '#' in args[2]: args[2] = args[2].replace('#', ',#')[1:] if len(args) > 3 and args[3].isdigit(): k.send(playerlib.getUseridList(args[2]), int(args[3])) else: k.send(playerlib.getUseridList(args[2])) else: es.dbgmsg(0, 'keymenu send: No such keymenu: %s' % kname) else: es.dbgmsg(0, 'Syntax: keymenu send <name> <users> [page]') elif subcmd == 'unsend': if kname and len(args) > 2: if k: if '#' in args[2]: args[2] = args[2].replace('#', ',#')[1:] if len(args) > 3 and args[3].isdigit(): k.unsend(playerlib.getUseridList(args[2]), int(args[3])) else: k.unsend(playerlib.getUseridList(args[2])) else: es.dbgmsg(0, 'keymenu unsend: No such keymenu: %s' % kname) else: es.dbgmsg(0, 'Syntax: keymenu unsend <name> <users> [page]') elif subcmd == 'update': if kname and len(args) > 1: if k: if len(args) > 2: if es.exists('keygroup', args[2]): k.update(args[2]) else: es.dbgmsg(0, 'keymenu update: No such keygroup: %s' % args[2]) else: k.update() else: es.dbgmsg(0, 'keymenu update: No such keymenu: %s' % kname) else: es.dbgmsg(0, 'Syntax: keymenu update <name> [keygroup]') elif subcmd == 'exists': if len(args) > 2: es.ServerVar(args[1]).set(int(keymenulib.exists(args[2]))) else: es.dbgmsg(0, 'Syntax: keymenu exists <var> <name>') elif subcmd == 'getpages': if len(args) > 2: if keymenulib.exists(args[2]): es.ServerVar(args[1]).set(int(keymenulib.find(args[2]).getpages())) else: es.dbgmsg(0, 'keymenu getpages: No such keymenu: %s' % args[2]) else: es.dbgmsg(0, 'Syntax: keymenu getpages <var> <name>') elif subcmd == 'getmenuname': if len(args) > 2: if popuplib.exists(args[2]): es.ServerVar(args[1]).set(str(keymenulib.getmenuname(args[2]))) else: es.dbgmsg(0, 'keymenu getmenuname: No such popup: %s' % args[2]) else: es.dbgmsg(0, 'Syntax: keymenu getmenuname <var> <popup-name>') elif subcmd == 'changeblock': if len(args) > 2: if k: k.changeblock(args[2]) else: es.dbgmsg(0, 'keymenu changeblock: No such keymenu: %s' % kname) else: es.dbgmsg(0, 'Syntax: keymenu changeblock <name> <script/block>') elif subcmd == 'backmenu': if len(args) > 2: if k: k.backmenu(args[2]) else: es.dbgmsg(0, 'keymenu backmenu: No such keymenu: %s' % kname) else: es.dbgmsg(0, 'Syntax: keymenu backmenu <name> <keymenu/popup>') elif subcmd == 'setvar': if len(args) > 3: if k: if args[2].isalnum(): setattr(k, args[2], args[3]) else: es.dbgmsg(0, 'keymenu setvar: Invalid keymenu variable name') else: es.dbgmsg(0, 'keymenu setvar: No such keymenu: %s' % kname) else: es.dbgmsg(0, 'Syntax: keymenu setvar <name> <variable> <value>') elif subcmd == 'getvar': if len(args) > 4: if k: if args[3].isalnum() and hasattr(k, args[3]): es.ServerVar(args[2]).set(getattr(k, args[3])) else: es.dbgmsg(0, 'keymenu getvar: Invalid keymenu variable name') else: es.dbgmsg(0, 'keymenu getvar: No such keymenu: %s' % kname) else: es.dbgmsg(0, 'Syntax: keymenu getvar <name> <var> <variable>') elif subcmd == 'list': if len(args) > 1: listlevel = int(kname) else: listlevel = 0 for kname in keymenulib.getmenulist(): keymenulib.find(kname).information(listlevel) if not len(args) > 1: es.dbgmsg(0, ' ') es.dbgmsg(0, 'For more details, supply list level (0-1):') es.dbgmsg(0, 'Syntax: keymenu list [level]') elif subcmd == 'info': if k: k.information(listlevel, 1) else: es.dbgmsg(0, 'keymenu info: No such keymenu: %s' % kname) if not len(args) > 1: es.dbgmsg(0, ' ') es.dbgmsg(0, 'Syntax: keymenu info <name>') else: es.dbgmsg(0, 'Invalid keymenu subcommand, see http://www.eventscripts.com/pages/Keymenu/ for a list of subcommands') else: es.dbgmsg(0, 'Missing keymenu subcommand, see http://www.eventscripts.com/pages/Keymenu/ for a list of subcommands')