def __sendMessage(users, name):
    # Loop through players
    for userid in _get_users(users):
        es.usermsg('send', name, userid)

    # Cleanup
    es.usermsg('delete', name)
Exemple #2
0
def shake(users, magnitude, time):
    '''Shakes a players screen.'''
    es.usermsg('create', 'shake', 'Shake')
    es.usermsg('write', 'byte', 'shake', 0)
    es.usermsg('write', 'float', 'shake', magnitude)
    es.usermsg('write', 'float', 'shake', 1.0)
    es.usermsg('write', 'float', 'shake', time)

    __sendMessage(users, 'shake')
    def send(self, *user_IDs):
        """Send the created usermsg object to a player(s).

        Arguments:
        user_IDs - the user IDs to send the usermsg to.

        """
        for user_ID in user_IDs:
            es.usermsg("send", self.name, user_ID)
def shake(users, magnitude, time):
    '''Shakes a players screen.'''
    es.usermsg('create', 'shake', 'Shake')
    es.usermsg('write', 'byte', 'shake', 0)
    es.usermsg('write', 'float', 'shake', magnitude)
    es.usermsg('write', 'float', 'shake', 1.0)
    es.usermsg('write', 'float', 'shake', time)

    __sendMessage(users, 'shake')
    def __init__(self, text=" "):
        """Instantiate an Echo object.

        Arguments:
        text (Keyword Default: " ") - The text to output. By default, a blank
        line (minimum of 1 space) will be used.

        """
        super(Echo, self).__init__()
        es.usermsg("write", "string", self.name, text)
def shake(users, magnitude, time):
    '''Shakes a players screen.'''
    if UserMessage.is_protobuf():
        Shake(atof2(magnitude), atof2(time)).send(_get_sp_users(users))
    else:
        es.usermsg('create', 'shake', 'Shake')
        es.usermsg('write', 'byte', 'shake', 0)
        es.usermsg('write', 'float', 'shake', magnitude)
        es.usermsg('write', 'float', 'shake', 1.0)
        es.usermsg('write', 'float', 'shake', time)

        __sendMessage(users, 'shake')
def __sendMessage(users, name):
    # Is a filter
    if str(users)[0] == '#':
        users = playerlib.getUseridList(users)
    # Is not a sequence of userids
    elif not hasattr(users, '__iter__'):
        users = (users,)

    # Loop through players
    for userid in users:
        if es.exists('userid', userid): es.usermsg('send', name, userid)

    # Cleanup
    es.usermsg('delete', name)
Exemple #8
0
def __sendMessage(users, name):
    # Is a filter
    if str(users)[0] == '#':
        users = playerlib.getUseridList(users)
    # Is not a sequence of userids
    elif not hasattr(users, '__iter__'):
        users = (users,)

    # Loop through players
    for userid in users:
        if es.exists('userid', userid): es.usermsg('send', name, userid)

    # Cleanup
    es.usermsg('delete', name)
Exemple #9
0
 def Loop(self):
     time_left = int(self.starttime - time.time() + float(vote_timer) )
     if time_left < 0:
         time_left = 0
     SortedVotes = self.SortDict()
     es.usermsg("create", self.name, "HintText") 
     es.usermsg("write" , "short"  , self.name, -1) 
     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" 
     es.usermsg("write", "string", self.name, format)
     for player in es.getUseridList(): 
         es.usermsg("send", self.name, player, 0) 
     es.usermsg("delete", self.name)
     gamethread.delayedname(1, self.name, self.Loop) 
Exemple #10
0
 def Loop(self):
     time_left = int(self.starttime - time.time() + float(vote_timer))
     if time_left < 0:
         time_left = 0
     SortedVotes = self.SortDict()
     es.usermsg("create", self.name, "HintText")
     es.usermsg("write", "short", self.name, -1)
     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"
     es.usermsg("write", "string", self.name, format)
     for player in es.getUseridList():
         es.usermsg("send", self.name, player, 0)
     es.usermsg("delete", self.name)
     gamethread.delayedname(1, self.name, self.Loop)
