示例#1
0
def voteBanCheck(userid, choice, popupid):
    """
    Executed when a player has chosen another to vote ban. Get the steamid
    of the victim, and check for the amount of bans needed. Ban the player
    if their are enough votes
    """
    userid = str(userid)
    if not es.exists('userid', choice):
        """ Something went wrong, the user no longer exists, return early """
        return
    steamid = es.getplayersteamid(choice)
    if userid not in userids or steamid not in targets:
        """ One of the instances weren't avaiable, return early """
        return
        
    xavotekickban.logging.log("has voted to ban user %s [%s]" % (es.getplayername(choice), es.getplayersteamid(choice) ), userid )
    userids[userid]["bans"].append(choice)
    targets[steamid]["bans"] += 1
    bansRemaining = getBansRemaining(steamid)
    if bansRemaining == 0:
        """ There has been enough kicks passed, kick the player. """
        removePlayer(steamid)
        es.server.queuecmd('banid %s %s;writeid;kickid %s "You have been banned"' % (banTime, choice, choice) )
        tokens = {}
        tokens['name'] = es.getplayername(choice)
        for player in playerlib.getPlayerList('#all'):
            es.tell(int(player), '#multi', xalanguage('player banned', tokens, player.get("lang") ) )
        xavotekickban.logging.log("has been vote banned", choice)
    else:
        tokens = {}
        tokens['name']   = es.getplayername(choice)
        tokens['amount'] = bansRemaining
        for player in playerlib.getPlayerList("#all"):
            es.tell( int(player), '#multi', xalanguage('player votes banned', tokens, player.get("lang") ) )
        xavotekickban.logging.log("needs %s more votes till they are banned" % bansRemaining, choice)
示例#2
0
 def _Win(self, popupid, optionid, choice, winner_votes, winner_percent, total_votes, was_tied, was_canceled):
     self.display.Stop()
     es.cexec_all('playgamesound', str(vote_end_sound) )
     if not was_tied or was_canceled:
         if choice != "0" and winner_votes:
             if self.option and self.options[choice]['winner']:
                 if isinstance(self.option, str):
                     es.server.cmd(self.option)
                 elif callable(self.option):
                     self.params = {}
                     self.params['winner']      = choice
                     self.params['votes']       = winner_votes
                     self.params['percent']     = winner_percent
                     self.params['total votes'] = total_votes
                     self.option(self.params)
             tokens = {}
             tokens['winner']     = choice 
             tokens['votes']      = winner_votes 
             tokens['totalvotes'] = total_votes
             tokens['percent']    = winner_percent
             
             for player in playerlib.getPlayerList("#human"): 
                 es.tell(int(player),'#multi',xalanguage("vote win",tokens, player.get("lang")))
         else:
             for player in playerlib.getPlayerList("#human"): 
                 es.tell(int(player),'#green',xalanguage("vote no voters", {}, player.get("lang")))
          
     elif was_tied and not was_canceled:
         for player in playerlib.getPlayerList("#human"): 
             es.tell(int(player),'#green',xalanguage("vote tie", player.get("lang")))
         possibilities = []
         maxAmount = 0
         for possibility in self.display.SortDict():
             amount = self.display.votes[possibility]['votes'] 
             if amount < maxAmount:
                 break
             maxAmount = amount
             possibilities.append(possibility)
         winner = random.choice(possibilities)
         tokens = {}
         tokens['winner'] = winner
         for player in playerlib.getPlayerList("#human"): 
             es.tell(int(player),'#multi',xalanguage("random win", tokens, player.get("lang")))
         if self.option and self.options[winner]['winner']:
             if isinstance(self.option, str):
                 es.server.cmd(self.option)
             elif callable(self.option):
                 self.params = {}
                 self.params['winner']      = winner
                 self.params['votes']       = winner_votes
                 self.params['percent']     = winner_percent
                 self.params['total votes'] = total_votes
                 self.option(self.params)
     else: 
         for player in playerlib.getPlayerList("#human"): 
             es.tell(int(player), '#green', xalanguage("vote canceled", player.get("lang") ) )
