def sendglobal(self, pUsers, prio=False, locked=False): try: # try if pUsers is just a single userid userid = int(pUsers) pUsers = [userid] except TypeError: pass if locked: optionstate = 0 else: optionstate = 1 for userid in pUsers: player = playerlib.getPlayer(userid) if player: menuname = '_setting_%s_user%s_global' % (self.name, userid) helpline = self.languages('setting '+self.keyvalues['config']['type']+' help', (), player.get('lang')) if not popuplib.active(userid)['name'] == menuname and not popuplib.isqueued(menuname, userid) or prio: self.popup['global'] = popuplib.easymenu(menuname, '_setting_choice', settinglib._submitGlobal) self.popup['global'].settingid = self.name self.popup['global'].c_titleformat = self.keyvalues['config']['descr'] + (' '*(30-len(self.keyvalues['config']['descr']))) + ' (%p/%t)\n' + helpline for option in list(self.keyvalues['options'].keys()): display = self.keyvalues['options'][option]['display'] userdata = self.keyvalues['options'] if option in userdata: if userdata[option]['globstate']: active = self.languages('setting toggle on', (), player.get('lang')) self.popup['global'].addoption(option, display + ' ('+active+')', optionstate) continue active = self.languages('setting toggle off', (), player.get('lang')) self.popup['global'].addoption(option, display + ' ('+active+')', optionstate) if self.backmenuvar: self.popup['global'].submenu(10, self.backmenuvar) self.popup['global'].send(userid, prio)
def player_death(event_var): # Is the player a bot? if event_var["es_steamid"] == "BOT": return # Is map vote running? if ggVote is None: return # Using 3rd party voting system ? if int(gg_map_vote) > 1: return # Only send to dead players ? if not int(gg_map_vote_after_death): return userid = int(event_var["userid"]) # Is the map vote currently in the player's queue if popuplib.isqueued("gg_map_vote", userid): return # Has the player already voted? if userid in votedUserids: return # Send the map vote to the player ggVote.send(userid)
def player_death(event_var): # Is the player a bot? if event_var['es_steamid'] == 'BOT': return # Is map vote running? if ggVote is None: return # Using 3rd party voting system ? if int(gg_map_vote) > 1: return # Only send to dead players ? if not int(gg_map_vote_after_death): return userid = int(event_var['userid']) # Is the map vote currently in the player's queue if popuplib.isqueued('gg_map_vote', userid): return # Has the player already voted? if userid in votedUserids: return # Send the map vote to the player ggVote.send(userid)
def sendPlayerVoteMenu(self,userid): if not es.getuserid(userid): return player = playerlib.getPlayer(userid) message, tokens = self.checkSendVote(player.uniqueid(True)) if message: es.tell(userid,'#multi',lmv['lang'](message,tokens,player.lang)) elif popuplib.isqueued('Vote on GamePlay_%s'%userid,userid) or popuplib.isqueued('Vote on Map_%s'%userid,userid): return else: if lmv_randomize_votes: options = list(self.options) random.shuffle(options) self.options = set(options) popupname = 'Vote on GamePlay' if self.vote_status == 1 else 'Vote on Map' uservotemenu = popuplib.easymenu('%s_%s'%(popupname,userid),'choice',self.getPlayerVote) uservotemenu.settitle(lmv['lang'](popupname,lang=player.lang)) for option in self.options: uservotemenu.addoption(option,lmv['lang'](option,lang=player.lang) if self.vote_status == 1 else option) uservotemenu.send(userid)
def batmenu(): userid = str(es.getcmduserid()) if not superhero.hasHero(userid,'Batman'): return if popuplib.isqueued('bat_menu',userid): popuplib.close('bat_menu',userid) popuplib.send('bat_menu',userid)
def batmenu(): userid = str(es.getcmduserid()) if not superhero.hasHero(userid, 'Batman'): return if popuplib.isqueued('bat_menu', userid): popuplib.close('bat_menu', userid) popuplib.send('bat_menu', userid)
def send(self, pUsers, prio=False, locked=False): try: # try if pUsers is just a single userid userid = int(pUsers) pUsers = [userid] except TypeError: pass if locked: optionstate = 0 else: optionstate = 1 for userid in pUsers: player = playerlib.getPlayer(userid) if player: steamid = playerlib.uniqueid(userid, True) menuname = '_setting_%s_user%s' % (self.name, userid) helpline = self.languages( 'setting ' + self.keyvalues['config']['type'] + ' help', (), player.get('lang')) if not popuplib.active( userid)['name'] == menuname and not popuplib.isqueued( menuname, userid) or prio: self.popup[userid] = popuplib.easymenu( menuname, '_setting_choice', settinglib._submit) self.popup[userid].settingid = self.name self.popup[userid].c_titleformat = self.keyvalues[ 'config']['descr'] + ( ' ' * (30 - len(self.keyvalues['config']['descr'])) ) + ' (%p/%t)\n' + helpline if not steamid in self.keyvalues['users']: self.initUser(userid) for option in list(self.keyvalues['options'].keys()): display = self.keyvalues['options'][option]['display'] userdata = self.keyvalues['users'][steamid]['data'] if option in userdata: if userdata[option]['state']: active = self.languages( 'setting toggle on', (), player.get('lang')) self.popup[userid].addoption( option, display + ' (' + active + ')', optionstate) continue active = self.languages('setting toggle off', (), player.get('lang')) self.popup[userid].addoption( option, display + ' (' + active + ')', optionstate) if self.backmenuvar: self.popup[userid].submenu(10, self.backmenuvar) self.popup[userid].send(userid, prio)
def weapon_give(userid, weapon, popupname): userid = str(userid) weapon = str(weapon) player = playerlib.getPlayer(userid) if int(player.isdead) != 1: batlist = 'tmp,mp5navy,p90,ak47,m4a1,sg552' if weapon in batlist: weapon_give = 'weapon_' + weapon primary = player.getPrimary() for x in xrange(7): handle = es.getplayerprop( userid, 'CBaseCombatCharacter.m_hMyWeapons.%03d' % x) if handle > 0: index = es.getindexfromhandle(handle) weapon = weaponlib.getWeapon( es.entitygetvalue(index, 'classname')) # Loop through all usps to find the one belonging to the player if weapon is not None and 'primary' in weapon.tags: es.entitysetvalue(index, 'targetname', 'kill_me') es.server.queuecmd('es_xfire %s kill_me kill' % userid) es.server.queuecmd('es_xgive %s %s' % (userid, weapon_give)) if popuplib.isqueued('bat_menu', userid): popuplib.close('bat_menu', userid) else: es.tell( userid, '#multi', '#green[SH] #lightgreenWeapon has already been picked once this round' )
def weapon_give(userid,weapon,popupname): userid = str(userid) weapon = str(weapon) player = playerlib.getPlayer(userid) if int(player.isdead) != 1: batlist = 'tmp,mp5navy,p90,ak47,m4a1,sg552' if weapon in batlist: weapon_give = 'weapon_'+weapon primary = player.getPrimary() for x in xrange(7): handle = es.getplayerprop(userid, 'CBaseCombatCharacter.m_hMyWeapons.%03d' % x) if handle > 0: index = es.getindexfromhandle(handle) weapon = weaponlib.getWeapon(es.entitygetvalue(index, 'classname')) # Loop through all usps to find the one belonging to the player if weapon is not None and 'primary' in weapon.tags: es.entitysetvalue(index, 'targetname', 'kill_me') es.server.queuecmd('es_xfire %s kill_me kill'%userid) es.server.queuecmd('es_xgive %s %s'%(userid, weapon_give)) if popuplib.isqueued('bat_menu', userid): popuplib.close('bat_menu', userid) else: es.tell(userid,'#multi','#green[SH] #lightgreenWeapon has already been picked once this round')
def player_spawn(ev): userid = ev['userid'] if not superhero.hasHero(userid,'Batman'): return player = playerlib.getPlayer(userid) if int(player.isdead) != 1: primary = player.getPrimary() es.tell(userid,'#multi','#green[SH]#lightgreen Batman activated. Type #greenbatmenu #lightgreento pick Weapons') if popuplib.isqueued('bat_menu',userid): popuplib.close('bat_menu',userid) if not primary: popuplib.send('bat_menu',userid)
def player_spawn(ev): userid = ev['userid'] if not superhero.hasHero(userid, 'Batman'): return player = playerlib.getPlayer(userid) if int(player.isdead) != 1: primary = player.getPrimary() es.tell( userid, '#multi', '#green[SH]#lightgreen Batman activated. Type #greenbatmenu #lightgreento pick Weapons' ) if popuplib.isqueued('bat_menu', userid): popuplib.close('bat_menu', userid) if not primary: popuplib.send('bat_menu', userid)
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 unsendVotes(popupname): for userid in playerlib.getUseridList('#human'): if popuplib.isqueued('%s_%s'%(popupname,userid),userid): popuplib.unsendname('%s_%s'%(popupname,userid),userid)