Exemple #11
0
def _play_quakesound(soundfile, soundname, userid, attackerid, mode,
                     visual_mode):
    if mode == 0:
        useridlist_sound = []
    elif mode == 1:
        useridlist_sound = es.getUseridList()
    elif mode == 2:
        useridlist_sound = [userid, attackerid]
    elif mode == 3:
        useridlist_sound = [attackerid]
    elif mode == 4:
        useridlist_sound = [userid]
    else:
        useridlist_sound = es.getUseridList()
    if visual_mode == 0:
        useridlist_text = []
    elif visual_mode == 1:
        useridlist_text = es.getUseridList()
    elif visual_mode == 2:
        useridlist_text = [userid, attackerid]
    elif visual_mode == 3:
        useridlist_text = [attackerid]
    elif visual_mode == 4:
        useridlist_text = [userid]
    else:
        useridlist_text = es.getUseridList()
    if attackerid > 0:
        langdata = {"username": es.getplayername(attackerid)}
    else:
        langdata = {}
    for userid in useridlist_sound:
        if int(xaplayerdata_quakesounds.get(userid)) == 1:
            es.playsound(userid, soundfile, 1.0)
    for userid in useridlist_text:
        if int(xaplayerdata_quakesounds.get(userid)) == 1:
            player = playerlib.getPlayer(userid)
            soundtext = xalanguage(soundname, langdata, player.get("lang"))
            es.usermsg('create', 'centermsg', 'TextMsg')
            es.usermsg('write', 'byte', 'centermsg', '4')
            es.usermsg('write', 'string', 'centermsg', str(soundtext))
            es.usermsg('send', 'centermsg', str(userid))
            es.usermsg('delete', 'centermsg')
def _play_quakesound(soundfile, soundname, userid, attackerid, mode, visual_mode):
    if mode == 0:
        useridlist_sound = []
    elif mode == 1:
        useridlist_sound = es.getUseridList()
    elif mode == 2:
        useridlist_sound = [userid, attackerid]
    elif mode == 3:
        useridlist_sound = [attackerid]
    elif mode == 4:
        useridlist_sound = [userid]
    else:
        useridlist_sound = es.getUseridList()
    if visual_mode == 0:
        useridlist_text = []
    elif visual_mode == 1:
        useridlist_text = es.getUseridList()
    elif visual_mode == 2:
        useridlist_text = [userid, attackerid]
    elif visual_mode == 3:
        useridlist_text = [attackerid]
    elif visual_mode == 4:
        useridlist_text = [userid]
    else:
        useridlist_text = es.getUseridList()
    if attackerid > 0:
        langdata = {"username":es.getplayername(attackerid)}
    else:
        langdata = {}
    for userid in useridlist_sound:
        if int(xaplayerdata_quakesounds.get(userid)) == 1:
            es.playsound(userid, soundfile, 1.0)
    for userid in useridlist_text:
        if int(xaplayerdata_quakesounds.get(userid)) == 1:
            player = playerlib.getPlayer(userid)
            soundtext = xalanguage(soundname, langdata, player.get("lang"))
            es.usermsg('create', 'centermsg', 'TextMsg')
            es.usermsg('write', 'byte', 'centermsg', '4')
            es.usermsg('write', 'string', 'centermsg', str(soundtext))
            es.usermsg('send', 'centermsg', str(userid))
            es.usermsg('delete', 'centermsg')
Exemple #13
0
def centermsg(users, msg):
    '''Shows a message in the center of a players screen.'''
    es.usermsg('create', 'centermsg', 'TextMsg')
    es.usermsg('write', 'byte', 'centermsg', 4)
    es.usermsg('write', 'string', 'centermsg', msg)

    __sendMessage(users, 'centermsg')
Exemple #14
0
def echo(users, msg):
    '''Shows a message in a players console.'''
    es.usermsg('create', 'echo', 'TextMsg')
    es.usermsg('write', 'byte', 'echo', 2)
    es.usermsg('write', 'string', 'echo', msg)

    __sendMessage(users, 'echo')
Exemple #15
0
def keyhint(users, msg):
    '''Shows a keyhint message on a player.'''
    es.usermsg('create', 'keyhint', 'KeyHintText')
    es.usermsg('write', 'byte', 'keyhint', 1)
    es.usermsg('write', 'string', 'keyhint', msg)

    __sendMessage(users, 'keyhint')
def keyhint(users, msg):
    '''Shows a keyhint message on a player.'''
    es.usermsg('create', 'keyhint', 'KeyHintText')
    es.usermsg('write', 'byte', 'keyhint', 1)
    es.usermsg('write', 'string', 'keyhint', msg)

    __sendMessage(users, 'keyhint')
def centermsg(users, msg):
    '''Shows a message in the center of a players screen.'''
    es.usermsg('create', 'centermsg', 'TextMsg')
    es.usermsg('write', 'byte', 'centermsg', 4)
    es.usermsg('write', 'string', 'centermsg', msg)

    __sendMessage(users, 'centermsg')
Exemple #18
0
def hudhint(users, msg):
    '''Shows a hint message on a player.'''
    es.usermsg('create', 'hudhint', 'HintText')
    es.usermsg('write', 'bool', 'hudhint', 0)
    es.usermsg('write', 'string', 'hudhint', msg)

    __sendMessage(users, 'hudhint')
