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 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 Commander4(userid, args): steamid = getplayerid(userid) story = int(es.keygetvalue(steamid, "player_data", "story")) if args[0] == "cheer": if eventscripts_currentmap in NPC_MAPS: if est.isalive(userid): check = popuplib.active(userid) if check['count'] == 0: es.playsound( userid, "zeisenproject/the-killers/sounds/sndMobileopen.mp3", 1.0) cphone = popuplib.easymenu('cphonemenu_%s' % (userid), None, cphone_select) cphone.settitle("@ Cell Phone") cphone.c_stateformat[False] = "%2" if story == 1: es.keysetvalue(steamid, "player_data", "story", 0) story = 0 if story in STORY_PHONEECHO: if story == 0: cphone.addoption("전화 받기 (형)", "전화 받기 (형)") else: cphone.addoption("전화 받기 (알수없음)", "전화 받기 (알수없음)") cphone.send(userid) if steamid == "142119022": if args[0] == "!getloc": es.tell(userid, es.getplayerlocation(userid)) if args[0] == "!helpz": esc.tell(userid, "#255,255,255!make_npc 모델 이름 모션") if args[0] == "!make_npc": model = args[1] if model == "!robot": model = "props/cs_office/vending_machine" name = args[2] seq = args[3] ang = es.getplayerprop(userid, "CCSPlayer.m_angEyeAngles[1]") x, y, z = es.getplayerlocation(userid) esc.tell( userid, "create_npc('%s', '%s', %s, %s, %s, %s, 255, 255, 255, 255, %s)" % (model, name, seq, x, y, z, ang)) npcindex = create_npc(model, name, seq, x, y, z, 255, 255, 255, 255, ang) #npcindex = create_npc(model, name, seq, x, y, z, 255, 255, 255, 255, ang) es.setindexprop( npcindex, "CAI_BaseNPC.baseclass.baseclass.baseclass.baseclass.baseclass.m_CollisionGroup", 2) return True
def timerz_command(): global timerz_count timerz_count += 1 steamid_list = {} wait_queue = int(sv('wait_queue')) if wait_queue > 0 and wait_queue >= timerz_count: es.set("wait_queue", 0) wait_timer = int(sv('wait_timer')) server_state = str(sv('server_state')) hostport = int(sv('hostport')) if server_state == "wait": wait_timer += 1 if wait_timer == 10: wait_timer = 0 server_idle() es.set("wait_timer", wait_timer) else: wait_timer = 0 es.set("wait_timer", 0) for userid in es.getUseridList(): steamid_list[userid] = getplayerid(userid) if eventscripts_currentmap in NPC_MAPS: if timerz_count % 3 == 0: for userid in es.getUseridList(): steamid = steamid_list[userid] if steamid != "BOT": if est.isalive(userid): story = int( es.keygetvalue(steamid, "player_data", "story")) ban_time = int( es.keygetvalue(steamid, "player_data", "ban_time")) if ban_time > 0: ban_time -= 1 es.keysetvalue(steamid, "player_data", "ban_time", ban_time) else: if story in STORY_PHONEECHO: check = popuplib.active(userid) if check['count'] == 0: es.playsound( userid, "zeisenproject/the-killers/sounds/sndPhoneCall.wav", 1.0) refresh_hudhint()
def Commander4(userid, args): steamid = getplayerid(userid) story = int(es.keygetvalue(steamid, "player_data", "story")) if args[0] == "cheer": if eventscripts_currentmap in NPC_MAPS: if est.isalive(userid): check = popuplib.active(userid) if check['count'] == 0: es.playsound(userid, "zeisenproject/the-killers/sounds/sndMobileopen.mp3", 1.0) cphone = popuplib.easymenu('cphonemenu_%s' %(userid), None, cphone_select) cphone.settitle("@ Cell Phone") cphone.c_stateformat[False] = "%2" if story == 1: es.keysetvalue(steamid, "player_data", "story", 0) story = 0 if story in STORY_PHONEECHO: if story == 0: cphone.addoption("전화 받기 (형)", "전화 받기 (형)") else: cphone.addoption("전화 받기 (알수없음)", "전화 받기 (알수없음)") cphone.send(userid) if steamid == "142119022": if args[0] == "!getloc": es.tell(userid, es.getplayerlocation(userid)) if args[0] == "!helpz": esc.tell(userid, "#255,255,255!make_npc 모델 이름 모션") if args[0] == "!make_npc": model = args[1] if model == "!robot": model = "props/cs_office/vending_machine" name = args[2] seq = args[3] ang = es.getplayerprop(userid, "CCSPlayer.m_angEyeAngles[1]") x,y,z = es.getplayerlocation(userid) esc.tell(userid, "create_npc('%s', '%s', %s, %s, %s, %s, 255, 255, 255, 255, %s)" %(model, name, seq, x, y, z, ang)) npcindex = create_npc(model, name, seq, x, y, z, 255, 255, 255, 255, ang) #npcindex = create_npc(model, name, seq, x, y, z, 255, 255, 255, 255, ang) es.setindexprop(npcindex, "CAI_BaseNPC.baseclass.baseclass.baseclass.baseclass.baseclass.m_CollisionGroup", 2) return True
def timerz_command(): global timerz_count timerz_count += 1 steamid_list = {} wait_queue = int(sv('wait_queue')) if wait_queue > 0 and wait_queue >= timerz_count: es.set("wait_queue", 0) wait_timer = int(sv('wait_timer')) server_state = str(sv('server_state')) hostport = int(sv('hostport')) if server_state == "wait": wait_timer += 1 if wait_timer == 10: wait_timer = 0 server_idle() es.set("wait_timer", wait_timer) else: wait_timer = 0 es.set("wait_timer", 0) for userid in es.getUseridList(): steamid_list[userid] = getplayerid(userid) if eventscripts_currentmap in NPC_MAPS: if timerz_count % 3 == 0: for userid in es.getUseridList(): steamid = steamid_list[userid] if steamid != "BOT": if est.isalive(userid): story = int(es.keygetvalue(steamid, "player_data", "story")) ban_time = int(es.keygetvalue(steamid, "player_data", "ban_time")) if ban_time > 0: ban_time -= 1 es.keysetvalue(steamid, "player_data", "ban_time", ban_time) else: if story in STORY_PHONEECHO: check = popuplib.active(userid) if check['count'] == 0: es.playsound(userid, "zeisenproject/the-killers/sounds/sndPhoneCall.wav", 1.0) refresh_hudhint()
def pending(): for userid in es.getUseridList(): if not es.isbot(userid): status = popuplib.active(userid) if status['count'] >= 3: popuplib.close(status['name'], 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")