示例#3
0
def _select_player(userid, choice, popupid):
    command = admins[userid]['command']
    if command.startswith('weapon_') or command.startswith('item_'):
        if 'vest' not in command:
            if str(admingive_stripfirst) == '1':
                if command.replace('weapon_','') in pistols:
                    secondary = playerlib.getPlayer(choice).get('secondary') 
                    if secondary:
                        RemoveWeapon(choice, secondary)
                elif command.replace('weapon_','') in (list(shotguns) + list(smgs) + list(rifles) + list(snipers) + ['m249']):
                    primary = playerlib.getPlayer(choice).get('primary') 
                    if primary:
                        RemoveWeapon(choice, primary)
            gamethread.delayed(0.1, es.server.queuecmd, 'es_xgive %s %s'%(choice, command))
        else:
            if 'helm' in command:
                es.setplayerprop(choice, 'CCSPlayer.m_bHasHelmet', 1)
            es.setplayerprop(choice, 'CCSPlayer.m_ArmorValue', 100)
        if str(admingive_anonymous) == '0':
            tokens = {}
            tokens['admin'] = es.getplayername(userid)
            tokens['user']  = es.getplayername(choice)
            for myplayer in playerlib.getPlayerList('#human'):
                tokens['item'] = '#greena #lightgreen' + str(xalanguage(command.replace('weapon_','').replace('item_',''), lang=myplayer.get("lang")))
                es.tell(int(myplayer), '#multi', xalanguage('admin give', tokens, myplayer.get("lang")))
    elif command.startswith('health_'):
        if str(admingive_anonymous) == '0':
            tokens = {}
            tokens['admin'] = es.getplayername(userid)
            tokens['user']  = es.getplayername(choice)
            health = command.replace('health_','')
            c = ''
            while len(health) > 3:
                c = ',' + health[-3:]
                health = health[0:-3]
            c = health + c
            tokens['item'] = '#green' + c + ' #lightgreenhealth'
            for myplayer in playerlib.getPlayerList('#human'):
                es.tell(int(myplayer), '#multi', xalanguage('admin give', tokens, myplayer.get("lang")))
        es.setplayerprop(choice, 'CBasePlayer.m_iHealth', es.getplayerprop(choice, 'CBasePlayer.m_iHealth') + int(command.replace('health_','')))
    elif command.startswith('cash_'):
        if str(admingive_anonymous) == '0':
            tokens = {}
            tokens['admin'] = es.getplayername(userid)
            tokens['user']  = es.getplayername(choice)
            cash = command.replace('cash_','')
            c = ''
            while len(cash) > 3:
                c = ',' + cash[-3:]
                cash = cash[0:-3]
            c = '$' + cash + c
            tokens['item'] = '#green' + c
            for myplayer in playerlib.getPlayerList('#human'):
                es.tell(int(myplayer), '#multi', xalanguage('admin give', tokens, myplayer.get("lang")))
        es.setplayerprop(choice, 'CCSPlayer.m_iAccount', es.getplayerprop(choice, 'CCSPlayer.m_iAccount') + int(command.replace('cash_','')))
示例#4
0
def setAttribute(filter, attribute, value):
    '''
    Sets a Player() attribute by userid or by filter:
        #all, #alive, #dead, #human, #bot, #un, #spec
    Note:
        See playerlib.getPlayerList() for the appropriate filters.

    Usage:
        from gungame.core.players.shortcuts import setAttribute

        # Set a custom attribute for all players
        setAttribute('#all', 'myattribute', 0)

        # Call this attribute (from some event that provides a userid)
        es.msg('myattribute for %s = %s' % (event_var['es_username'],
            Player(event_var['userid']).myattribute))
    '''
    if isinstance(filter, int):
        filter = str(filter)

    if '#' in filter:
        for userid in getPlayerList(filter):
            Player(userid)[attribute] = copy(value)
        return
    Player(filter)[attribute] = value