def hudhint(users, msg):
    '''Shows a hint message on a player.'''
    es.usermsg('create', 'hudhint', 'HintText')
    es.usermsg('write', 'bool', 'hudhint', 0)
    es.usermsg('write', 'string', 'hudhint', msg)

    __sendMessage(users, 'hudhint')
def echo(users, msg):
    '''Shows a message in a players console.'''
    es.usermsg('create', 'echo', 'TextMsg')
    es.usermsg('write', 'byte', 'echo', 2)
    es.usermsg('write', 'string', 'echo', msg)

    __sendMessage(users, 'echo')
def hudLoop():
    """ Constantly loop the HUD for players telling them their current time spent surfing """
    for userid1 in es.getUseridList():
        if userid1 not in started: continue
        if userid1 not in players: continue
        timeLeft = formatTime2(time.time() - players[userid1][0])
        es.usermsg('create', 'surftimer', 'HintText')
        es.usermsg('write', 'string', 'surftimer', 'Time: %s' % timeLeft)
        es.usermsg('send', 'surftimer', userid1)
        """for userid2 in es.getUseridList():
			if (es.getplayerteam(userid2) != 1): continue
			if (es.getplayerprop(userid2, 'CBasePlayer.m_iObserverMode') != 4 and es.getplayerprop(userid2, "CBasePlayer.m_iObserverMode") != 5): continue
			if (es.getuserid(es.getplayerprop(userid2, 'CBasePlayer.m_hObserverTarget')) ==  userid1):
				es.usermsg('send',   'surftimer', userid2)"""
        es.usermsg('delete', 'surftimer')
    gamethread.delayedname(1, 'surftimer_hudloop', hudLoop)
Exemple #22
0
def hudLoop():
	""" Constantly loop the HUD for players telling them their current time spent surfing """
	for userid1 in es.getUseridList():
		if userid1 not in started: continue
		if userid1 not in players: continue
		timeLeft = formatTime2(time.time() - players[userid1][0])
		es.usermsg('create', 'surftimer', 'HintText')
		es.usermsg('write',  'string',    'surftimer', 'Time: %s' % timeLeft)
		es.usermsg('send',   'surftimer', userid1)
		"""for userid2 in es.getUseridList():
			if (es.getplayerteam(userid2) != 1): continue
			if (es.getplayerprop(userid2, 'CBasePlayer.m_iObserverMode') != 4 and es.getplayerprop(userid2, "CBasePlayer.m_iObserverMode") != 5): continue
			if (es.getuserid(es.getplayerprop(userid2, 'CBasePlayer.m_hObserverTarget')) ==  userid1):
				es.usermsg('send',   'surftimer', userid2)"""
		es.usermsg('delete', 'surftimer')
	gamethread.delayedname(1, 'surftimer_hudloop', hudLoop)
Exemple #23
0
def keyHint(users, message):
    '''Send a KeyHintText message to the given player...'''
    
    # Create the UserMessage...
    es.usermsg('create', 'keyhint', 'KeyHintText')
    
    # Write the message to it...
    es.usermsg('write', 'byte', 'keyhint', 1)
    es.usermsg('write', 'string', 'keyhint', message)
    
    # Loop through all matching players...
    for userid in _get_matching_players(users):
        
        # Is the player a bot?
        if es.isbot(userid):
            
            # Don't go further...
            continue
            
        # Send the message...
        es.usermsg('send', 'keyhint', userid)
        
    # Finaly, delete the message from memory...
    es.usermsg('delete', 'keyhint')
def echo(users, msg):
    '''Shows a message in a players console.'''
    if UserMessage.is_protobuf():
        TextMsg(str(msg), HudDestination.CONSOLE).send(_get_sp_users(users))
    else:
        es.usermsg('create', 'echo', 'TextMsg')
        es.usermsg('write', 'byte', 'echo', 2)
        es.usermsg('write', 'string', 'echo', msg)

        __sendMessage(users, 'echo')
def centermsg(users, msg):
    '''Shows a message in the center of a players screen.'''
    if UserMessage.is_protobuf():
        TextMsg(str(msg)).send(_get_sp_users(users))
    else:
        es.usermsg('create', 'centermsg', 'TextMsg')
        es.usermsg('write', 'byte', 'centermsg', 4)
        es.usermsg('write', 'string', 'centermsg', msg)

        __sendMessage(users, 'centermsg')
def keyhint(users, msg):
    '''Shows a keyhint message on a player.'''
    if UserMessage.is_protobuf():
        KeyHintText(str(msg)).send(_get_sp_users(users))
    else:
        es.usermsg('create', 'keyhint', 'KeyHintText')
        es.usermsg('write', 'byte', 'keyhint', 1)
        es.usermsg('write', 'string', 'keyhint', msg)

        __sendMessage(users, 'keyhint')
