def _run_bomb(tick): if tick.isdigit(): soundtext = '%s sec'%tick elif tick == 'P': soundtext = 'Bomb Planted' elif tick == 'D': soundtext = 'Bomb Defused' elif tick == 'E': soundtext = 'Bomb Exploded' if 'command_%s'%tick in bomb_timer_language.keys(): for commandname in bomb_timer_language['command_%s'%tick].keys(): es.server.queuecmd(bomb_timer_language['command_%s'%tick][commandname].strip()) for userid in playerlib.getUseridList('#human'): if bomb_timer_setting.get('display', userid): if int(bomb_timer_middle_screen) == 1: usermsg.hudhint(userid, soundtext) elif int(bomb_timer_middle_screen) == 2: usermsg.centermsg(userid, soundtext) if bomb_timer_setting.get('text', userid): if 'text_%s'%tick in bomb_timer_language.keys(): es.tell(userid, '#multi', bomb_timer_language('text_%s'%tick, {}, playerlib.getPlayer(userid).get('lang'))) if bomb_timer_setting.get('sound', userid): if int(es.getplayerteam(userid)) < 2: keyname = 'spec' elif int(es.getplayerteam(userid)) == 2: keyname = 't' elif int(es.getplayerteam(userid)) == 3: keyname = 'ct' if 'sound_%s'%tick in bomb_timer_language.keys(): es.playsound(userid, bomb_timer_language['sound_%s'%tick][keyname], 1.0)
def player_connect(event_var): """ Announces the connecting player's country """ if event_var['networkid'] == 'BOT': return tokens = { 'name': event_var['name'], 'location': iptocountry.get_country(event_var['address'])[0] } chat = int(cvar_announce_chat) center = int(cvar_announce_center) hud = int(cvar_announce_hud) es.dbgmsg(0, remove_tags(lang_text('connect', tokens))) for userid in es.getUseridList(): text = lang_text('connect', tokens, playerlib.getPlayer(userid).get('lang')) if chat: if chat == 2: es.tell(userid, '#multi', text) else: usermsg.echo(userid, remove_tags(text)) if center: es.centertell(userid, remove_tags(text)) if hud: usermsg.hudhint(userid, remove_tags(text))
def playerHurt(self, ev): if int(ev["attacker"]) in self.humans: if ev['weapon'] == "hegrenade" and int(ev["userid"]) in self.bots: dmg = int(float(ev["dmg_health"]) * float(es.ServerVar("uz_grenade"))) usermsg.hudhint(ev["attacker"], "Damages: %s" % str(dmg)) # Display Damage else: usermsg.hudhint(ev["attacker"], "Damages: %s" % ev["dmg_health"]) # Display Damage
def refresh_hudhint(): score = int(sv('score')) combo = int(sv('combo')) combo_msg = " " if combo > 0: combo_msg = "(%sx Combo)" %(combo) hudhint_string = "* %s PTS\n%s\n \n " %(score, combo_msg) for userid in es.getUseridList(): if es.isbot(userid): continue usermsg.hudhint(userid, hudhint_string)
def refresh_hudhint(): score = int(sv('score')) combo = int(sv('combo')) combo_msg = " " if combo > 0: combo_msg = "(%sx Combo)" % (combo) hudhint_string = "* %s PTS\n%s\n \n " % (score, combo_msg) for userid in es.getUseridList(): if es.isbot(userid): continue usermsg.hudhint(userid, hudhint_string)
def usermsg_cmd(args): if len(args) == 1: if args[0] == 'list': es.dbgmsg(0, "usermsg fade: Syntax: fade <userid> <0 = no fade, 1 = fade Out 2 = fade in> <time to fade (in frames)> <time faded (in frames)> <red> <green> <blue> <alpha>") es.dbgmsg(0, "usermsg shake: Syntax: shake <userid> <magnitude> <time>") es.dbgmsg(0, "usermsg motd: Syntax: motd <userid> <0 = text, 2 = url> <title> <msg>") es.dbgmsg(0, "usermsg hudhint: Syntax: hudhint <userid> <msg>") es.dbgmsg(0, "usermsg keyhint: Syntax: keyhint <userid> <msg>") es.dbgmsg(0, "usermsg centermsg: Syntax: centermsg <userid> <msg>") else: es.dbgmsg(0, 'usermsg: Invalid parameters, type "usermsg list" to see a list of valid subcommands') elif len(args) > 1: subcommand = args[0] if subcommand == 'fade': if len(args) > 8: usermsg.fade(args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]) else: es.dbgmsg(0, "usermsg fade: Syntax: fade <userid> <0 = no fade, 1 = fade Out 2 = fade in> <time to fade (in frames)> <time faded (in frames)> <red> <green> <blue> <alpha>") elif subcommand == 'shake': if len(args) > 3: usermsg.shake(args[1], args[2], args[3]) else: es.dbgmsg(0, "usermsg shake: Syntax: shake <userid> <magnitude> <time>") elif subcommand == 'motd': if len(args) > 4: usermsg.motd(args[1], args[2], args[3], args[4]) else: es.dbgmsg(0, "usermsg motd: Syntax: motd <userid> <0 = text, 2 = url> <title> <msg>") elif subcommand == 'hudhint': if len(args) > 2: usermsg.hudhint(args[1], args[2]) else: es.dbgmsg(0, "usermsg hudhint: Syntax: hudhint <userid> <msg>") elif subcommand == 'keyhint': if len(args) > 2: usermsg.keyhint(args[1], args[2]) else: es.dbgmsg(0, "usermsg keyhint: Syntax: keyhint <userid> <msg>") elif subcommand == 'centermsg': if len(args) > 2: usermsg.centermsg(args[1], args[2]) else: es.dbgmsg(0, "usermsg centermsg: Syntax: centermsg <userid> <msg>") elif subcommand == 'echo': if len(args) > 2: usermsg.echo(args[1], args[2]) else: es.dbgmsg(0, "usermsg echo: Syntax: echo <userid> <msg>") else: es.dbgmsg(0, 'usermsg: Invalid subcommand, type "usermsg list" to see a list of valid subcommands') else: es.dbgmsg(0, 'usermsg: Missing userid and subcommand, type "usermsg list" to see a list of valid subcommands')
def Loop(self): time_left = int(self.starttime - time.time() + float(vote_timer)) if time_left < 0: time_left = 0 SortedVotes = self.SortDict() format = "Vote Counter: (%ss)\n-----------------------\n" % time_left for index in range(min(2, len(SortedVotes))): option = SortedVotes[index] format = format + option + " - Votes: " + str( self.votes[option]['votes']) + "\n" usermsg.hudhint(playerlib.getUseridList("#human"), format) if time_left: gamethread.delayedname(1, self.name, self.Loop)
def sendAllPlayersMessages(message,tokens,message_types,reminder=False): for player in playerlib.getPlayerList('#human'): pmessage = lmv['lang'](message,tokens,player.lang) if 'chat' in message_types: es.tell(player.userid,'#multi',pmessage) for color in ('#default','#green','#lightgreen','[LooneyMapVote]'): pmessage = pmessage.replace(color,'') ptime = 1 if reminder else lmv_announce_time if 'hudhint' in message_types: usermsg.hudhint(player.userid,pmessage) if 'center' in message_types: for second in range(ptime): gamethread.delayed(second,usermsg.centermsg,(player.userid,pmessage)) if 'toptext' in message_types: msglib.VguiDialog(pmessage,pmessage,5,'%s %s %s 255'%(lmv_top_red,lmv_top_green,lmv_top_blue),ptime).send(player.userid)
def player_hurt(event_var): victim_id = int(event_var['userid']) damage = int(event_var['dmg_health']) attacker_id = int(event_var['attacker']) victim_name = event_var['es_username'] attacker_name = event_var['es_attackername'] if victim_id not in (0, attacker_id): display_areas_split = str(DISPLAY_DAMAGE_DISPLAY).strip().split(';') show_dmg = '-%sHP' %damage show_maxlen = max(len(victim_name), len(show_dmg)) if int(DISPLAY_DAMAGE_NAME): show_msg = '%s\n%s' %(victim_name.center(show_maxlen), show_dmg.center(show_maxlen)) else: show_msg = show_dmg if 'chat' in display_areas_split: es.tell(attacker_id, '#multi', '#green[DMG] #lightgreen%s' %show_msg) if 'hudhint' in display_areas_split: usermsg.hudhint(attacker_id, show_msg) if 'keyhint' in display_areas_split: usermsg.keyhint(attacker_id, show_msg) if 'center' in display_areas_split: es.centertell(attacker_id, show_msg)
def _run_bomb(tick): if tick.isdigit(): soundtext = '%s sec' % tick elif tick == 'P': soundtext = 'Bomb Planted' elif tick == 'D': soundtext = 'Bomb Defused' elif tick == 'E': soundtext = 'Bomb Exploded' if 'command_%s' % tick in bomb_timer_language.keys(): for commandname in bomb_timer_language['command_%s' % tick].keys(): es.server.queuecmd(bomb_timer_language['command_%s' % tick][commandname].strip()) for userid in playerlib.getUseridList('#human'): if bomb_timer_setting.get('display', userid): if int(bomb_timer_middle_screen) == 1: usermsg.hudhint(userid, soundtext) elif int(bomb_timer_middle_screen) == 2: usermsg.centermsg(userid, soundtext) if bomb_timer_setting.get('text', userid): if 'text_%s' % tick in bomb_timer_language.keys(): es.tell( userid, '#multi', bomb_timer_language( 'text_%s' % tick, {}, playerlib.getPlayer(userid).get('lang'))) if bomb_timer_setting.get('sound', userid): if int(es.getplayerteam(userid)) < 2: keyname = 'spec' elif int(es.getplayerteam(userid)) == 2: keyname = 't' elif int(es.getplayerteam(userid)) == 3: keyname = 'ct' if 'sound_%s' % tick in bomb_timer_language.keys(): es.playsound(userid, bomb_timer_language['sound_%s' % tick][keyname], 1.0)
def player_connect(event_var): """ Announces the connecting player's country """ if event_var['networkid'] == 'BOT': return tokens = {'name': event_var['name'], 'location': iptocountry.get_country(event_var['address'])[0]} chat = int(cvar_announce_chat) center = int(cvar_announce_center) hud = int(cvar_announce_hud) es.dbgmsg(0, remove_tags(lang_text('connect', tokens))) for userid in es.getUseridList(): text = lang_text('connect', tokens, playerlib.getPlayer(userid).get('lang')) if chat: if chat == 2: es.tell(userid, '#multi', text) else: usermsg.echo(userid, remove_tags(text)) if center: es.centertell(userid, remove_tags(text)) if hud: usermsg.hudhint(userid, remove_tags(text))
def hudhint(self, filter, string, tokens={}): # Setup filter filter = self.__format_filter(filter) # Check if this is a normal message if not str(string) in __strings__: # Send message to the userid if isinstance(filter, int): return usermsg.hudhint(filter, string) # Send message to the userids from the playerlib filter for userid in getUseridList(filter): usermsg.hudhint(userid, string) else: # Send message to the userid if isinstance(filter, int): return usermsg.hudhint( filter, self.__format_string(string, tokens, filter)) # Send message to the userids from the playerlib filter for userid in getUseridList(filter): usermsg.hudhint(userid, self.__format_string(string, tokens, userid))
def hudhint(self, filter, string, tokens={}): # Setup filter filter = self.__format_filter(filter) # Check if this is a normal message if not str(string) in __strings__: # Send message to the userid if isinstance(filter, int): return usermsg.hudhint(filter, string) # Send message to the userids from the playerlib filter for userid in getUseridList(filter): usermsg.hudhint(userid, string) else: # Send message to the userid if isinstance(filter, int): return usermsg.hudhint(filter, self.__format_string(string, tokens, filter)) # Send message to the userids from the playerlib filter for userid in getUseridList(filter): usermsg.hudhint(userid, self.__format_string(string, tokens, userid))
def round_announce(): usermsg.hudhint(playerlib.getUseridList('#human'), 'Say !quake for Quake Styles')
def player_hurt(event_var): if es.ServerVar("ut_displaydmg") == 1: att = event_var["attacker"] dmg = int(event_var["dmg_health"]) usermsg.hudhint(att, "Damages: %s" % (dmg)) # Display Damage
def update(self): timer = es.import_addon('trikztimer/plugins/timer') """ Update the player's message showing his targets ranks. """ if not es.exists('userid', self.userid): return #if not es.exists('userid', self.target): # return if es.getplayerteam(self.userid) in (2, 3): if not playerlib.getPlayer(self.userid).isdead: Player(self.userid).delspec(self.userid, self.target, 1) return target = self.getspec() if target != -1: self.target = target steamid = es.getplayersteamid(self.target) name = es.getplayername(self.target) # PARTNER TIMER velocity = round( vector( float( es.getplayerprop( self.target, 'CBasePlayer.localdata.m_vecVelocity[0]')), float( es.getplayerprop( self.target, 'CBasePlayer.localdata.m_vecVelocity[1]'))).length( ), 2) Player(self.userid).addspec(self.userid, self.target) Player(self.userid).delspec(self.userid, self.target, 2) specs[self.userid]["last_spec"] = self.target if steamid in timer.player: string = timer.player[steamid]["text_display"] if timer.CheckPartner(self.target): string += "\n(Partnered)" else: string += "\n(Solo)" timer.player[steamid]['spectators'] = specs[self.target]['n'] if not es.isbot(target): hudhint(self.userid, "- %s -\nVel: %s\n%s" % (name, velocity, string)) name_list = "" if len(specs[self.target]['n']) > 0: for object in specs[self.target]['n']: s_name = str(es.getplayername(object)) if len(s_name) > 12: s_name = str(es.getplayername(object))[0:12] + "..." name_list += "\n" + s_name if timer.tournament["status"] == 0: keyhint( self.userid, "%s's Spectators: %s\n%s" % (name, len(specs[self.target]['n']), name_list)) else: string = "" string += "-- Tournament Mode --\n " if timer.tournament["turn"] in timer.tournament["queue"] > 0: turn = timer.tournament["turn"] string += "\n %s | %s is playing..\n \n Next couple in: %s \n \n \n" % ( timer.tournament["queue"][turn][0]["name"], timer.tournament["queue"][turn][1]["name"], timer.TimeFormat(timer.tournament["time"], None, True)) else: string += "\nNo teams available yet!\n \n" keyhint( self.userid, "Spectators: %s\n%s" % (string, name, len(specs[self.target]['n']), name_list)) else: Player(self.userid).delspec(self.userid, self.target, 2)
import es
def display_advert(): global next_advert # repeat the timer gamethread.delayedname(float(time_between_advert), 'adverts', display_advert) if adverts and xaadvertlist and es.ServerVar( 'eventscripts_currentmap') != '': # start at the beginning if next_advert >= len(xaadvertlist): next_advert = 0 # get advert advert_text = xaadvertlist[next_advert] tags = re.compile(r'(?P<tag>\{\w+\})') for tag in tags.findall(advert_text): advert_text = advert_text.replace(tag, tag.upper()) # set color color = '%s %s %s 255' % (str(advert_col_red), str(advert_col_green), str(advert_col_blue)) for k in colors: if k in advert_text: color = colors[k] advert_text = advert_text.replace(k, '') # set tags if str(es.ServerVar('eventscripts_nextmapoverride')) != '': advert_text = advert_text.replace( '{NEXTMAP}', str(es.ServerVar('eventscripts_nextmapoverride'))) else: if len(mapcycle) == 1: advert_text = advert_text.replace( '{NEXTMAP}', str(es.ServerVar('eventscripts_currentmap'))) elif currentmap + 1 > len(mapcycle): # fix for when we are at the end of the maplist advert_text = advert_text.replace('{NEXTMAP}', mapcycle[0]) else: advert_text = advert_text.replace('{NEXTMAP}', mapcycle[currentmap + 1]) advert_text = advert_text.replace( '{CURRENTMAP}', str(es.ServerVar('eventscripts_currentmap'))) advert_text = advert_text.replace('{TICKRATE}', 'UNKNOWN') if int(es.ServerVar('mp_friendlyfire')): advert_text = advert_text.replace('{FF}', 'on') else: advert_text = advert_text.replace('{FF}', 'off') advert_text = advert_text.replace( '{THETIME}', str(time.strftime("%H:%M:%S", time.localtime()))) advert_text = advert_text.replace('{SERVERHOST}', 'UNKNOWN') # send top text if int(adverts_top_left): if int(advert_dead_only) == 1: xaadvert_playerlist = playerlib.getPlayerList('#human,#dead') else: xaadvert_playerlist = playerlib.getPlayerList('#human') toptext = msglib.VguiDialog(title=advert_text, level=5, time=25, mode=msglib.VguiMode.MSG) toptext['color'] = color for k in xaadvert_playerlist: toptext.send(k.userid) # send chat text if int(adverts_chat_area): if int(advert_dead_only) == 1: xaadvert_playerlist = playerlib.getPlayerList('#human,#dead') for k in xaadvert_playerlist: es.tell(k.userid, '#lightgreen', advert_text) else: es.msg('#lightgreen', advert_text) # send bottom text if int(adverts_bottom_area): if int(advert_dead_only) == 1: xaadvert_playerlist = playerlib.getPlayerList('#human,#dead') else: xaadvert_playerlist = playerlib.getPlayerList('#human') for k in xaadvert_playerlist: usermsg.hudhint(k.userid, advert_text) next_advert = next_advert + 1
def display_advert(): global next_advert # repeat the timer gamethread.delayedname(float(time_between_advert), 'adverts', display_advert) if adverts and xaadvertlist and es.ServerVar('eventscripts_currentmap') != '': # start at the beginning if next_advert >= len(xaadvertlist): next_advert = 0 # get advert advert_text = xaadvertlist[next_advert] tags = re.compile(r'(?P<tag>\{\w+\})') for tag in tags.findall(advert_text): advert_text = advert_text.replace(tag,tag.upper()) # set color color = '%s %s %s 255' % (str(advert_col_red), str(advert_col_green), str(advert_col_blue)) for k in colors: if k in advert_text: color = colors[k] advert_text = advert_text.replace(k, '') # set tags if str(es.ServerVar('eventscripts_nextmapoverride')) != '': advert_text = advert_text.replace('{NEXTMAP}', str(es.ServerVar('eventscripts_nextmapoverride'))) else: if len(mapcycle) == 1: advert_text = advert_text.replace('{NEXTMAP}', str(es.ServerVar('eventscripts_currentmap'))) elif currentmap+1 > len(mapcycle): # fix for when we are at the end of the maplist advert_text = advert_text.replace('{NEXTMAP}', mapcycle[0]) else: advert_text = advert_text.replace('{NEXTMAP}', mapcycle[currentmap+1]) advert_text = advert_text.replace('{CURRENTMAP}', str(es.ServerVar('eventscripts_currentmap'))) advert_text = advert_text.replace('{TICKRATE}', 'UNKNOWN') if int(es.ServerVar('mp_friendlyfire')): advert_text = advert_text.replace('{FF}', 'on') else: advert_text = advert_text.replace('{FF}', 'off') advert_text = advert_text.replace('{THETIME}', str(time.strftime("%H:%M:%S", time.localtime()))) advert_text = advert_text.replace('{SERVERHOST}', 'UNKNOWN') # send top text if int(adverts_top_left): if int(advert_dead_only) == 1: xaadvert_playerlist = playerlib.getPlayerList('#human,#dead') else: xaadvert_playerlist = playerlib.getPlayerList('#human') toptext = msglib.VguiDialog(title=advert_text, level=5, time=25, mode=msglib.VguiMode.MSG) toptext['color'] = color for k in xaadvert_playerlist: toptext.send(k.userid) # send chat text if int(adverts_chat_area): if int(advert_dead_only) == 1: xaadvert_playerlist = playerlib.getPlayerList('#human,#dead') for k in xaadvert_playerlist: es.tell(k.userid, '#lightgreen', advert_text) else: es.msg('#lightgreen', advert_text) # send bottom text if int(adverts_bottom_area): if int(advert_dead_only) == 1: xaadvert_playerlist = playerlib.getPlayerList('#human,#dead') else: xaadvert_playerlist = playerlib.getPlayerList('#human') for k in xaadvert_playerlist: usermsg.hudhint(k.userid, advert_text) next_advert = next_advert + 1
def usermsg_cmd(args): if len(args) == 1: if args[0] == 'list': es.dbgmsg( 0, "usermsg fade: Syntax: fade <userid> <0 = no fade, 1 = fade Out 2 = fade in> <time to fade (in frames)> <time faded (in frames)> <red> <green> <blue> <alpha>" ) es.dbgmsg( 0, "usermsg shake: Syntax: shake <userid> <magnitude> <time>") es.dbgmsg( 0, "usermsg motd: Syntax: motd <userid> <0 = text, 2 = url> <title> <msg>" ) es.dbgmsg(0, "usermsg hudhint: Syntax: hudhint <userid> <msg>") es.dbgmsg(0, "usermsg keyhint: Syntax: keyhint <userid> <msg>") es.dbgmsg(0, "usermsg centermsg: Syntax: centermsg <userid> <msg>") else: es.dbgmsg( 0, 'usermsg: Invalid parameters, type "usermsg list" to see a list of valid subcommands' ) elif len(args) > 1: subcommand = args[0] if subcommand == 'fade': if len(args) > 8: usermsg.fade(args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]) else: es.dbgmsg( 0, "usermsg fade: Syntax: fade <userid> <0 = no fade, 1 = fade Out 2 = fade in> <time to fade (in frames)> <time faded (in frames)> <red> <green> <blue> <alpha>" ) elif subcommand == 'shake': if len(args) > 3: usermsg.shake(args[1], args[2], args[3]) else: es.dbgmsg( 0, "usermsg shake: Syntax: shake <userid> <magnitude> <time>") elif subcommand == 'motd': if len(args) > 4: usermsg.motd(args[1], args[2], args[3], args[4]) else: es.dbgmsg( 0, "usermsg motd: Syntax: motd <userid> <0 = text, 2 = url> <title> <msg>" ) elif subcommand == 'hudhint': if len(args) > 2: usermsg.hudhint(args[1], args[2]) else: es.dbgmsg(0, "usermsg hudhint: Syntax: hudhint <userid> <msg>") elif subcommand == 'keyhint': if len(args) > 2: usermsg.keyhint(args[1], args[2]) else: es.dbgmsg(0, "usermsg keyhint: Syntax: keyhint <userid> <msg>") elif subcommand == 'centermsg': if len(args) > 2: usermsg.centermsg(args[1], args[2]) else: es.dbgmsg( 0, "usermsg centermsg: Syntax: centermsg <userid> <msg>") elif subcommand == 'echo': if len(args) > 2: usermsg.echo(args[1], args[2]) else: es.dbgmsg(0, "usermsg echo: Syntax: echo <userid> <msg>") else: es.dbgmsg( 0, 'usermsg: Invalid subcommand, type "usermsg list" to see a list of valid subcommands' ) else: es.dbgmsg( 0, 'usermsg: Missing userid and subcommand, type "usermsg list" to see a list of valid subcommands' )