示例#5
0
def deleteAttribute(filter, attribute):
    '''
    Deletes a Player() attribute by userid or by filter:
        #all, #alive, #dead, #human, #bot, #un, #spec

    Note:
        See playerlib.getPlayerList() for the appropriate filters.

    Usage:
        from gungame.core.players.shortcuts import deleteAttribute

        # Delete a custom attribute for all players
        deleteAttribute('#all', 'myattribute')

        # Delete a custom attribute from one player
        deleteAttribute(event_var['userid'], 'myattribute')
    '''
    if isinstance(filter, int):
        filter = str(filter)

    if '#' in filter:
        for userid in getPlayerList(filter):
            del Player(userid)[attribute]
        return
    del Player(filter)[attribute]
示例#6
0
 def check(self):
     """
     This function is a function which is repeated every second to check
     all current player positions and relative smoke grenades. If the
     player is in range, damage them.
     """
     smokeList = es.createentitylist("smokegrenade_projectile")
     for entity in self.entities.copy():
         if entity in smokeList:
             x, y, z = map(
                 float,
                 es.getindexprop(entity,
                                 'CBaseEntity.m_vecOrigin').split(","))
             player = self.entities[entity]
             level = sourcerpg.players[player][skillName]
             for loopPlayer in playerlib.getPlayerList(
                     '#t,#alive' if es.getplayerteam(player) ==
                     3 else '#ct,#alive'):
                 xx, yy, zz = loopPlayer.get('location')
                 if abs(x - xx) <= 220 and abs(y - yy) <= 220 and abs(
                         z - zz) <= 220:
                     es.server.queuecmd('damage %s %s 32 %s' %
                                        (int(loopPlayer), level *
                                         int(damagePerLevel), player))
                     es.emitsound(
                         'player', int(loopPlayer),
                         'player/damage%s.wav' % random.randint(1, 3),
                         '0.7', '0.6')
         else:
             self.removeEntity(entity)
示例#7
0
def teleportPlayerToPlayer(userid, choice, popupid):
    target, recipient = choice
    if es.getplayerprop(target, 'CBasePlayer.pl.deadflag') or es.getplayerprop(
            recipient, 'CBasePlayer.pl.deadflag'):
        es.tell(
            userid,
            xalanguage('one player died', {},
                       playerlib.getPlayer(userid).get("lang")))
        return

    if not es.exists('userid', target) or not es.exists('userid', recipient):
        """ One of the player's doesn't exists... Return early and break the function """
        return
    x, y, z = es.getplayerlocation(recipient)
    z += 100
    es.server.queuecmd('es_xsetpos %s %s %s %s' % (target, x, y, z))
    if not int(xa_anonymous):
        args = {}
        args["admin"] = es.getplayername(userid)
        args["target"] = es.getplayername(target)
        args["recipient"] = es.getplayername(recipient)
        for player in playerlib.getPlayerList("#all"):
            es.tell(
                int(player),
                xalanguage("player sent to player", args, player.get("lang")))
    xateleport.logging.log(
        "has teleported user %s [%s] to user %s [%s]" %
        (es.getplayername(target), es.getplayersteamid(target),
         es.getplayername(recipient), es.getplayersteamid(recipient)), userid,
        True)
def _action_remove(userid, popupid):
    """
Removes one bot, trying to conserve team balance
    """
    if int(es.ServerVar("bot_quota")):
        if int(es.getplayercount(2)) > int(es.getplayercount(3)):
            prefteam = 2
        else:
            prefteam = 3

        botlist = playerlib.getPlayerList("#bot")
        currentbot = None
        currentlevel = 0
        for botid in botlist:
            level = 1
            if int(botid.get("teamid")) == prefteam:
                level += 4
            if int(botid.get("isdead")) == 1:
                level += 2
            if level == 7:
                # max level, we found our bot >:)
                es.server.queuecmd("bot_kick " + botid.get("name"))
                return True
            if level > currentlevel:
                currentbot = botid
                currentlevel = level
        if currentbot:
            # we found at least one bot...
            es.server.queuecmd("bot_kick " + currentbot.get("name"))
            xabotmanagement.logging.log("kicked bot %s" % currentbot.get("name"), userid, True)
            return True
    # TODO: Insert a message here telling that no bots on server
    # message string: remove_no_bots
    return True