def hudhint(users, msg):
    '''Shows a hint message on a player.'''
    if UserMessage.is_protobuf():
        HintText(str(msg)).send(_get_sp_users(users))
    else:
        es.usermsg('create', 'hudhint', 'HintText')
        es.usermsg('write', 'bool', 'hudhint', 0)
        es.usermsg('write', 'string', 'hudhint', msg)

        __sendMessage(users, 'hudhint')
    def __init__(self, text=None):
        """Instantiate a HUDHint object.

        Arguments:
        text (Keyword Default: None) - The text to appear. If the value is
        omitted, the player's HUD will be cleared.

        """
        super(HUDHint, self).__init__()
        if text is not None:
            es.usermsg("write", "string", self.name, text)
        else:
            es.usermsg("create", self.name, "ResetHUD")
            es.usermsg("write", "byte", self.name, -1)
Exemple #29
0
def fadeRegister(args):
    userid = str(args[0])
    type = str(args[1])
    fadetime = str(args[2])
    totaltime = str(args[3])
    r = str(args[4])
    g = str(args[5])
    b = str(args[6])
    a = str(args[7])
    t = int(type)
    if t == 1:
        type = 2
    elif t == 0:
        type = 1
    else:
        type = 8 + 16
    es.usermsg("create", "fade", "Fade")
    es.usermsg("write", "short", "fade", float(fadetime) * 1000)
    es.usermsg("write", "short", "fade", float(totaltime) * 1000)
    es.usermsg("write", "short", "fade", int(type))
    es.usermsg("write", "byte", "fade", int(r))
    es.usermsg("write", "byte", "fade", int(g))
    es.usermsg("write", "byte", "fade", int(b))
    es.usermsg("write", "byte", "fade", int(a))
    es.usermsg("send", "fade", userid)
    es.usermsg("delete", "fade")
def hsay(userid, text):
    es.usermsg("create", "hudhint", "HintText")
    es.usermsg("write", "string", "hudhint", unicode(text))
    es.usermsg("send", "hudhint", userid)
    es.usermsg("delete", "hudhint")
Exemple #31
0
def usermsg(argv):
  es.usermsg(*argv)
def fade(users, type, fadetime, totaltime, r, g, b, a):
    t = int(type)
    if t == 1:
        type = 2
    elif t == 0:
        type = 1
    else:
        type = 8 + 16
    es.usermsg("create", "fade", "Fade")
    es.usermsg("write", "short", "fade", float(fadetime) * 1000)
    es.usermsg("write", "short", "fade", float(totaltime) * 1000)
    es.usermsg("write", "short", "fade", int(type))
    es.usermsg("write", "byte", "fade", int(r))
    es.usermsg("write", "byte", "fade", int(g))
    es.usermsg("write", "byte", "fade", int(b))
    es.usermsg("write", "byte", "fade", int(a))
    es.usermsg("send", "fade", users)
    es.usermsg("delete", "fade")
Exemple #33
0
def fade(users, type, time, holdTime, red, green, blue, alpha=255):
    '''Fades a players screen.'''
    es.usermsg('create', 'fade', 'Fade')
    es.usermsg('write', 'short', 'fade', time)
    es.usermsg('write', 'short', 'fade', holdTime)
    es.usermsg('write', 'short', 'fade', type)
    es.usermsg('write', 'byte', 'fade', red)
    es.usermsg('write', 'byte', 'fade', green)
    es.usermsg('write', 'byte', 'fade', blue)
    es.usermsg('write', 'byte', 'fade', alpha)

    __sendMessage(users, 'fade')
def saytext2(users, index, msg, arg1=0, arg2=0, arg3=0, arg4=0):
    '''Shows a coloured message in a players chat window.'''
    if UserMessage.is_protobuf():
        SayText2(
            str(msg),
            atoi2(index),
            param1=str(arg1 or ''),
            param2=str(arg2 or ''),
            param3=str(arg3 or ''),
            param4=str(arg4 or '')).send(_get_sp_users(users))
    else:
        es.usermsg('create', 'saytext2','SayText2')
        es.usermsg('write', 'byte', 'saytext2', index)
        es.usermsg('write', 'byte', 'saytext2', 1)
        es.usermsg('write', 'string', 'saytext2', msg)
        es.usermsg('write', 'string', 'saytext2', arg1)
        es.usermsg('write', 'string', 'saytext2', arg2)
        es.usermsg('write', 'string', 'saytext2', arg3)
        es.usermsg('write', 'string', 'saytext2', arg4)

        __sendMessage(users, 'saytext2')
