def execute(self, args): """ When told to execute the function we need to pass the userid of the player who used the command as well as the command's arguments. We also need to determine if the player is authorized to use the command. """ userid = es.getcmduserid() # No auth? No fuss. if not self.auth_capability is None: # Check whether the userid is authorized is_authed = services.use('auth').isUseridAuthorized(userid, self.auth_capability) if not is_authed: # If a callback has been specified for auth failure then execute that function if self.auth_fail_callback: if isinstance(self.auth_fail_callback, collections.Callable): self.auth_fail_callback(userid, args) else: es.doblock(self.auth_fail_callback) # We have yet to inform the player they aren't authorized so we need to do it else: es.tell(userid, 'You are not authorized to use the ' + self.name + ' command.') return if isinstance(self.callback, collections.Callable): self.callback(userid, args) else: es.server.queuecmd('es_xdoblock ' + self.callback)
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(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 load(): """ This method executes when the script loads. Register the skill """ sourcerpg.skills.addSkill(skillName, maxLevel, creditStart, creditIncrement) es.doblock("corelib/noisy_on")
def execute(self, args): """ When told to execute the function we need to pass the userid of the player who used the command as well as the command's arguments. We also need to determine if the player is authorized to use the command. """ userid = es.getcmduserid() # No auth? No fuss. if not self.auth_capability is None: # Check whether the userid is authorized is_authed = services.use('auth').isUseridAuthorized(userid, self.auth_capability) if not is_authed: # If a callback has been specified for auth failure then execute that function if self.auth_fail_callback: if callable(self.auth_fail_callback): self.auth_fail_callback(userid, args) else: es.doblock(self.auth_fail_callback) # We have yet to inform the player they aren't authorized so we need to do it else: es.tell(userid, 'You are not authorized to use the ' + self.name + ' command.') return if callable(self.callback): self.callback(userid, args) else: es.server.queuecmd('es_xdoblock ' + self.callback)
def stop(self, cancel=None, internal=None): if self.running: self.popup.unsend(playerlib.getUseridList("#human")) self.popup.delete() self.popup = None if self.endblock: if cancel: gVariables['vote_name'].set(self.name) gVariables['vote_id'].set(0) gVariables['vote_text'].set(0) gVariables['vote_count'].set(0) gVariables['vote_percent'].set(0) gVariables['vote_votes'].set(self.votes) gVariables['vote_tie'].set(0) gVariables['vote_canceled'].set(1) else: gVariables['vote_name'].set(self.name) gVariables['vote_votes'].set(self.votes) gVariables['vote_canceled'].set(0) gVariables['vote_count'].set(0) for option in self.options: if int(self.options[option]) > int( gVariables['vote_count']): gVariables['vote_id'].set(option) gVariables['vote_text'].set( self.options[option].getText()) gVariables['vote_count'].set( self.options[option].submits) gVariables['vote_tie'].set(0) gVariables['vote_percent'].set( int((self.options[option].submits * 100) / self.votes) if self.votes > 0 else 100) elif int(self.options[option]) == int( gVariables['vote_count']) and int( gVariables['vote_count']) > 0: gVariables['vote_tie'].set(1) if callable(self.endblock): self.endblock( self.name, int(gVariables['vote_id']), str(gVariables['vote_text']), int(gVariables['vote_count']), int(gVariables['vote_percent']), self.votes, True if int(gVariables['vote_tie']) else False, True if cancel else False) else: es.doblock(self.endblock) self.running = False self.votes = 0 self.time = 0 for userid in gUsers: user = gUsers[userid] user.state[self.name] = False user.voted[self.name] = None else: es.dbgmsg( 0, "Votelib: Cannot stop vote '%s', it is not running" % self.name)
def _keymenu_select(userid, choice, popupid): # handling selected option popup/keymenu if popuplib.exists(popupid): k = find(getmenuname(popupid)) if k.block: if callable(k.block): k.block(userid, choice, k.name) else: es.doblock(k.block)
def stop(self, cancel=None, internal=None): if self.running: self.popup.unsend(playerlib.getUseridList("#human")) self.popup.delete() self.popup = None if self.endblock: if cancel: gVariables["vote_name"].set(self.name) gVariables["vote_id"].set(0) gVariables["vote_text"].set(0) gVariables["vote_count"].set(0) gVariables["vote_percent"].set(0) gVariables["vote_votes"].set(self.votes) gVariables["vote_tie"].set(0) gVariables["vote_canceled"].set(1) else: gVariables["vote_name"].set(self.name) gVariables["vote_votes"].set(self.votes) gVariables["vote_canceled"].set(0) gVariables["vote_count"].set(0) for option in self.options: if int(self.options[option]) > int(gVariables["vote_count"]): gVariables["vote_id"].set(option) gVariables["vote_text"].set(self.options[option].getText()) gVariables["vote_count"].set(self.options[option].submits) gVariables["vote_tie"].set(0) gVariables["vote_percent"].set( int((self.options[option].submits * 100) / self.votes) if self.votes > 0 else 100 ) elif ( int(self.options[option]) == int(gVariables["vote_count"]) and int(gVariables["vote_count"]) > 0 ): gVariables["vote_tie"].set(1) if callable(self.endblock): self.endblock( self.name, int(gVariables["vote_id"]), str(gVariables["vote_text"]), int(gVariables["vote_count"]), int(gVariables["vote_percent"]), self.votes, True if int(gVariables["vote_tie"]) else False, True if cancel else False, ) else: es.doblock(self.endblock) self.running = False self.votes = 0 self.time = 0 for userid in gUsers: user = gUsers[userid] user.state[self.name] = False user.voted[self.name] = None else: es.dbgmsg(0, "Votelib: Cannot stop vote '%s', it is not running" % self.name)
def doblock(argv): block = argv[0] split = splitblock(block) if split: addonname, blockname = split if blockexists(addonname, blockname): addons[addonname].blocks[blockname].run() else: sv.save() es.doblock(block)
def server_cvar(event_var): # Change "eventscripts_noisy" due to "gg_spawn_protect_cancelonfire"? if event_var['cvarname'] == 'gg_spawn_protect_cancelonfire': if int(event_var['cvarvalue']) >= 1: # Set noisy vars es.doblock('corelib/noisy_on') else: # Set noisy back es.doblock('corelib/noisy_off')
def load(): """ This method executes when the script loads. Register the skill """ sourcerpg.skills.addSkill( skillName, maxLevel, creditStart, creditIncrement ) es.doblock("corelib/noisy_on") """ Add any active people to the list when the mod loads """ for player in es.getUseridList(): ammo.addPlayer(player)
def load(): chat.hook("window.chat", None) es.doblock('corelib/noisy_on') chat.registerPublicCommand("!lj", lj_toggle, True) chat.registerPublicCommand("!ljstats", lj_toggle, True) chat.registerPublicCommand("!rb", lj_toggle, True) chat.registerPublicCommand("!rbstats", lj_toggle, True) chat.registerHiddenCommand('/lj', lj_toggle, True) chat.registerHiddenCommand('/ljstats', lj_toggle, True) chat.registerHiddenCommand('/rb', lj_toggle, True) chat.registerHiddenCommand('/rbstats', lj_toggle, True)
def Explosion(self, origin, IMagniTude=400, IRadiusOverride=150, FireBallSprite='sprites/ar2_muzzle1.vmt', RenderMode=18, HOwner=None, Name='Explosion'): if self.getUserid() and origin: #index = es.createentity('env_explosion', Name+str(self.unique)) #index = spe.getEntityIndex(spe.createEntity('env_explosion')) es.ServerVar('wcs_userid').set(self.getUserid()) es.doblock('tools/explosion/env_explosion')
def submit(self, pUsers, option, force=False): try: # try if pUsers is just a single userid userid = int(pUsers) pUsers = [userid] except TypeError: pass if self.running and self.popup and self.isValidOption(option): for userid in pUsers: if not userid in gUsers: gUsers[userid] = Vote_user(userid) if not self.name in gUsers[userid].state: gUsers[userid].state[self.name] = False if not self.name in gUsers[userid].voted: gUsers[userid].voted[self.name] = 0 if not gUsers[userid].state[self.name]: self.options[option].add() self.votes += 1 gUsers[userid].state[self.name] = True gUsers[userid].voted[self.name] = option elif force: if gUsers[userid].voted[self.name]: self.options[gUsers[userid].voted[self.name]].sub self.votes -= 1 self.options[option].add() self.votes += 1 gUsers[userid].state[self.name] = True gUsers[userid].voted[self.name] = option if self.subblock and gUsers[userid].voted[self.name] == option: gVariables['vote_name'].set(self.name) gVariables['vote_id'].set(option) gVariables['vote_text'].set(self.options[option].getText()) gVariables['vote_userid'].set(userid) if callable(self.subblock): self.subblock(userid, self.name, option, self.options[option].getText()) else: es.doblock(self.subblock) if self.enduser and self.votes >= len( playerlib.getUseridList("#human")): self.endtime = True self.time = 1 elif not self.running: es.dbgmsg( 0, "Votelib: Cannot submit vote '%s', it is not running" % self.name)
def fire1(self, userid, BaseSpread, SpreadSpeed, Speed, StartSize, EndSize, Rate, JetLength, RenderColor, RenderMode, RenderAmt, SmokeMaterial, Angles, Twist, Delayed, Name): if self.getUserid() and es.exists('userid', userid): es.ServerVar('wcs_userid').set(self.getUserid()) es.doblock('wcs/tools/smokestack/env_smokestack')
def submit(self, pUsers, option, force=False): try: # try if pUsers is just a single userid userid = int(pUsers) pUsers = [userid] except TypeError: pass if self.running and self.popup and self.isValidOption(option): for userid in pUsers: if not userid in gUsers: gUsers[userid] = Vote_user(userid) if not self.name in gUsers[userid].state: gUsers[userid].state[self.name] = False if not self.name in gUsers[userid].voted: gUsers[userid].voted[self.name] = 0 if not gUsers[userid].state[self.name]: self.options[option].add() self.votes += 1 gUsers[userid].state[self.name] = True gUsers[userid].voted[self.name] = option elif force: if gUsers[userid].voted[self.name]: self.options[gUsers[userid].voted[self.name]].sub self.votes -= 1 self.options[option].add() self.votes += 1 gUsers[userid].state[self.name] = True gUsers[userid].voted[self.name] = option if self.subblock and gUsers[userid].voted[self.name] == option: gVariables['vote_name'].set(self.name) gVariables['vote_id'].set(option) gVariables['vote_text'].set(self.options[option].getText()) gVariables['vote_userid'].set(userid) if isinstance(self.subblock, collections.Callable): self.subblock(userid, self.name, option, self.options[option].getText()) else: es.doblock(self.subblock) if self.enduser and self.votes >= len(playerlib.getUseridList("#human")): self.endtime = True self.time = 1 elif not self.running: es.dbgmsg(0,"Votelib: Cannot submit vote '%s', it is not running"%self.name)
def fire(self, origin, BaseSpread, SpreadSpeed, Initial, Speed, StartSize, EndSize, Rate, JetLength, RenderColor, RenderMode, RenderAmt, SmokeMaterial, Angles, Twist, Delayed, Name, Userid): if self.getUserid() and origin: #index = es.createentity('env_smokestack', Name+str(self.unique)) #index = spe.getEntityIndex(spe.createEntity('env_smokestack')) es.ServerVar('wcs_userid').set(self.getUserid()) es.doblock('wcs/tools/smokestack/env_smokestack')
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(): """ This method executes when the script unloads. Unregister the skill """ sourcerpg.skills.removeSkill(skillName) es.doblock("corelib/noisy_off")
def execute(self, args): """ When told to execute a function we only need to pass the command's arguments """ if callable(self.callback): self.callback(args) else: es.doblock(self.callback)
def unload(): if gg_spawn_protect_cancelonfire: es.doblock('corelib/noisy_off')
def use(self, userid, popup): if callable(self.method): self.method(userid) else: es.set("_xa_userid", str(userid)) es.doblock(self.method)
def execute(self, args): """ When told to execute a function we only need to pass the command's arguments """ if isinstance(self.callback, collections.Callable): self.callback(args) else: es.doblock(self.callback)
def cmdtest_run(): es.set("cmdtest_pass", es.getargv(1)) #print "cmdtest(), args: %s, argc: %d" % (es.getargs(), es.getargc()) if es.getargc() != 2: print("cmdtest0_failed,", es.getargc()) es.doblock("pyunittest/cmdtest_block")
def cmdtest_run(): es.set("cmdtest_pass", es.getargv(1)) #print "cmdtest(), args: %s, argc: %d" % (es.getargs(), es.getargc()) if es.getargc() != 2: print "cmdtest0_failed,", es.getargc() es.doblock("pyunittest/cmdtest_block")