示例#9
0
    def start_warmup(self):
        """Called when Warmup Round needs to start"""

        # Add Warmup Round to PriorityAddon
        self.priorities.add(info.name)

        # Set the Warmup Message
        self.message = "Timer_Ended"

        # Store a backup of mp_freezetime
        self.freezetime = int(mp_freezetime)

        # Set Freeze Time to 0
        mp_freezetime.set(0)

        # Execute the Start Warmup Round cfg
        es.mexec("gungame51/" + str(warmup_start_file))

        # Get the Warmup Weapon
        self.weapon = self.set_warmup_weapon()

        # Start the count down
        self.repeat.start(1, int(warmup_timer))

        # Loop through all living players
        for player in getPlayerList("#alive"):

            # Give the player the warmup weapon
            self.give_warmup_weapon(player.userid)

        # Wait until adding other PriortyAddons
        delayed(0.1, self.add_priority_addons)
def beacon(userid):
    userid = int(userid)
    for player in playerlib.getPlayerList('#alive'):
        if player.team == 2:
            iRed = 255
            iBlue = 0
        else:
            iRed = 0
            iBlue = 255
        spe_effects.beamRingPoint(
        userid, #'#all', # users
        0., # fDelay
        player.location, # vOrigin
        0., # fStartRadius
        600., # fEndRadius
        'sprites/lgtning.vmt', # szModelPath
        1, # iHaloIndex
        0, # iStartFrame
        255, # iFrameRate
        0.3, # fLife
        12, # fWidth
        0, # iSpread
        2., # fAmplitude
        iRed, # iRed
        0, # iGreen
        iBlue, # iBlue
        255, # iAlpha
        0.5, # iSpeed
        0, # iFlags
        )
    gamethread.delayedname(2, 'beacon_%i' % userid, beacon, userid)
示例#11
0
def sendSecondMenu(userid, choice, popupid):
    oldChoice, target = choice
    if oldChoice == 2:
        steamid           = playerlib.uniqueid(userid, False)
        lang              = playerlib.getPlayer(userid).get("lang")
        if steamid not in locations:
            es.tell(userid, "#green", xalanguage("no locations", {}, lang) )
            return
        currentMap = str(es.ServerVar('eventscripts_currentmap'))
        if currentMap not in locations[steamid]:
            es.tell(userid, "#green", xalanguage("no map locations", {}, lang) )
            return
        if es.getplayerprop(target, 'CBasePlayer.pl.deadflag'):
            es.tell(userid, xalanguage('one player died', {}, playerlib.getPlayer(userid).get("lang") ) )
            return
        x, y, z = locations[steamid][currentMap]
        es.server.queuecmd('es_xsetpos %s %s %s %s' % (target, x, y, z + 10) )
        if not int(xa_anonymous):
            args           = {}
            args["player"] = es.getplayername(target)
            args["admin"]  = es.getplayername(userid)
            for player in playerlib.getPlayerList("#all"):
                es.tell(int(player), xalanguage("teleport to location", args, player.get("lang") ) )
        xateleport.logging.log("has teleported user %s [%s] to their saved location" % (es.getplayername(target), es.getplayersteamid(target)), userid)
    else:
        lang = playerlib.getPlayer(userid).get("lang")
        popupMenu = popuplib.easymenu("xa_teleport_players", "_popup_choice", teleportPlayerToPlayer)
        popupMenu.settitle(xalanguage["player select to send to"])
        for player in filter(lambda x: not es.getplayerprop(x, "CBasePlayer.pl.deadflag"), es.getUseridList()):
            popupMenu.addoption([target, player], es.getplayername(player), lang=lang)
        popupMenu.send(userid)