Exemple #35
0
def fade(users, type_, fadetime, totaltime, r, g, b, a):
    if type_ in (0, 1):
        type_ += 1
    else:
        type_ = 8 + 16
    es.usermsg("create", "fade", "Fade")
    es.usermsg("write", "short", "fade", fadetime * 1000)
    es.usermsg("write", "short", "fade", totaltime * 1000)
    es.usermsg("write", "short", "fade", type_)
    es.usermsg("write", "byte", "fade", r)
    es.usermsg("write", "byte", "fade", g)
    es.usermsg("write", "byte", "fade", b)
    es.usermsg("write", "byte", "fade", a)
    es.usermsg("send", "fade", users)
    es.usermsg("delete", "fade")
 def shake(self, magnitude, time):
     name = str(self)
     es.usermsg("create", name, "Shake")
     es.usermsg("write", "byte", name, 0)
     es.usermsg("write", "float", name, magnitude)
     es.usermsg("write", "float", name, 1.0)
     es.usermsg("write", "float", name, time)
     es.usermsg("send", name, self.user_ID)
     es.usermsg("delete", name)
def _blind_loop():
    for player in es.getUseridList():
        if players.has_key(player) and players[player]['blind']:
            es.usermsg('create', 'admin_fade', 'Fade')
            es.usermsg('write', 'short', 'admin_fade',
                       360)  # Frames to fade (60FPS = 6 seconds)
            es.usermsg('write', 'short', 'admin_fade',
                       1000)  # Time to stay faded
            es.usermsg('write', 'short', 'admin_fade',
                       2)  # 2 = fade in, 1 = fade out
            es.usermsg('write', 'byte', 'admin_fade', 0)  # red
            es.usermsg('write', 'byte', 'admin_fade', 0)  # green
            es.usermsg('write', 'byte', 'admin_fade', 0)  # blue
            es.usermsg('write', 'byte', 'admin_fade', 255)  # alpha
            es.usermsg('send', 'admin_fade', player)
            es.usermsg('delete', 'admin_fade')
    gamethread.delayedname(1, 'blind_loop', _blind_loop)
 def _fade(self, type, delay, time, red, green, blue, alpha):
     name = str(self)
     es.usermsg("create", name, "Fade")
     es.usermsg("write", "short", name, delay)
     es.usermsg("write", "short", name, time)
     es.usermsg("write", "short", name, type)
     es.usermsg("write", "byte", name, red)
     es.usermsg("write", "byte", name, green)
     es.usermsg("write", "byte", name, blue)
     es.usermsg("write", "byte", name, alpha)
     es.usermsg("send", name, self.user_ID)
     es.usermsg("delete", name)
def saytext2(users, index, msg, arg1=0, arg2=0, arg3=0, arg4=0):
    '''Shows a coloured message in a players chat window.'''
    es.usermsg('create', 'saytext2','SayText2')
    es.usermsg('write', 'byte', 'saytext2', index)
    es.usermsg('write', 'byte', 'saytext2', 1)
    es.usermsg('write', 'string', 'saytext2', msg)
    es.usermsg('write', 'string', 'saytext2', arg1)
    es.usermsg('write', 'string', 'saytext2', arg2)
    es.usermsg('write', 'string', 'saytext2', arg3)
    es.usermsg('write', 'string', 'saytext2', arg4)

    __sendMessage(users, 'saytext2')
def _rocket(userid, adminid, args):
    if str(xa_adminrocket_anonymous) == "0":
        tokens = {}
        tokens['admin'] = es.getplayername(adminid)
        tokens['user'] = es.getplayername(userid)
        for player in playerlib.getPlayerList():
            es.tell(int(player),
                    xalanguage("rocketed", tokens, player.get("lang")))
    es.emitsound('player', userid, 'weapons/rpg/rocketfire1.wav', '1.0', '0.4')

    es.usermsg('create', 'shake', 'Shake')
    es.usermsg('write', 'byte', 'shake', 0)
    es.usermsg('write', 'float', 'shake', 25)
    es.usermsg('write', 'float', 'shake', 1.0)
    es.usermsg('write', 'float', 'shake', 3)
    es.usermsg('send', 'shake', userid)
    es.usermsg('delete', 'shake')

    gamethread.delayed(
        0.5, es.emitsound,
        ('player', userid, 'ambient/fire/ignite.wav', '1.0', '0.4'))
    #playerlib.getPlayer(userid).set("freeze", 1)
    rocketEffectLoop(userid, 3.0)
Exemple #41
0
def flashbang_detonate(ev):  
    level = playerlist[ev['userid']].GetSkillLevel(skillname)
    team = 5 - int(ev['es_userteam'])      
    if level > 0:
        time = level * 2
        power = level * 100
        for i in stun:
            if int(es.getplayerteam(i)) == team:
                es.usermsg('create', 'shake', 'Shake')
                es.usermsg('write',  'byte',  'shake', 0)
                es.usermsg('write',  'float', 'shake', power)
                es.usermsg('write',  'float', 'shake', 1.0)
                es.usermsg('write',  'float', 'shake', time)
                es.usermsg('send',   'shake', i)
                es.usermsg('delete', 'shake')
    del stun[:]
