def load(): config.execute() lmv['command'] = str(lmv_command) if lmv['command']: cmdlib.registerSayCommand(lmv['command'],sendVote,'Send Player Vote popup') cmdlib.registerClientCommand(lmv['command'],sendVote,'Send Player Vote popup') ini = cfglib.AddonINI(addonpath + '/strings.ini') ini.addValueToGroup('Vote on GamePlay','en','Vote for next GamePlay:') ini.addValueToGroup('Vote on Map','en','Vote on a Map:') ini.addValueToGroup('Start GamePlay Vote','en','#green[LooneyMapVote]#default Use the command "#lightgreen$command#default" to vote for the next GamePlay') ini.addValueToGroup('End GamePlay Vote','en','#green[LooneyMapVote]#default Next GamePlay will be#lightgreen $gameplay#default!') ini.addValueToGroup('Start Map Vote','en','#green[LooneyMapVote]#default Use the command "#lightgreen$command#default" to Vote for the next Map') ini.addValueToGroup('End Map Vote','en','#green[LooneyMapVote]#default Next Map is#lightgreen $nextmap#default!') ini.addValueToGroup('Vote Not Started','en','#green[LooneyMapVote]#default Vote has not started yet') ini.addValueToGroup('Between Votes','en','#green[LooneyMapVote]#default Please wait to use this command, we are between votes') ini.addValueToGroup('Vote Over','en','#green[LooneyMapVote]#default Sorry, voting is over') ini.addValueToGroup('NextMap Decided','en','#green[LooneyMapVote]#default NextMap has already been decided.#lightgreen NextMap#default:#green $nextmap') ini.addValueToGroup('Already Voted','en','#green[LooneyMapVote]#default You already voted for#lightgreen $playervote') ini.addValueToGroup('Player Vote','en','#green[LooneyMapVote]#default $player voted for#lightgreen $choice') ini.addValueToGroup('Time Remaining','en','#green[LooneyMapVote]#default Vote ends in $seconds seconds') ini.addValueToGroup('One Second Remains','en','#green[LooneyMapVote]#default Vote ends in 1 second') lmv['maps'] = cfglib.AddonINI(addonpath + '/maptypes.ini') for mapbsp in os.listdir(str(es.ServerVar('eventscripts_gamedir')) + '/maps/'): if not mapbsp.endswith('.bsp'): continue mapname = mapbsp[0:~3] if mapname in str(lmv_maps_to_not_use).split(','): continue allmaps.add(mapname) if notInHeader(mapname): prefix = mapname.split('_')[0] + '_' lmv['maps'].addValueToGroup(prefix,getNumber(prefix),mapname) lmv['maps'].write() serverlang = langlib.getDefaultLang() for gameplay in lmv['maps']: ini.addValueToGroup(gameplay,serverlang,gameplay) first = True for group in ini: if first: first = False else: ini.setGroupComments(group,'') ini.write() lmv['lang'] = langlib.Strings(ini) if lmv_scripts_for_gameplay: scriptpath = addonpath + '/scriptmanager' if not os.path.isdir(scriptpath): os.makedirs(scriptpath) for gameplay in lmv['maps']: gameplay_ini[gameplay] = cfglib.AddonINI(scriptpath + '/%s.ini'%gameplay) gameplay_ini[gameplay].addValueToGroup('Scripts','1','') gameplay_ini[gameplay].setGroupComments('Scripts',['Set scripts to be loaded for maptype below','Use a different number for each and follow the same syntax']) gameplay_ini[gameplay].addValueToGroup('Configs','1','') gameplay_ini[gameplay].setGroupComments('Configs',['Set .cfg files to be executed for maptype below','Use a different number for each and follow the same syntax','Please use the path relative to <gamename>','For instance, if your cfg is in <gamename>/cfg/myconfigs/configone.cfg, you would use "cfg/myconfigs/configone"']) gameplay_ini[gameplay].write() mapVote.mapStart(str(lmv_default_gameplay)) mapVote.resetMapVote(str(es.ServerVar('eventscripts_currentmap'))) startTimeVote()
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 load(): """ Executed when the script loads. Ensure that the admin menu is built and all of the options are either other popups or functions we can call. """ sourcerpg.addons.addAddon(addonName) cmdlib.registerSayCommand("rpg_admin", admin.mainCommand, "The command to open the admin menu", "sourcerpg_admin", "ADMIN", admin.failCommand) cmdlib.registerSayCommand("rpgadmin", admin.mainCommand, "The command to open the admin menu", "sourcerpg_admin", "ADMIN", admin.failCommand) """ Register the client commands so we can use escape boxes """ cmdlib.registerClientCommand("rpgaddxp", admin.clientAddXp, "The command to add experience to a target", "sourcerpg_admin", "ADMIN", admin.failCommand) cmdlib.registerClientCommand("rpgaddlevels", admin.clientAddLevels, "The command to add levels to a target", "sourcerpg_admin", "ADMIN", admin.failCommand) cmdlib.registerClientCommand("rpgaddcredits", admin.clientAddCredits, "The command to add credits to a target", "sourcerpg_admin", "ADMIN", admin.failCommand) cmdlib.registerServerCommand("rpgaddxp", admin.clientAddXp, "rpgaddxp <steamid/username> <amount>") cmdlib.registerServerCommand("rpgaddlevels", admin.clientAddLevels, "rpgaddlevels <steamid/username> <amount>") cmdlib.registerServerCommand("rpgaddcredits", admin.clientAddCredits, "rpgaddcredits <steamid/username> <amount>") """ Create the confirmation menu """ confirmation = popuplib.easymenu("sourcerpg_confirmDeleteDatabase", "_popup_choice", popup.confirmation) confirmation.settitle("=== %s Confirmation ===" % sourcerpg.prefix) confirmation.setdescription("""\ !!! WARNING !!! This is an irriversable effect! Once you remove this database, you cannot get it back. All skills / levels will be destroyed. Are you sure you want to continue?""") confirmation.addoption(True, "Yes") confirmation.addoption(False, "No") """ Build the admin menu """ admin.addOption( popup.buildOnlinePlayers, "Online Players") admin.addOption( popup.buildOfflinePlayers, "Offline Players (Warning, may lag)" ) admin.addOption( popup.buildSkills, "Load/Unload Skills" ) admin.addOption( popup.buildAddons, "Load/Unload Addons" ) admin.addOption( "sourcerpg_confirmDeleteDatabase", "Delete Database" )
def load(): """ Executed when the script loads. Ensure that the admin menu is built and all of the options are either other popups or functions we can call. """ sourcerpg.addons.addAddon(addonName) cmdlib.registerSayCommand("rpg_admin", admin.mainCommand, "The command to open the admin menu", "sourcerpg_admin", "ADMIN", admin.failCommand) cmdlib.registerSayCommand("rpgadmin", admin.mainCommand, "The command to open the admin menu", "sourcerpg_admin", "ADMIN", admin.failCommand) """ Register the client commands so we can use escape boxes """ cmdlib.registerClientCommand("rpgaddxp", admin.clientAddXp, "The command to add experience to a target", "sourcerpg_admin", "ADMIN", admin.failCommand) cmdlib.registerClientCommand("rpgaddlevels", admin.clientAddLevels, "The command to add levels to a target", "sourcerpg_admin", "ADMIN", admin.failCommand) cmdlib.registerClientCommand("rpgaddcredits", admin.clientAddCredits, "The command to add credits to a target", "sourcerpg_admin", "ADMIN", admin.failCommand) cmdlib.registerServerCommand("rpgaddxp", admin.clientAddXp, "rpgaddxp <steamid/username> <amount>") cmdlib.registerServerCommand("rpgaddlevels", admin.clientAddLevels, "rpgaddlevels <steamid/username> <amount>") cmdlib.registerServerCommand("rpgaddcredits", admin.clientAddCredits, "rpgaddcredits <steamid/username> <amount>") """ Create the confirmation menu """ confirmation = popuplib.easymenu("sourcerpg_confirmDeleteDatabase", "_popup_choice", popup.confirmation) confirmation.settitle("=== %s Confirmation ===" % sourcerpg.prefix) confirmation.setdescription("""\ !!! WARNING !!! This is an irriversable effect! Once you remove this database, you cannot get it back. All skills / levels will be destroyed. Are you sure you want to continue?""") confirmation.addoption(True, "Yes") confirmation.addoption(False, "No") """ Build the admin menu """ admin.addOption(popup.buildOnlinePlayers, "Online Players") admin.addOption(popup.buildOfflinePlayers, "Offline Players (Warning, may lag)") admin.addOption(popup.buildSkills, "Load/Unload Skills") admin.addOption(popup.buildAddons, "Load/Unload Addons") admin.addOption("sourcerpg_confirmDeleteDatabase", "Delete Database")
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] 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 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' )
with CFG_ADVERTS_PATH.open('r') as file: lines = file.readlines() with CFG_ADVERTS_PATH.open('w') as file: for line in lines: if not line.startswith('//'): line_split = line.replace('\n', '').split('|', 1) if len(line_split) == 2: line = line_split[1] else: line = line_split[0] if line != pure_ad: if line.endswith('\n'): file.write(line) else: file.write(line + '\n') if new_adverts: adverts = cycle(new_adverts) else: adverts = None break else: if userid: es.cexec(userid, "echo No advert found") else: print('No advert found') cmdlib.registerClientCommand('add_advert', addAdvertClient, 'adds an advert', 'add_ad_permission', 'ADMIN') cmdlib.registerClientCommand('delete_advert', deleteAdvertClient, 'deletes an advert', 'add_ad_permission', 'ADMIN') cmdlib.registerServerCommand('add_advert', addAdvertServer, 'adds an advert') cmdlib.registerServerCommand('delete_advert', deleteAdvertServer, 'deletes an advert')