示例#12
0
 def _Message(self, userid, votename, optionid, option):
     tokens = {} 
     tokens['username'] = es.getplayername(userid) 
     tokens['option']   = str(option) 
     for player in playerlib.getPlayerList(): 
         es.tell(int(player),'#multi', xalanguage("vote message", tokens, player.get("lang")))
     self.display.ChangeDict(option, 1)
示例#13
0
def _action_remove(userid, popupid):
    '''
Removes one bot, trying to conserve team balance
    '''
    if int(es.ServerVar('bot_quota')):
        if int(es.getplayercount(2)) > int(es.getplayercount(3)):
            prefteam = 2
        else:
            prefteam = 3
        
        botlist = playerlib.getPlayerList('#bot')
        currentbot = None
        currentlevel = 0
        for botid in botlist:
            level = 1
            if int(botid.get('teamid')) == prefteam:
                level += 4
            if int(botid.get('isdead')) == 1:
                level += 2
            if level == 7:
                # max level, we found our bot >:)
                es.server.queuecmd('bot_kick '+botid.get('name'))
                return True
            if level > currentlevel:
                currentbot = botid
                currentlevel = level
        if currentbot:
            # we found at least one bot...
            es.server.queuecmd('bot_kick '+currentbot.get('name'))
            return True
    # TODO: Insert a message here telling that no bots on server
    # message string: remove_no_bots
    return True
示例#14
0
def round_end(eventVar):
    if int(slay):
        if eventVar["winner"] == "2" and es.getlivingplayercount(3):
            cts, ts = getPlayerList("#ct"), getPlayerList("#t")
            for i in cts:
                i.kill()
                es.tell(int(i), "#multi", text("lost"))
            for i in ts:
                es.tell(int(i), "#multi", text("won"))
        elif eventVar["winner"] == "3" and es.getlivingplayercount(2):
            ts, cts = getPlayerList("#t"), getPlayerList("#ct")
            for i in ts:
                i.kill()
                es.tell(int(i), "#multi", text("lost"))
            for i in cts:
                es.tell(int(i), "#multi", text("won"))
示例#15
0
def load():
    for k, v in cvars.items():
        es.ServerVar(k, 0, v)
    es.server.cmd('exec noblock')
    es.ServerVar('noblock_version', '1.0.0', 'The version of the ES Python noblock script')
    for k in playerlib.getPlayerList():
        players[k.userid] = dict(queued=False)
    if(es.getInt('noblock_load_advert')): es.msg('#multi', '#green[NoBlock]#default NoBlock has been loaded')
示例#16
0
    def play_beep():
        """Plays a beep sound to all players"""

        # Loop through all players
        for player in getPlayerList("#human"):

            # Play the sound
            Player(player.userid).playsound("countDownBeep")
示例#17
0
def mapmenu_handler(userid, choice, popupname):
    if gActions[userid] == "changemap":
        es.server.cmd("changelevel " + choice)
    elif gActions[userid] == "setnextmap":
        nextmapvar.set(choice)
        if str(xa_announce_setnextmap) == "1":
            for player in playerlib.getPlayerList():
                es.tell(player.userid, xalanguage("new next map", {"mapname": choice}, player.get("lang")))
    del gActions[userid]
示例#18
0
def fillDatabase():
    for player in playerlib.getPlayerList('#human'):
        steamid = sid(int(player))
        if steamid not in players:
            players.newplayer(steamid)
        players.update(steamid,'sessionstart',player.attributes['timeconnected'])
        players.update(steamid,'lastseen',time.time())
        players.name(steamid,player.attributes['name'])
        players.update(steamid,'teamchange_time',player.attributes['timeconnected'])
示例#19
0
def _punishment_slay(userid, adminid, args, force):
    if str(xa_adminslay_anonymous) == '0' and not force:
        tokens = {}
        tokens['admin']   = es.getplayername(adminid)
        tokens['user']    = es.getplayername(userid)
        for user in playerlib.getPlayerList():
            es.tell(int(userid), xalanguage("admin slay", tokens, user.get("lang")))
    player = playerlib.getPlayer(userid)
    player.kill()