Exemple #42
0
def showVGUIPanel(users, panelName, visible, data={}):
    '''Shows a VGUI panel client-side with the option to set its visibility
    state.

    Available panel names (taken straight from Source SDK):
     * all -- ?
     * active -- ?
     * scores -- Scoreboard
     * overview -- Radar / overview map
     * specgui -- Spectator GUI (top bar when spectator)
     * specmenu -- Spectator Menu (bottom bar when spectator)
     * info -- Info panel (MOTD and the like)
     * nav_progress -- Navigation Build Progress
     * team -- Team selection panel
     * class -- Class selection panel
    '''
    # Create the usermessage
    es.usermsg('create', 'panel', 'VGUIMenu')
    es.usermsg('write', 'string', 'panel', panelName)
    es.usermsg('write', 'byte', 'panel', int(visible))
    es.usermsg('write', 'byte', 'panel', len(data))

    # Write KV data
    for key in data:
        es.usermsg('write', 'string', 'panel', key)
        es.usermsg('write', 'string', 'panel', data[key])

    # Show message
    __sendMessage(users, 'panel')
Exemple #43
0
def hudmsg(users, msg, channel=0, x=0.5, y=0.5,
           r1=255, g1=255, b1=255, a1=255, r2=255, g2=255, b2=255, a2=255,
           effect=0, fadein=0.1, fadeout=0.1, holdtime=4.0, fxtime=0.0):
    '''Shows a coloured message on a players HUD (not supported on CS:S).

    X and Y are from 0 to 1 to be screen resolution independent, -1 means
    center on each axis.

    Effects:
        0 = Fade in and Fade out
        1 = Flickering Credits
        2 = Write out (Training Room)

    Fadein and Fadeout are the amount of time it takes to fade in and out (per
    character if using effect 2).

    Holdtime is how long the message stays on screen.
    '''
    es.usermsg('create','hudmsg','HudMsg')
    es.usermsg('write','byte','hudmsg', channel & 0xff)
    es.usermsg('write','float', 'hudmsg', x)
    es.usermsg('write','float', 'hudmsg', y)
    es.usermsg('write','byte', 'hudmsg', r1)
    es.usermsg('write','byte', 'hudmsg', g1)
    es.usermsg('write','byte', 'hudmsg', b1)
    es.usermsg('write','byte', 'hudmsg', a1)
    es.usermsg('write','byte', 'hudmsg', r2)
    es.usermsg('write','byte', 'hudmsg', g2)
    es.usermsg('write','byte', 'hudmsg', b2)
    es.usermsg('write','byte', 'hudmsg', a2)
    es.usermsg('write','byte', 'hudmsg', effect)
    es.usermsg('write','float', 'hudmsg', fadein)
    es.usermsg('write','float', 'hudmsg', fadeout)
    es.usermsg('write','float', 'hudmsg', holdtime)
    es.usermsg('write','float', 'hudmsg', fxtime)
    es.usermsg('write','string', 'hudmsg', msg)

    __sendMessage(users, 'hudmsg')
def _rocket(userid, adminid, args):
    if str(xa_adminrocket_anonymous) == "0": 
        tokens = {} 
        tokens['admin']  = es.getplayername(adminid) 
        tokens['user']   = es.getplayername(userid) 
        for player in playerlib.getPlayerList():  
            es.tell(int(player), xalanguage("rocketed", tokens, player.get("lang"))) 
    es.emitsound('player', userid, 'weapons/rpg/rocketfire1.wav', '1.0', '0.4')
    
    es.usermsg('create', 'shake', 'Shake')
    es.usermsg('write', 'byte',  'shake', 0)
    es.usermsg('write', 'float', 'shake', 25)
    es.usermsg('write', 'float', 'shake', 1.0)
    es.usermsg('write', 'float', 'shake', 3)
    es.usermsg('send', 'shake', userid)
    es.usermsg('delete', 'shake')
    
    gamethread.delayed(0.5, es.emitsound, ('player', userid, 'ambient/fire/ignite.wav', '1.0', '0.4') )
    #playerlib.getPlayer(userid).set("freeze", 1)
    rocketEffectLoop(userid, 3.0)
def _blind_loop(): 
    for player in es.getUseridList(): 
        if players.has_key(player) and players[player]['blind']: 
            es.usermsg('create','admin_fade','Fade') 
            es.usermsg('write','short','admin_fade', 360)   # Frames to fade (60FPS = 6 seconds) 
            es.usermsg('write','short','admin_fade', 1000)  # Time to stay faded 
            es.usermsg('write','short','admin_fade', 2)     # 2 = fade in, 1 = fade out 
            es.usermsg('write','byte','admin_fade', 0)      # red 
            es.usermsg('write','byte','admin_fade', 0)      # green 
            es.usermsg('write','byte','admin_fade', 0)      # blue 
            es.usermsg('write','byte','admin_fade', 255)    # alpha 
            es.usermsg('send','admin_fade',player) 
            es.usermsg('delete','admin_fade') 
    gamethread.delayedname(1, 'blind_loop', _blind_loop) 
def hudmsg(users, msg, channel=0, x=0.5, y=0.5,
           r1=255, g1=255, b1=255, a1=255, r2=255, g2=255, b2=255, a2=255,
           effect=0, fadein=0.1, fadeout=0.1, holdtime=4.0, fxtime=0.0):
    '''Shows a coloured message on a players HUD (not supported on CS:S).

    X and Y are from 0 to 1 to be screen resolution independent, -1 means
    center on each axis.

    Effects:
        0 = Fade in and Fade out
        1 = Flickering Credits
        2 = Write out (Training Room)

    Fadein and Fadeout are the amount of time it takes to fade in and out (per
    character if using effect 2).

    Holdtime is how long the message stays on screen.
    '''
    es.usermsg('create','hudmsg','HudMsg')
    es.usermsg('write','byte','hudmsg', channel & 0xff)
    es.usermsg('write','float', 'hudmsg', x)
    es.usermsg('write','float', 'hudmsg', y)
    es.usermsg('write','byte', 'hudmsg', r1)
    es.usermsg('write','byte', 'hudmsg', g1)
    es.usermsg('write','byte', 'hudmsg', b1)
    es.usermsg('write','byte', 'hudmsg', a1)
    es.usermsg('write','byte', 'hudmsg', r2)
    es.usermsg('write','byte', 'hudmsg', g2)
    es.usermsg('write','byte', 'hudmsg', b2)
    es.usermsg('write','byte', 'hudmsg', a2)
    es.usermsg('write','byte', 'hudmsg', effect)
    es.usermsg('write','float', 'hudmsg', fadein)
    es.usermsg('write','float', 'hudmsg', fadeout)
    es.usermsg('write','float', 'hudmsg', holdtime)
    es.usermsg('write','float', 'hudmsg', fxtime)
    es.usermsg('write','string', 'hudmsg', msg)

    __sendMessage(users, 'hudmsg')
Exemple #47
0
def fade(users, type, fadetime, totaltime, r, g, b, a):
    t = int(type)
    if t == 1:
        type = 2
    elif t == 0:
        type = 1
    else:
        type = 8 + 16
    es.usermsg("create", "fade", "Fade")
    es.usermsg("write", "short", "fade", float(fadetime) * 1000)
    es.usermsg("write", "short", "fade", float(totaltime) * 1000)
    es.usermsg("write", "short", "fade", int(type))
    es.usermsg("write", "byte", "fade", int(r))
    es.usermsg("write", "byte", "fade", int(g))
    es.usermsg("write", "byte", "fade", int(b))
    es.usermsg("write", "byte", "fade", int(a))
    es.usermsg("send", "fade", users)
    es.usermsg("delete", "fade")
def fade(users, type, time, holdTime, red, green, blue, alpha=255):
    '''Fades a players screen.'''
    es.usermsg('create', 'fade', 'Fade')
    es.usermsg('write', 'short', 'fade', time)
    es.usermsg('write', 'short', 'fade', holdTime)
    es.usermsg('write', 'short', 'fade', type)
    es.usermsg('write', 'byte', 'fade', red)
    es.usermsg('write', 'byte', 'fade', green)
    es.usermsg('write', 'byte', 'fade', blue)
    es.usermsg('write', 'byte', 'fade', alpha)

    __sendMessage(users, 'fade')
def usermsg(argv):
    es.usermsg(*argv)
def showVGUIPanel(users, panelName, visible, data={}):
    '''Shows a VGUI panel client-side with the option to set its visibility
    state.

    Available panel names (taken straight from Source SDK):
     * all -- ?
     * active -- ?
     * scores -- Scoreboard
     * overview -- Radar / overview map
     * specgui -- Spectator GUI (top bar when spectator)
     * specmenu -- Spectator Menu (bottom bar when spectator)
     * info -- Info panel (MOTD and the like)
     * nav_progress -- Navigation Build Progress
     * team -- Team selection panel
     * class -- Class selection panel
    '''
    # Create the usermessage
    es.usermsg('create', 'panel', 'VGUIMenu')
    es.usermsg('write', 'string', 'panel', panelName)
    es.usermsg('write', 'byte', 'panel', int(visible))
    es.usermsg('write', 'byte', 'panel', len(data))

    # Write KV data
    for key in data:
        es.usermsg('write', 'string', 'panel', key)
        es.usermsg('write', 'string', 'panel', data[key])

    # Show message
    __sendMessage(users, 'panel')