示例#20
0
def round_end(eventVar):
    if int(slay):
        if eventVar["winner"] == "2" and es.getlivingplayercount(3):
            xaobjectives.logging.log("Counter-Terrorists slayed for failing to meet their objectives")
            cts, ts = getPlayerList("#ct"), getPlayerList("#t")
            for i in cts:
                i.kill()
                es.tell(int(i), "#multi", text("lost"))
            for i in ts:
                es.tell(int(i), "#multi", text("won"))
        elif eventVar["winner"] == "3" and es.getlivingplayercount(2):
            xaobjectives.logging.log("Terrorists slayed for failing to meet their objectives")
            ts, cts = getPlayerList("#t"), getPlayerList("#ct")
            for i in ts:
                i.kill()
                es.tell(int(i), "#multi", text("lost"))
            for i in cts:
                es.tell(int(i), "#multi", text("won"))
示例#21
0
def round_start(event_var):
    """Initializes dictionary with the number of grenades each player starts the round with."""
    global dict_players

    dict_players.clear()
    for player in playerlib.getPlayerList('#all'):
        dict_current_player = dict_players[int(player)] = {}
        for str_grenade in dict_grenade_names:
            dict_current_player[dict_grenade_names[str_grenade]] = player.get(str_grenade)
def _gimp(userid, adminid, args): 
    gimped = players[userid]['gimped'] 
    players[userid]['gimped'] = (1 if not gimped else 0) 
    if str(xa_admingimp_anonymous) == "0": 
        tokens = {} 
        tokens['admin'] = es.getplayername(adminid) 
        tokens['user']  = es.getplayername(userid) 
        for player in playerlib.getPlayerList(): 
            tokens['state'] = xalanguage("gimped", lang=player.get("lang")) if not gimped else xalanguage("ungimped", lang=player.get("lang")) 
            es.tell(int(player), xalanguage("admin state", tokens, player.get("lang"))) 
示例#23
0
def play_admin_say_sound(userid=None):
  '''
  Used to play the admin message sound for everyone to hear.
  '''
  if str(say_admin_soundfile):
    if userid:
      es.playsound(userid, str(say_admin_soundfile), 1)
    else:
      for p in playerlib.getPlayerList():
        es.playsound(int(p), str(say_admin_soundfile), 1)
def _drug(userid, adminid, args): 
    drugged = players[userid]['drugged'] 
    players[userid]['drugged'] = (1 if not drugged else 0) 
    if str(xa_admindrug_anonymous) == "0": 
        tokens = {} 
        tokens['admin'] = es.getplayername(adminid) 
        tokens['user']  = es.getplayername(userid) 
        for player in playerlib.getPlayerList(): 
            tokens['state'] = xalanguage("drugged", lang=player.get("lang")) if not drugged else xalanguage("undrugged", lang=player.get("lang")) 
            es.tell(int(player), xalanguage("admin state", tokens, player.get("lang"))) 
        es.setplayerprop(userid, 'CBasePlayer.m_iDefaultFOV', 165 if not drugged else 90) 
示例#25
0
def _admin_say_center(userid, message, teamonly): 
    tokens = {} 
    tokens['username'] = es.getplayername(userid) 
    tokens['message']  = message 
    if not teamonly: 
        for player in filter(lambda x: not es.getplayersteamid(x) == "BOT", es.getUseridList()): 
            es.centertell(player, xalanguage('center message', tokens, playerlib.getPlayer(player).get("lang"))) 
    else: 
        for player in playerlib.getPlayerList('#admin_say'): 
            es.centertell(int(player), xalanguage('admin only center message', tokens, player.get("lang"))) 
    return (0,'',0)
示例#26
0
def mapmenu_handler(userid,choice,popupname):
    if gActions[userid] == 'changemap':
        xamapmanagement.logging.log("changed map to %s" % choice, userid, True )
        es.server.queuecmd('changelevel '+choice)
    elif gActions[userid] == 'setnextmap':
        nextmapvar.set(choice)
        if str(xa_announce_setnextmap) == '1':
            for player in playerlib.getPlayerList():
                es.tell(player.userid, xalanguage('new next map', {'mapname':choice}, player.get('lang')))
        xamapmanagement.logging.log("set next map set to %s" % choice, userid, True )
    del gActions[userid]
示例#27
0
    def set_all_players_godmode(self, value):
        """Sets all players GodMode to the given value"""

        # Store the value to be used on player_spawn
        self.godmode = value

        # Loop through all living players
        for player in getPlayerList("#alive"):

            # Give the player GodMode
            player.godmode = value
示例#28
0
def _playerlist(userid):
    es.dbgmsg(1, '*****_playerlist')
    global playermenu
    #uncomment following line, #all is for testing only
    players = playerlib.getPlayerList('#human')
    #players = playerlib.getPlayerList('#all')
    playermenu = popuplib.easymenu('playermenu', None, _manage_player)
    for player in players:
        name = player.get('name')
        playermenu.addoption(name, utfcode(name))
    playermenu.settitle(lang['current players'])
    playermenu.send(userid)
示例#29
0
def set_nextmap():
    mapname = es.getargv(1)
    if map_check(mapname):
        nextmapvar.set(mapname)
        if str(xa_announce_setnextmap) == '1':
            for player in playerlib.getPlayerList():
                es.tell(player.userid, xalanguage('new next map', {'mapname':mapname}, player.get('lang')))
        xamapmanagement.logging.log("set next map set to %s" % mapname, es.getcmduserid(), True )
    else:
        userid = int(es.getcmduserid())
        if userid:
            es.tell(userid,'#multi','#green[XA] #default',xalanguage('invalid map',{'mapname':mapname},playerlib.getPlayer(userid).get('lang')))
示例#30
0
def _playerlist(userid):
    es.dbgmsg(1,'*****_playerlist')
    global playermenu
    #uncomment following line, #all is for testing only	
    players = playerlib.getPlayerList('#human')
    #players = playerlib.getPlayerList('#all')
    playermenu = popuplib.easymenu('playermenu',None,_manage_player)
    for player in players:
        name = player.get('name')
        playermenu.addoption(name,utfcode(name))
    playermenu.settitle(lang['current players'])
    playermenu.send(userid)
示例#31
0
def rtv():
    """ Executed when a user types 'rtv' in chat """
    global votes_in
    global vote_req_total
     
    userid  = es.getcmduserid() 
    steamid = es.getplayersteamid(userid) 
    entry(steamid) 
    if not players[steamid][0]:
        
        if (time.time() - map_start_time) < float(vote_req_time):
            tokens = {}
            tokens['time'] = int(float(vote_req_time) - int( time.time() - map_start_time ) ) 
            es.tell(userid, '#multi', lang('map_time', tokens, playerlib.getPlayer(userid).get('lang') ) )
            xartv.logging.log("has been denied the right to RTV as not enough time in the map has passed", userid ) 
        else: 
            if allowVoting:
                players[steamid][0] = True
                vote_req_total = int( round(vote_req_p / 100. * len(playerlib.getPlayerList("#human") ) ) )
                if not votes_in: 
                    name = es.getplayername(userid) 
                    for user in es.getUseridList(): 
                        tokens = {}
                        tokens['player'] = es.getplayername(user)
                        es.tell(user, '#multi', lang('player_started', tokens, playerlib.getPlayer(user).get('lang') ) ) 
                        popuplib.unsend("nomination_menu", user)
                votes_in += 1
                xartv.logging.log("has rocked the vote, %s votes in" % votes_in, userid )
                
                if votes_in >= int(vote_req_min): 
                    if votes_in >= vote_req_total:
                        xartv.logging.log("Rock the vote has passed, starting the vote") 
                        rtv_init() 
                    else: 
                        name   = es.getplayername(userid)
                        tokens = {}
                        tokens['player'] = name
                        tokens['votes']  = vote_req_total - votes_in
                        xartv.logging.log("%s votes still needed to rock the vote" % (vote_req_total - votes_in) ) 
                        for user in es.getUseridList():
                            es.tell(user, '#multi', lang('req', tokens ,playerlib.getPlayer(user).get('lang') ) ) 
                else: 
                    name   = es.getplayername(userid)
                    tokens = {}
                    tokens['player'] = name
                    tokens['votes']  = int(vote_req_min) - votes_in
                    for user in es.getUseridList(): 
                        es.tell(user, '#multi', lang('req', tokens, playerlib.getPlayer(user).get('lang') ) ) 
            else: 
                es.tell(userid, '#multi', lang('started', lang=playerlib.getPlayer(userid).get('lang') ) ) 
    else:
        xartv.logging.log("has attempted to RTV more than once", userid) 
        es.tell(userid, '#multi', lang('1vote', lang=playerlib.getPlayer(userid).get('lang') ) ) 