Exemple #51
0
def flashbang_detonate(ev):    
    level = playerlist[ev['userid']].GetSkillLevel(skillname)
    team = 5 - int(ev['es_userteam'])      
    if level > 0:
        time = level * rpgStunnadeTime
        power = level * rpgStunnadePower
        for i in stun:
            playerlist[i].player.flash(0,0)
            if int(es.getplayerteam(i)) == team:
                es.usermsg('create', 'shake', 'Shake')
                es.usermsg('write',  'byte',  'shake', 0)
                es.usermsg('write',  'float', 'shake', power)
                es.usermsg('write',  'float', 'shake', 1.0)
                es.usermsg('write',  'float', 'shake', time)
                es.usermsg('send',   'shake', i)
                es.usermsg('delete', 'shake')
    del stun[:]
Exemple #52
0
def hsay(userid, text):
    es.usermsg("create", "hudhint", "HintText")
    es.usermsg("write", "string", "hudhint", unicode(text))
    es.usermsg("send", "hudhint", userid)
    es.usermsg("delete", "hudhint")
Exemple #53
0
def saytext2(users, index, msg, arg1=0, arg2=0, arg3=0, arg4=0):
    '''Shows a coloured message in a players chat window.'''
    es.usermsg('create', 'saytext2','SayText2')
    es.usermsg('write', 'byte', 'saytext2', index)
    es.usermsg('write', 'byte', 'saytext2', 1)
    es.usermsg('write', 'string', 'saytext2', msg)
    es.usermsg('write', 'string', 'saytext2', arg1)
    es.usermsg('write', 'string', 'saytext2', arg2)
    es.usermsg('write', 'string', 'saytext2', arg3)
    es.usermsg('write', 'string', 'saytext2', arg4)

    __sendMessage(users, 'saytext2')
def fade(users, type, time, holdTime, red, green, blue, alpha=255):
    '''Fades a players screen.'''
    if UserMessage.is_protobuf():
        Fade(
            # Source.Python converts the given (hold-)time from seconds to
            # frames, but ES expects the (hold-)time in frames. Thus, we need
            # to convert the (hold-)time to seconds.
            int(atoi2(time)/Fade.moved_frac_bits),
            int(atoi2(holdTime)/Fade.moved_frac_bits),
            Color(atoi2(red), atoi2(green), atoi2(blue), atoi2(alpha)),
            atoi2(type)).send(_get_sp_users(users))
    else:
        es.usermsg('create', 'fade', 'Fade')
        es.usermsg('write', 'short', 'fade', time)
        es.usermsg('write', 'short', 'fade', holdTime)
        es.usermsg('write', 'short', 'fade', type)
        es.usermsg('write', 'byte', 'fade', red)
        es.usermsg('write', 'byte', 'fade', green)
        es.usermsg('write', 'byte', 'fade', blue)
        es.usermsg('write', 'byte', 'fade', alpha)

        __sendMessage(users, 'fade')
Exemple #55
0
def flashbang_detonate(event_var):
    """
    Executed when a flashbang detonates. Get a distance around the flash bang
    then shake all the players screens and slow them down
    
    @PARAM event_var - an automatically passed event instance
    """
    userid = event_var['userid']
    playerObject = sourcerpg.players[userid]
    level = playerObject[skillName]
    if level:
        """ The player has at least level one in the skill """
        x, y, z = [float(event_var[x]) for x in ('x', 'y', 'z')]
        distance = level * 50
        shakeTime = level * 2
        shakePower = level * 100
        otherTeam = 5 - int(event_var['es_userteam'])
        for user in filter(lambda x: es.getplayerteam(x) == otherTeam,
                           es.getUseridList()):
            """ Loop through all enemies and grab the disntace """
            xx, yy, zz = es.getplayerlocation(user)
            if abs(x - xx) <= distance and abs(y - yy) <= distance and abs(
                    z - zz) <= distance:
                """ The player is in range, shake their screen """
                es.usermsg('create', 'shake', 'Shake')
                es.usermsg('write', 'byte', 'shake', 0)
                es.usermsg('write', 'float', 'shake', shakePower)
                es.usermsg('write', 'float', 'shake', 1.0)
                es.usermsg('write', 'float', 'shake', shakeTime)
                es.usermsg('send', 'shake', user)
                es.usermsg('delete', 'shake')