示例#32
0
def giveObject(adminid, userid):
    command = admins[adminid]['command']
    if command.startswith(('health_', 'cash_')):
        prop   = 'CBasePlayer.m_iHealth' if command.startswith('health_') else 'CCSPlayer.m_iAccount'
        amount = int(command.replace('health_', '').replace('cash_', ''))
        currentAmount  = es.getplayerprop(userid, prop)
        es.setplayerprop(userid, prop, currentAmount + amount)
        # issue #70 :: value formatting error
        strInt = str(amount)
        thousands = []
        while strInt:
            thousands.append(strInt[-3:])
            strInt = strInt[:-3]
        formattedAmount = ",".join(reversed(thousands))
        tokens = {}
        tokens['admin'] = es.getplayername(adminid)
        tokens['user']  = es.getplayername(userid)
        tokens['item']  =  '#green%s #lightgreen%s' % (formattedAmount, 'cash' if command.startswith('cash_') else 'health')
        for tellplayer in playerlib.getPlayerList('#human'):
            es.tell(int(tellplayer), '#multi', xalanguage('admin give', tokens, tellplayer.get("lang")))
        xaadmingive.logging.log("has given player %s %s" % (tokens['user'], tokens['item']), adminid, True) 
    else:
        weaponName = _remove_prefix(command)
        fullName   = _prepend_prefix(command)
        if int(admingive_stripfirst) == 1:
            if fullName in weaponlib.getWeaponNameList('#secondary'):
                weapon = playerlib.getPlayer(userid).get('secondary')
            else:
                weapon = playerlib.getPlayer(userid).get('primary')
            if weapon:
                _remove_weapon(userid, weapon)
        es.delayed(0.1, 'es_xgive %s %s' % (userid, fullName))
        if str(admingive_anonymous) == '0':
            tokens = {}
            tokens['admin'] = es.getplayername(adminid)
            tokens['user']  = es.getplayername(userid)
            for tellplayer in playerlib.getPlayerList('#human'):
                tokens['item'] = '#greena #lightgreen%s' % weaponName
                es.tell(int(tellplayer), '#multi', xalanguage('admin give', tokens, tellplayer.get("lang")))
        xaadmingive.logging.log("has given player %s %s" % (tokens['user'], tokens['item']), adminid, True)            
示例#33
0
def foreach_player(variable, identifier, command):
    if '#' in identifier:
        identifier = identifier.replace('#', ',#')[1:]
        for userid in playerlib.getUseridList(identifier):
            variable.set(int(userid))
            es.server.cmd(command)
    elif identifier:
        for player in playerlib.getPlayerList('#all'):
            if identifier.lower() in player.attributes['name'].lower() or identifier == player.attributes['steamid'] or identifier == str(player):
                variable.set(int(player))
                es.server.cmd(command)
    else:
        es.dbgmsg(0, 'foreach player: The identifier "%s" does not exists' % identifier)