Esempio n. 1
0
def changerace_handler(userid, choice, popupname):
    if es.exists("key", "wcsraces", choice):
        ##If race is not restricted
        if int(es.keygetvalue("wcsuserdata", userid, "total_level")) < int(
                es.keygetvalue("wcsraces", choice, "required_level")):
            levelsneeded = str(
                int(es.keygetvalue("wcsraces", choice, "required_level")) -
                int(es.keygetvalue("wcsuserdata", userid, "total_level")))
            es.tell(
                userid, "#multi",
                "#lightgreenYou cannot choose this race because you are too low level, #green"
                + levelsneeded + "#lightgreen levels needed.")
        elif es.keygetvalue("wcsraces", choice, "allow_only") == "0":
            changerace_successful(userid, choice)
        elif es.keygetvalue("wcsraces", choice, "allow_only") == "<admins>":
            if not es.exists("key", "wcsadmin", es.getplayersteamid(userid)):
                es.tell(
                    userid, "#multi",
                    "#lightgreenSorry you can't pick this race because it is a#green Admin Only Race"
                )
            else:
                changerace_successful(userid, choice)
        elif es.keygetvalue("wcsraces", choice, "allow_only") != "0":
            users = es.keygetvalue("wcsraces", choice, "allow_only").split("|")
            if es.getplayersteamid(userid) not in users:
                es.tell(
                    userid, "#multi",
                    "#lightgreenSorry you can't pick this race because it is a#green Private Race"
                )
            else:
                changerace_successful(userid, choice)
Esempio n. 2
0
def showmenu(userid, args):
    userid = str(userid)
    steamid = es.getplayersteamid(userid)
    if steamid == 'BOT':
        return
    steamid = es.getplayersteamid(userid)
    global menuname
    menuname = "showmenu" + "_" + userid
    menuname = popuplib.easymenu(menuname, 'choice', showmenu_selection)
    showmenu_popup = langlib.Strings(
        es.getAddonPath("superhero") + "/languages/showmenu_popup.ini")
    global popup_language
    menuname.settitle(
        showmenu_popup('showmenu_title', lang=str(popup_language)))
    pid, plevel, punspent, pheroes, ppower1, ppower2, ppower3 = cursor.execute(
        'SELECT id, level, unspent, heroes, power1, power2, power3 FROM users WHERE id=?',
        (steamid, )).fetchone()
    tokens = {}
    tokens['unspent'] = punspent
    menuname.setdescription(
        showmenu_popup('showmenu_desc', tokens, lang=str(popup_language)))
    herolist = str(es.ServerVar('herolist')).split(',')
    for hero in herolist:
        userheroes = pheroes.split(',')
        if not hero in userheroes:
            text = langlib.Strings(
                es.getAddonPath("superhero/heroes/" + hero + "/strings.ini"))
            if int(text("req_level")) <= int(plevel):
                string = str(text("heroname")) + '    -   ' + str(
                    text("description", lang=str(popup_language)))
                menuname.addoption(hero, string)
    menuname = "showmenu" + "_" + userid
    #close_popups(userid)
    popuplib.send(menuname, userid)
def player_death(ev):
    userid = ev['userid']
    steamid = es.getplayersteamid(userid)
    if steamid == 'BOT': steamid = es.getplayername(userid)
    attacker = ev['attacker']
    weapon = ev['weapon']
    if weapon != 'world':
        if weapon != 'worldspawn':
            if userid != attacker:
                if ev['es_userteam'] != ev['es_attackerteam']: 
                    # Normal Player kill
                    xp_kill_min = es.ServerVar('xp_kill_min')
                    xp_kill_max = es.ServerVar('xp_kill_max')
                    xp = random.randint(xp_kill_min,xp_kill_max)
                    if attacker != '0':
                        if userid != '0':
                            pid, plevel = cursor.execute('SELECT id, level FROM users WHERE id=?', (steamid,)).fetchone()
                            if es.getplayersteamid(attacker) == 'BOT':
                                aid = getID(attacker)
                                alevel = '1'
                            else:
                                aid, alevel = cursor.execute('SELECT id, level FROM users WHERE id=?', (getID(attacker),)).fetchone()
                            level_dif = int(plevel) - int(alevel)
                            if alevel < 1:
                                xp = xp * float(es.ServerVar('xp_multi'))
                            if level_dif > 1:
                                xp = xp * level_dif * level_dif
                            elif level_dif == 1:
                                xp = xp * 2
                            if steamid == 'BOT':
                                return
                            xp_msg = langlib.Strings(es.getAddonPath('superhero') + '/languages/xp_msg.ini')
                            global popup_language
                            sh_givexp(attacker,xp,xp_msg('xp_kill',lang=str(popup_language)))
def showmenu(userid, args):
    userid = str(userid)
    steamid = es.getplayersteamid(userid)
    if steamid == 'BOT':
        return
    steamid = es.getplayersteamid(userid)
    global menuname
    menuname = "showmenu"+"_"+userid
    menuname = popuplib.easymenu(menuname, 'choice', showmenu_selection)
    showmenu_popup = langlib.Strings(es.getAddonPath("superhero") + "/languages/showmenu_popup.ini")
    global popup_language
    menuname.settitle(showmenu_popup('showmenu_title',lang=str(popup_language)))
    pid, plevel, punspent, pheroes, ppower1, ppower2, ppower3 = cursor.execute('SELECT id, level, unspent, heroes, power1, power2, power3 FROM users WHERE id=?', (steamid,)).fetchone()
    tokens = {}
    tokens['unspent'] = punspent
    menuname.setdescription(showmenu_popup('showmenu_desc',tokens,lang=str(popup_language)))
    herolist = str(es.ServerVar('herolist')).split(',')
    for hero in herolist:
        userheroes = pheroes.split(',')
        if not hero in userheroes:
            text = langlib.Strings(es.getAddonPath("superhero/heroes/"+hero+ "/strings.ini"))
            if int(text("req_level")) <= int(plevel):
                string = str(text("heroname"))+'    -   '+str(text("description",lang=str(popup_language)))
                menuname.addoption(hero,string)
    menuname = "showmenu"+"_"+userid
    #close_popups(userid)
    popuplib.send(menuname,userid)
Esempio n. 5
0
def changerace_successful(userid, race):
    if es.getplayerprop(userid, "CCSPlayer.baseclass.pl.deadflag") == 0:
        es.server.queuecmd("es wcs_dealdamage %s %s 9999" % (userid, userid))
    es.server.queuecmd("es wcs_saveplayer %s" % userid)
    player_race = es.keygetvalue("wcsuserdata", userid, "race")
    command_buffer = es.keygetvalue("wcsraces", player_race, "onchange")
    es.server.queuecmd("es_xset wcs_userid %s" % userid)
    es.server.queuecmd(command_buffer)
    es.server.queuecmd("es_keysetvalue \"wcsuserdata\" %s \"race\" %s" %
                       (userid, race))
    es.server.queuecmd("es wcs_keysetvalue  \"%s\" \"race\" %s" %
                       (es.getplayersteamid(userid), race))
    es.server.queuecmd("es_xset wcs_id \"%s\"" % es.getplayersteamid(userid))
    es.server.queuecmd("es_xdoblock wcs/wcsfunctions/wcs_playercheck")
    es.server.queuecmd("es wcs_getplayer %s" % userid)
    es.server.queuecmd(
        "es_keysetvalue \"wcsuserdata\" %s \"skillcheck\" \"1\"" % userid)
    es.tell(
        userid, "#multi", "#lightgreenYou changed your race to#green " +
        es.keygetvalue("wcsraces", race, "name"))
    old_name = es.keygetvalue("wcsraces", player_race, "name")
    new_name = es.keygetvalue("wcsraces", race, "name")
    es.event('initialize', "wcs_changerace")
    es.event('setint', "wcs_changerace", "userid", int(userid))
    es.event('setstring', "wcs_changerace", "oldrace", str(old_name))
    es.event('setstring', "wcs_changerace", "newrace", str(new_namead))
    es.event('fire', "wcs_changerace")
Esempio n. 6
0
def banReasonList():
  global badAccess
  # Get the userid of the person calling this menu
  playerid = es.getcmduserid()
  
  if es.exists('keygroup', 'playerlist'):
    es.server.queuecmd('es_xkeygroupdelete playerlist')
  es.server.queuecmd('es_xcreateplayerlist playerlist')
  
  # Member check only needs to be performed on this menu
  if isMember(es.getplayersteamid(playerid)):
    if es.exists('keygroup', 'GlobalBan_Reason'):
      # Open the keygroup that contains all reason codes
      es.keygroupdelete('GlobalBan_Reason')
    es.keygroupload('GlobalBan_Reason', '|GlobalBan')

    # Create keymenu called banReasonMenu for user to select from
    banReasonMenu = keymenulib.create("banReasonMenu", "selectedBanReason", banLengthList, "GlobalBan_Reason", "#keyvalue reasonText", "#key", "Ban Reason List")
    banReasonMenu.send(playerid)
  else:
    es.tell(playerid, '#green', 'You are not an admin!')
    # Increment the number of attempts
    badAccess[es.getplayersteamid(playerid)] = int(badAccess[es.getplayersteamid(playerid)]) + 1
    if int(badAccess[es.getplayersteamid(playerid)]) > 4:
      # Remove the player from the badAccess dictionary
      if badAccess.has_key(event_var['es_steamid']):
        del badAccess[es.getplayersteamid(playerid)]
      # Kick the player
      es.server.queuecmd('kickid ' + str(playerid) + ' You were kicked for attempting to use an admin command');
Esempio n. 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)
Esempio n. 8
0
def dod_round_win(ev):
    wt,lt = 'ct','t'
    dbg( 'round won')
    if ev['team'] == '2':
        wt,lt = lt,wt
    for userid in playerlib.getUseridList('#human,#%s' % wt):
        players.increment(es.getplayersteamid(userid),'win')
    for userid in playerlib.getUseridList('#human,#%s' % lt):
        players.increment(es.getplayersteamid(userid),'lose')
    dcfg.sync()
    updateTimes()
    db.commit()
Esempio n. 9
0
def round_end(ev):
    dbg( 'round end')
    wt,lt = 'ct','t'
    if ev['winner'] == '2':
        wt,lt = lt,wt
    for userid in playerlib.getUseridList('#human,#%s' % wt):
        players.increment(es.getplayersteamid(userid),'win')
    for userid in playerlib.getUseridList('#human,#%s' % lt):
        players.increment(es.getplayersteamid(userid),'lose')
    dcfg.sync()
    updateTimes()
    db.commit()
Esempio n. 10
0
def xarates_cmd():
    int_userid = es.getcmduserid()
    xarates.logging.log(
        'xarates request by %s (%s)' %
        (es.getplayersteamid(int_userid), es.getplayername(int_userid)))
    dict_rates = {}
    longest_name = 4
    longest_rate = 4
    longest_cmdrate = 8
    longest_updaterate = 11
    longest_interp = 6
    for instance_player in playerlib.getPlayerList("#all"):
        int_player = int(instance_player)
        if es.getplayersteamid(int_player) != "BOT":
            str_name = es.getplayername(int_player)
            if len(str_name) > longest_name:
                longest_name = len(str_name)
            dict_rates[int_player] = {}
            str_rate = es.getclientvar(int_player, "rate")
            dict_rates[int_player]["rate"] = str_rate
            if len(str_rate) > longest_rate:
                longest_rate = len(str_rate)
            str_cmdrate = es.getclientvar(int_player, "cl_cmdrate")
            dict_rates[int_player]["cmdrate"] = str_cmdrate
            if len(str_cmdrate) > longest_cmdrate:
                longest_cmdrate = len(str_cmdrate)
            str_updaterate = es.getclientvar(int_player, "cl_updaterate")
            dict_rates[int_player]["updaterate"] = str_updaterate
            if len(str_updaterate) > longest_updaterate:
                longest_updaterate = len(str_updaterate)
            str_interp = es.getclientvar(int_player, "cl_interp")
            dict_rates[int_player]["interp"] = str_interp
            if len(str_interp) > longest_interp:
                longest_interp = len(str_interp)
    total_len = longest_name + longest_rate + longest_cmdrate + longest_updaterate + longest_interp + 12
    usermsg.echo(int_userid, "|%s|" % ("-" * total_len))
    usermsg.echo(
        int_userid, "|%-*s   %-*s   %-*s   %-*s   %-*s|" %
        (longest_name, "Name", longest_rate, "Rate", longest_cmdrate,
         "CMD Rate", longest_updaterate, "Update Rate", longest_interp,
         "Interp"))
    usermsg.echo(int_userid, "|%s|" % ("-" * total_len))
    for int_player in dict_rates:
        usermsg.echo(
            int_userid, "|%-*s   %-*s   %-*s   %-*s   %-*s|" %
            (longest_name, es.getplayername(int_player), longest_rate,
             dict_rates[int_player]["rate"], longest_cmdrate,
             dict_rates[int_player]["cmdrate"], longest_updaterate,
             dict_rates[int_player]["updaterate"], longest_interp,
             dict_rates[int_player]["interp"]))
    usermsg.echo(int_userid, "|%s|" % ("-" * total_len))
Esempio n. 11
0
def log(module, text, userid=None, admin=False, loglvl=0):
    """
        XA logging
        
        module:         module name (usually automatically provided)
        test:           text string to log
        userid:         optionally provide a userid as reference
        admin:          set to true if this is an admin action
        loglvl:         an optional level - messages with lower xa_log values will not be recorded
        
        Appends a line to the module's log file (found in the xa/logs directory).
        
        Includes ability to reference a specific player and also flag as an admin action
    """
    # Is logging enabled and does our module exist?
    if int(es.ServerVar('xa_log')) and int(
            es.ServerVar('xa_log')) >= loglvl and xa.exists(module):
        # Was a valid source userid specified?
        if userid and es.exists('userid', int(userid)):
            # Is this userid an admin?
            if admin:
                # Adming log
                logtext = '%s: Admin %s [%s]: %s' % (
                    module, es.getplayername(userid),
                    es.getplayersteamid(userid), text)

            else:
                # User log
                logtext = '%s: User %s [%s]: %s' % (
                    module, es.getplayername(userid),
                    es.getplayersteamid(userid), text)

        else:
            # Default log
            logtext = '%s: %s' % (module, text)

        # Create our log folder if it does not exist
        if not os.path.isdir('%s/logs' % xa.coredir()):
            os.mkdir('%s/logs' % xa.coredir())

        # Write to our log file
        logname = '%s/logs/l%s' % (xa.coredir(), time.strftime('%m%d000.log'))
        logfile = open(logname, 'a+')
        logfile.write(
            time.strftime('L %m/%d/%Y - %H:%M:%S: ') + logtext + '\n')
        logfile.close()

        # Write to the SRCDS log file
        es.log(logtext)
Esempio n. 12
0
def rank_menu_cmd(userid, args):
    # Make sure player exists
    if not es.exists('userid', userid) and userid != 0:
        return

    # Get the winners list with a limit of 0 (unlimited)
    currentWinners = get_winners_list(0)
    rankings = []
    rank = 0

    # Empty database ?
    if currentWinners == []:
        rankings = ['Nobody has won yet!']

    # 1 Winner ?
    elif isinstance(currentWinners, dict):
        # Check to see if the player requesting the menu is the player being
        # listed
        if currentWinners["uniqueid"] == es.getplayersteamid(userid):
            rank = 1

        # Add the player
        rankings.append('[%s] %s' %
                        (currentWinners['wins'], currentWinners['name']))

    # Update popup list
    else:
        count = 0

        for player in currentWinners:
            count += 1

            # Check to see if the player requesting the menu is the player
            # being listed
            if player["uniqueid"] == es.getplayersteamid(userid):
                rank = count

            # Add the player
            rankings.append('[%s] %s' % (player['wins'], player['name']))

    # Create a new OrderedMenu
    ggRankMenu = OrderedMenu(userid,
                             'GunGame: Rank Menu',
                             rankings,
                             highlightIndex=rank)

    # Send the OrderedMenu on the page the player is on
    ggRankMenu.send_page(get_index_page(rank))
Esempio n. 13
0
 def clientAddXp(self, userid, args=None):
     """
     This method is a client command callback when an admin runs the command
     rpgaddxp <steamid> <amount>. This will be generally called from the
     custom menu with the escape input box. Execute the addition of the experience
     
     @PARAM userid - the admin's id who executed the command
     @PARAM args - any additional arguments after the command
     """
     if args is None:
         args = userid
         userid = None
     if len(args) != 2:
         if len(args) == 6:
             args = ("".join(args[:5]), args[5])
         else:
             es.dbgmsg(0, "rpgaddxp <steamid> <amount>")
             return
     steamid, amount = args
     if not str(amount).isdigit():
         es.dbgmsg(0, "rpgaddxp <steamid> <amount>")
         return
     if not steamid.lower().startswith("steam"):
         userid = es.getuserid(steamid)
         if userid is None:
             return
         steamid = es.getplayersteamid(userid)
     amount = int(amount)
     popup.addXp(userid, amount, "sourcerpg_addxp_player%s" % steamid)
def unload():
    for userid in es.getUseridList(): 
        if players.has_key(userid):
            gamethread.cancelDelayed('beacon_%s'%userid) 
            gamethread.cancelDelayed('timebomb_%s'%userid) 
            gamethread.cancelDelayed('freezebomb_%s'%userid) 
            gamethread.cancelDelayed('firebomb_%s'%userid)
            gamethread.cancelDelayed('unmute_%s'%es.getplayersteamid(userid))
            es.setplayerprop(userid, "CBaseEntity.movetype", 2)
            es.setplayerprop(userid, 'CBasePlayer.m_iDefaultFOV', 90)
    gamethread.cancelDelayed('remove_fire')
    gamethread.cancelDelayed('blind_loop')
    es.addons.unregisterSayFilter(_say_filter)
    # xaextendedpunishments.xapunishments.unregisterPunishment("punishment") 
    xaextendedpunishments.xapunishments.unregisterPunishment("blind") 
    xaextendedpunishments.xapunishments.unregisterPunishment("freeze") 
    xaextendedpunishments.xapunishments.unregisterPunishment("gimp") 
    xaextendedpunishments.xapunishments.unregisterPunishment("drug") 
    xaextendedpunishments.xapunishments.unregisterPunishment("beacon") 
    xaextendedpunishments.xapunishments.unregisterPunishment("noclip") 
    xaextendedpunishments.xapunishments.unregisterPunishment("freezebomb") 
    xaextendedpunishments.xapunishments.unregisterPunishment("timebomb") 
    xaextendedpunishments.xapunishments.unregisterPunishment("firebomb")
    
    if int(xa_adminmute_on):
        xaextendedpunishments.xapunishments.unregisterPunishment("mute")
        
    xaextendedpunishments.delRequirement('xapunishments')
    xaextendedpunishments.unregister()
Esempio n. 15
0
 def mute(self, userid, adminid, args=None):
     userid = int(userid)
     steamid = es.getplayersteamid(userid)
     if userid in self.muted:
         self.muted.remove(userid)
         self.steamids.remove(steamid)
         status = 'unmuted'
         if not bool(self.muted):
             es.addons.unregisterTickListener(self._tickListener)
             self.tickStatus = self.UNREGISTERED
     else:
         if not bool(self.muted):
             es.addons.registerTickListener(self._tickListener)
             self.tickStatus = self.REGISTERED
         self.steamids.add(steamid)
         self.muted.add(userid)
         status = 'muted'
     if str(xa_adminmute_anonymous) == '0':
         tokens = {}
         tokens['admin'] = es.getplayername(adminid)
         tokens['user'] = es.getplayername(userid)
         for player in playerlib.getPlayerList('#human'):
             tokens['state'] = xalanguage(status, lang=player.get("lang"))
             es.tell(int(player), '#multi',
                     xalanguage('admin state', tokens, player.get("lang")))
Esempio n. 16
0
def load():
    global mute
    mute = MuteManager()
    xaextendedpunishments.addRequirement('xapunishments')
    # xaextendedpunishments.xapunishments.registerPunishment("punishment", xalanguage["punishment"], _callback_function)
    xaextendedpunishments.xapunishments.registerPunishment(
        "blind", xalanguage["blind"], _blind, 1)
    xaextendedpunishments.xapunishments.registerPunishment(
        "freeze", xalanguage["freeze"], _freeze, 1)
    xaextendedpunishments.xapunishments.registerPunishment(
        "gimp", xalanguage["gimp"], _gimp, 1)
    xaextendedpunishments.xapunishments.registerPunishment(
        "drug", xalanguage["drug"], _drug, 1)
    xaextendedpunishments.xapunishments.registerPunishment(
        "beacon", xalanguage["beacon"], _beacon, 1)
    xaextendedpunishments.xapunishments.registerPunishment(
        "noclip", xalanguage["noclip"], _noclip, 1)
    xaextendedpunishments.xapunishments.registerPunishment(
        "freezebomb", xalanguage["freezebomb"], _freeze_bomb, 1)
    xaextendedpunishments.xapunishments.registerPunishment(
        "timebomb", xalanguage["timebomb"], _time_bomb, 1)
    xaextendedpunishments.xapunishments.registerPunishment(
        "firebomb", xalanguage["firebomb"], _fire_bomb, 1)
    xaextendedpunishments.xapunishments.registerPunishment(
        "rocket", xalanguage["rocket"], _rocket, 1)
    xaextendedpunishments.xapunishments.registerPunishment(
        "mute", xalanguage["mute"], mute.mute, 1, True)
    gamethread.delayedname(1, 'blind_loop', _blind_loop)
    """ Make sure if XA is loaded late, add all players """
    for player in es.getUseridList():
        player_activate({
            'userid': player,
            'es_steamid': es.getplayersteamid(player)
        })
Esempio n. 17
0
def es_map_start(ev):
    userid = ev['userid']
    steamid = es.getplayersteamid(userid)
    if not steamid in client:
        client[steamid] = {'radio':0}
    else:
        client[steamid]['radio'] = 0
Esempio n. 18
0
def player_activate(ev):
    userid = ev['userid']
    steamid = es.getplayersteamid(userid)
    if not steamid in client:
        client[steamid] = {'radio':0}
    else:
        client[steamid]['radio'] = 0
Esempio n. 19
0
def trikz_menu(userid, text=None, steamid=None, name=None):
    QueueAPI.Validate(userid, 0)
    steamid = es.getplayersteamid(userid)
    info = popuplib.create('trikz_menu')
    info.addline('[ DreamAboutNow ]')
    info.addline(' ')
    if client[steamid]["auto_switch"] == "On":
        info.addline('->1. Auto Switch: On')
    else:
        info.addline('->1. Auto Switch: Off')

    if client[steamid]["auto_jump"] == "On":
        info.addline('->2. Auto Jump: On')
    else:
        info.addline('->2. Auto Jump: Off')
    if client[steamid]["auto_stuck"] == "On":
        info.addline('->3. Anti Stuck: On')
    else:
        info.addline('->3. Anti Stuck: Off')

    if client[steamid]["player_state"] == "Ghost":

        info.addline('->4. Blocking: Off')
    else:
        info.addline('->4. Blocking: On')
    info.addline(' ')
    info.addline('->5. Checkpoints')
    info.addline(' ')
    info.addline('0. Exit')
    info.enablekeys = "12345680"
    info.unsend(userid)
    info.send(userid)
    info.delete()
    info.menuselect = trikz_menu_select
Esempio n. 20
0
def cp_menu(userid):
    steamid = es.getplayersteamid(userid)
    timer = es.import_addon("queue_timer/plugins/timer")
    QueueAPI.Validate(userid, 0)
    info = popuplib.create('checkpoint_menu')
    info.addline('Checkpoints')
    info.addline(' ')
    info.addline('->1. Save CP 1')
    info.addline('->2. Teleport to CP 1 ')
    info.addline(' ')
    info.addline('->3. Save CP 2')
    info.addline('->4. Teleport to CP 2')
    info.addline(' ')
    if client[steamid]["stop_speed"] == "On":
        info.addline('->5. Save speed: On')
    else:
        info.addline('->5. Save speed: Off')
    if client[steamid]["save_angles"] == "On":
        info.addline('->6. Save angles: On')
    else:
        info.addline('->6. Save angles: Off')
    info.addline(' ')
    if timer.CheckPartner(userid):
        info.addline('Disabled during timer!')
        info.addline(' ')
    info.addline('->8. Back')
    info.addline('0 Exit')
    info.enablekeys = "12345608"
    info.unsend(userid)
    info.send(userid)
    info.delete()
    info.menuselect = cp_menu_select
Esempio n. 21
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)
Esempio n. 22
0
def antispam():
    for userid in es.getUseridList():
        steamid = es.getplayersteamid(userid)
        if steamid not in client:
            QueueAPI.Validate(userid, 0)
        client[steamid]["spam"] = 0
    gamethread.delayedname(30, "spam", antispam)
Esempio n. 23
0
def load():
    esc.msg('#255,0,0Radio load')
    for userid in es.getUseridList():
        steamid = es.getplayersteamid(userid)
        if not steamid in client:
            client[steamid] = {'radio': 0}
    jukebox_loop()
Esempio n. 24
0
 def clientAddXp(self, userid, args=None):
     """
     This method is a client command callback when an admin runs the command
     rpgaddxp <steamid> <amount>. This will be generally called from the
     custom menu with the escape input box. Execute the addition of the experience
     
     @PARAM userid - the admin's id who executed the command
     @PARAM args - any additional arguments after the command
     """
     if args is None:
         args = userid
         userid = None
     if len(args) != 2:
         if len(args) == 6:
             args = ("".join(args[:5]), args[5])
         else:
             es.dbgmsg(0, "rpgaddxp <steamid> <amount>")
             return
     steamid, amount = args
     if not str(amount).isdigit():
         es.dbgmsg(0, "rpgaddxp <steamid> <amount>")
         return
     if not steamid.lower().startswith("steam"):
         userid = es.getuserid(steamid)
         if userid is None:
             return
         steamid = es.getplayersteamid(userid)
     amount = int(amount)
     popup.addXp(userid, amount, "sourcerpg_addxp_player%s" % steamid)
Esempio n. 25
0
def cmd_myweaponstats(userid,args):
    steamid = es.getplayersteamid(userid)
    pplchck('xs_ws_my%s' % userid)
    weapons.execute("SELECT weapon FROM xs_weapons WHERE weapon!='world'")
    weaponnames = weapons.fetchall()
    # fetch top killer weapon
    kills = map(lambda x: (players.query(steamid,'kill_%s' % x),x),weaponnames) # get the kills and form a list of tuples: (kills,weaponname)
    kills.sort(reverse=True) # sort the list, reverse=True because we want the MOST kills
    killeramount,killername = kills[0] # get the first entry of the list
    # fetch top death weapon
    deaths = map(lambda x: (players.query(steamid,'death_%s' % x),x),weaponnames) # get the deaths and form a list of tuples: (deaths,weaponname)
    deaths.sort(reverse=True) # sort the list, reverse=True because we want the MOST deaths
    deathamount,deathname = deaths[0] # get the first entry of the list
    # fetch top damage weapon
    damage = map(lambda x: (players.query(steamid,'damage_%s' % x),x),weaponnames) # get the damage dealt and form a list of tuples: (damage,weaponname)
    damage.sort(reverse=True) # again reverse for most damage dealt
    damageamount,damagename = damage[0]
    if EE: # if EE is available, also check for most bought
        bought = map(lambda x: (players.query(steamid,'bought_%s' % x),x),weaponnames)
        bought.sort(reverse=True)
        boughtamount,boughtname = bought[0]
    p = popuplib.easymenu('xs_ws_my%s' % userid,'_popup_choice',myweaponchoice)
    p.settitle('eXtended Stats - Your Weaponstats')
    p.addoption(killername,'Your most lethal weapon: %s with %s kills' % (killername,killeramount))
    p.addoption(damagename,'Your most damaging weapon: %s with %.1f damage done' % (damagename,damageamount))
    p.addoption(deathname,'Your most feared weapon: %s, killed you %s times' % (deathname,deathamount))
    if EE:
        p.addoption(boughtname,'Your favorite weapon: %s, bought %s times' % (boughtname,boughtamount))
    p.addoption(1,'Full list of weapons')
    p.send(userid)
Esempio n. 26
0
def Check_Runboost(userid):
    location = es.getplayerlocation(userid)
    steamid = es.getplayersteamid(userid)
    velocity = int(
        round(
            vector(
                (float(
                    es.getplayerprop(
                        userid, 'CBasePlayer.localdata.m_vecVelocity[0]')),
                 float(
                     es.getplayerprop(
                         userid, 'CBasePlayer.localdata.m_vecVelocity[1]')),
                 float(
                     es.getplayerprop(
                         userid,
                         'CBasePlayer.localdata.m_vecVelocity[2]')))).length(),
            2))
    gamethread.cancelDelayed("Check_Ground_%s" % userid)
    if playerOnTop(userid)[0] == "True":
        client[steamid]['loc'] = location
        client[steamid]['time'] = 0
        client[steamid]['avs'] = []
        client[steamid]['pre'] = velocity
    else:
        gamethread.cancelDelayed("Check_Ground_%s" % userid)
        Check_When_Grounded(userid, False, True)
        return

    gamethread.delayedname(0.001,
                           'Check_Runboost_%s' % userid,
                           Check_Runboost,
                           args=(userid))
Esempio n. 27
0
def dog_tags(userid):
    steamid = es.getplayersteamid(userid)
    rank = getPos(steamid)
    points = getPoints(steamid)
    dog_t = popuplib.easymenu(str(steamid) + 'Dog_tags', None, dog_tags_select)
    dog_t.settitle("Dog Tags")
    dog_t.setdescription('Current: None')
    dog_t.c_beginsep = " "
    dog_t.c_pagesep = " "
    for pos in tags:

        if not pos.startswith('[U:'):

            if str(tags[pos]['type']) == "ranked":
                if points > 7000:
                    if int(rank) >= int(tags[pos]['min_rank']):
                        dog_t.addoption(pos, pos)
                    else:
                        dog_t.addoption(pos, pos, state=False)
                else:
                    dog_t.addoption(pos, pos, state=False)

            elif tags[pos]["type"] == "points":
                if points >= int(tags[pos]['min_points']):
                    dog_t.addoption(pos, pos)

                else:
                    dog_t.addoption(pos, pos, state=False)

    dog_t.send(userid)
Esempio n. 28
0
def myheroes(userid, args):
    userid = str(userid)
    steamid = es.getplayersteamid(userid)
    pid, pheroes, ppower1, ppower2, ppower3 = cursor.execute('SELECT id, heroes, power1, power2, power3 FROM users WHERE id=?', (steamid,)).fetchone()
    heroes = pheroes
    heroes = heroes.split(',')
    menuname = "myheroes"+"_"+userid
    menuname = popuplib.easymenu(menuname,None, myheroes_selection)
    myheroes_popup = langlib.Strings(es.getAddonPath("superhero") + "/languages/myheroes_popup.ini")
    global popup_language
    menuname.settitle(myheroes_popup('myheroes_title',lang=str(popup_language)))
    menuname.setdescription(myheroes_popup('myheroes_desc',lang=str(popup_language)))
    for hero in heroes:
        if hero != '0':
            if str(ppower1) == hero:
                menuname.addoption(str(hero),str(hero)+' [+power1]')
            elif str(ppower2) == hero:
                menuname.addoption(str(hero),str(hero)+' [+power2]')
            elif str(ppower3) == hero:
                menuname.addoption(str(hero),str(hero)+' [+power3]')
            else:
                menuname.addoption(str(hero),hero)
    menuname = "myheroes"+"_"+userid
    #close_popups(userid)
    popuplib.send(menuname,userid)
Esempio n. 29
0
def myheroes(userid, args):
    userid = str(userid)
    steamid = es.getplayersteamid(userid)
    pid, pheroes, ppower1, ppower2, ppower3 = cursor.execute(
        'SELECT id, heroes, power1, power2, power3 FROM users WHERE id=?',
        (steamid, )).fetchone()
    heroes = pheroes
    heroes = heroes.split(',')
    menuname = "myheroes" + "_" + userid
    menuname = popuplib.easymenu(menuname, None, myheroes_selection)
    myheroes_popup = langlib.Strings(
        es.getAddonPath("superhero") + "/languages/myheroes_popup.ini")
    global popup_language
    menuname.settitle(
        myheroes_popup('myheroes_title', lang=str(popup_language)))
    menuname.setdescription(
        myheroes_popup('myheroes_desc', lang=str(popup_language)))
    for hero in heroes:
        if hero != '0':
            if str(ppower1) == hero:
                menuname.addoption(str(hero), str(hero) + ' [+power1]')
            elif str(ppower2) == hero:
                menuname.addoption(str(hero), str(hero) + ' [+power2]')
            elif str(ppower3) == hero:
                menuname.addoption(str(hero), str(hero) + ' [+power3]')
            else:
                menuname.addoption(str(hero), hero)
    menuname = "myheroes" + "_" + userid
    #close_popups(userid)
    popuplib.send(menuname, userid)
def getRank(es_player=None):
    # Tell Player their Current Rank
    if not es_player:
        es_player = es.getcmduserid()
    steamid = es.getplayersteamid(es_player)
    steam_64 = str(convertSteamIDToCommunityID(steamid))
    es.tell(es_player, leetcoin_client.getPlayerRank(steam_64))
Esempio n. 31
0
    def log_event(self, event_var):
        '''Method used to log the given event'''

        # Store the event and userid Event Variables
        event = event_var['es_event']
        userid = event_var['userid']

        # Is this an event that needs to log the "attacker" instead?
        if event in ('gg_levelup', 'gg_knife_steal', 'gg_win'):

            # Store the attacker's userid
            userid = event_var['attacker']

        # Is the player still on the server?
        if not es.exists('userid', userid) and userid != 0:

            # If not, return
            return

        # Get all other information to be logged
        player_name = es.getplayername(userid)
        steamid = es.getplayersteamid(userid)
        team_name = self.get_team_name(userid)

        # Log the event with the necessary information
        es.server.queuecmd('es_xlogq "%s<%s><%s><%s>" triggered "%s"'
            % (player_name, userid, steamid, team_name, event))
def help(es_player=None):
    # Tell Player the help options
    if not es_player:
        es_player = es.getcmduserid()
    steamid = es.getplayersteamid(es_player)
    steam_64 = str(convertSteamIDToCommunityID(steamid))
    es.tell(es_player, "Available commands are:  /balance /rank")
Esempio n. 33
0
def clearpowers(userid, args):
    userid = str(userid)
    steamid = es.getplayersteamid(userid)
    global popup_language
    drop_msg = langlib.Strings(es.getAddonPath("superhero/languages/drop_msg.ini"))
    if int(es.ServerVar('drop_alive')) == 0:
        if int(playerlib.getPlayer(userid).isdead) == 0:
            es.tell(userid,'#multi',drop_msg('drop_alive',lang=str(popup_language)))
            return
    pid, punspent, pheroes, ppower1, ppower2, ppower3 = cursor.execute('SELECT id, unspent, heroes, power1, power2, power3 FROM users WHERE id=?', (steamid,)).fetchone()
    heroes = pheroes
    heroes = heroes.split(',')
    counter = 0
    for hero in heroes:
        if hero != '0':
            cursor.execute('UPDATE users SET unspent=(unspent + 1) WHERE id=?', (steamid,))
            if ppower1 == hero:
                cursor.execute('UPDATE users SET power1=\'0\' WHERE id=?', (steamid,))
            if ppower2 == hero:
                cursor.execute('UPDATE users SET power2=\'0\' WHERE id=?', (steamid,))
            if ppower3 == hero:
                cursor.execute('UPDATE users SET power3=\'0\' WHERE id=?', (steamid,))
            counter += 1
    cursor.execute('UPDATE users SET heroes=\'0\', powerx=\'0\' WHERE id=?', (steamid,))
    connection.commit()
    other_msg = langlib.Strings(es.getAddonPath("superhero") + "/languages/other_msg.ini")
    tokens = {}
    tokens['counter'] = counter
    es.tell(userid,'#multi',other_msg('other_cleared',tokens,lang=str(popup_language)))
Esempio n. 34
0
def unload():
    for userid in es.getUseridList():
        if players.has_key(userid):
            gamethread.cancelDelayed('beacon_%s' % userid)
            gamethread.cancelDelayed('timebomb_%s' % userid)
            gamethread.cancelDelayed('freezebomb_%s' % userid)
            gamethread.cancelDelayed('firebomb_%s' % userid)
            gamethread.cancelDelayed('unmute_%s' % es.getplayersteamid(userid))
            es.setplayerprop(userid, "CBaseEntity.movetype", 2)
            es.setplayerprop(userid, 'CBasePlayer.m_iDefaultFOV', 90)
    gamethread.cancelDelayed('remove_fire')
    gamethread.cancelDelayed('blind_loop')
    es.addons.unregisterSayFilter(_say_filter)
    # xaextendedpunishments.xapunishments.unregisterPunishment("punishment")
    xaextendedpunishments.xapunishments.unregisterPunishment("blind")
    xaextendedpunishments.xapunishments.unregisterPunishment("freeze")
    xaextendedpunishments.xapunishments.unregisterPunishment("gimp")
    xaextendedpunishments.xapunishments.unregisterPunishment("drug")
    xaextendedpunishments.xapunishments.unregisterPunishment("beacon")
    xaextendedpunishments.xapunishments.unregisterPunishment("noclip")
    xaextendedpunishments.xapunishments.unregisterPunishment("freezebomb")
    xaextendedpunishments.xapunishments.unregisterPunishment("timebomb")
    xaextendedpunishments.xapunishments.unregisterPunishment("firebomb")

    if int(xa_adminmute_on):
        xaextendedpunishments.xapunishments.unregisterPunishment("mute")

    xaextendedpunishments.delRequirement('xapunishments')
    xaextendedpunishments.unregister()
Esempio n. 35
0
def sh_givexp(userid, amount, reason):
    userid = str(userid)
    steamid = es.getplayersteamid(userid)
    if steamid == 'BOT':
        return
    reason = str(reason)
    amount = int(amount)
    pid, plevel, pxp = cursor.execute(
        'SELECT id, level, xp FROM users WHERE id=?', (steamid, )).fetchone()
    if plevel < int(es.ServerVar('max_level')):
        xp_next_level = int(es.ServerVar('xp_next_level'))
        xp_multi = float(es.ServerVar('xp_multi'))
        #xp_grenze = ((plevel + 1)*xp_next_level)*xp_multi
        xp_grenze = int((plevel * plevel) * xp_next_level * xp_multi)
        xp = amount + int(pxp)
        if int(xp) >= int(xp_grenze):
            # The player is above max xp
            cursor.execute('UPDATE users SET xp=? WHERE id=?',
                           ((xp), getID(userid)))
            sh_levelup(userid, 1)
        else:
            cursor.execute('UPDATE users SET xp=? WHERE id=?',
                           ((xp), getID(userid)))
        # Show the player's current level XP
        xp_msg = langlib.Strings(
            es.getAddonPath('superhero') + '/languages/xp_msg.ini')
        global popup_language
        tokens = {}
        tokens['amount'] = amount
        es.tell(userid, '#multi',
                xp_msg('xp_gain', tokens, lang=str(popup_language)), reason)
        es.server.cmd('es_xsexec %s say /showxp' % userid)
        connection.commit()
Esempio n. 36
0
def sh_givexp(userid,amount,reason):
    userid = str(userid)
    steamid = es.getplayersteamid(userid)
    if steamid == 'BOT':
        return
    reason = str(reason)
    amount = int(amount)
    pid, plevel, pxp = cursor.execute('SELECT id, level, xp FROM users WHERE id=?', (steamid,)).fetchone()
    if plevel < int(es.ServerVar('max_level')):
        xp_next_level = int(es.ServerVar('xp_next_level'))
        xp_multi = float(es.ServerVar('xp_multi'))
        #xp_grenze = ((plevel + 1)*xp_next_level)*xp_multi
        xp_grenze = int((plevel*plevel)*xp_next_level*xp_multi)
        xp = amount + int(pxp)
        if int(xp) >= int(xp_grenze):
            # The player is above max xp
            cursor.execute('UPDATE users SET xp=? WHERE id=?', ((xp), getID(userid)))
            sh_levelup(userid,1)
        else:
            cursor.execute('UPDATE users SET xp=? WHERE id=?', ((xp), getID(userid)))
        # Show the player's current level XP
        xp_msg = langlib.Strings(es.getAddonPath('superhero') + '/languages/xp_msg.ini')
        global popup_language
        tokens = {}
        tokens['amount'] = amount
        es.tell(userid,'#multi',xp_msg('xp_gain',tokens,lang=str(popup_language)),reason)
        es.server.cmd('es_xsexec %s say /showxp' % userid)
        connection.commit()
Esempio n. 37
0
def player_spawn(ev):
    dbg('player_spawn')
    if not es.isbot(ev['userid']):
        steamid = es.getplayersteamid(ev['userid'])
        if not steamid:
            dbg('NO STEAM ID!!!')
            return
        if steamid == 'STEAM_ID_PENDING':
            dbg('STEAM_ID_PENDING')
            gamethread.delayedname(1, 'xs_delayed_%s' % ev['userid'], pendingCheck, kw={userid:ev['userid']})
            pending.append(ev['userid']) 
            return
        if not ev['userid'] in newconnected:
            return
        if not steamid in players:
            players.newplayer(steamid)
        if not steamid in toplist:
            toplist.newplayer(steamid)
        players.increment(steamid,'sessions')
        players.update(steamid,'sessionstart',time.time())
        players.update(steamid,'lastseen',time.time())
        players.update(steamid,'teamchange_time',time.time())
        newname = es.getplayername(ev['userid'])
        players.name(steamid,newname)
        newconnected.remove(ev['userid'])
        if ev['userid'] in pending:
            pending.remove(ev['userid'])
        dbg('player spawned: %s' % steamid)
Esempio n. 38
0
 def _say_text_filter(cls, user_ID, text, teamonly):
     stripped_text = text.strip("\"")
     name, separator, stripped_text = stripped_text.partition(" ")
     if not name in cls._names:
         return (user_ID, text, teamonly)
     command = cls._names[name]
     if (command.requires_auth and not clients.is_user_authorised(
             es.getplayersteamid(user_ID), command.permission)):
         command.no_auth_callback(command.INFORMER, name, user_ID)
         return (False, False, False)
     try:
         args = shlex.split(stripped_text)
     except ValueError:
         # If the string does not have a trailing ", it needs appending.
         stripped_text += "\""
         args = shlex.split(stripped_text)
     try:
         args = _Command._get_transformed_args(command.callback,
                                               args,
                                               user_ID=user_ID)
     except ArgumentCountError, (args, ):
         command.invalid_syntax_callback(command.INFORMER,
                                         name,
                                         command.callback.parameters,
                                         args,
                                         user_ID=user_ID)
Esempio n. 39
0
def Set_Location(userid):
    check = es.getplayerprop(userid, 'CBasePlayer.m_fFlags')
    location = es.getplayerlocation(userid)
    steamid = es.getplayersteamid(userid)
    player = playerlib.getPlayer(userid)
    velocity = int(
        round(
            vector(
                (float(
                    es.getplayerprop(
                        userid, 'CBasePlayer.localdata.m_vecVelocity[0]')),
                 float(
                     es.getplayerprop(
                         userid, 'CBasePlayer.localdata.m_vecVelocity[1]')),
                 float(
                     es.getplayerprop(
                         userid,
                         'CBasePlayer.localdata.m_vecVelocity[2]')))).length(),
            2))
    if not check & 1:
        if not playerOnTop(userid)[0] == "True":
            if velocity < 400:
                gamethread.cancelDelayed("Check_Runboost_%s" % userid)
                gamethread.cancelDelayed("Check_Ground_%s" % userid)
                Check_When_Grounded(userid, False, False)

            else:
                gamethread.cancelDelayed("Check_Runboost_%s" % userid)
                gamethread.cancelDelayed("Check_Ground_%s" % userid)
                Check_When_Grounded(userid, True, False)
        else:
            gamethread.cancelDelayed("Check_Runboost_%s" % userid)
            gamethread.cancelDelayed("Check_Ground_%s" % userid)
            Check_Runboost(userid)

        return
    else:
        client[steamid]['loc'] = location
        client[steamid]['time'] = 0
        client[steamid]['avs'] = []
        client[steamid]['pre'] = velocity
        gamethread.cancelDelayed("Check_Runboost_%s" % userid)
        gamethread.cancelDelayed("Check_Ground_%s" % userid)

    if player.isdead:
        gamethread.cancelDelayed("Check_Runboost_%s" % userid)
        gamethread.cancelDelayed("Check_Ground_%s" % userid)
        gamethread.cancelDelayed("Set_Location_%s" % userid)
        esc.tell(
            userid,
            "#255,51,0[#255,137,0LJStats#255,51,0] #snowis no longer tracking you!"
        )
        client[steamid]['lj'] = 0
        return

    gamethread.delayedname(0.001,
                           'Set_Location_%s' % userid,
                           Set_Location,
                           args=(userid))
Esempio n. 40
0
def _is_validated(user_ID):
    """Return whether ot not a given user"s network ID has been validated by
    the server.

    Arguments:
    user_ID - the unique session ID of the user.
    """
    return es.getplayersteamid(user_ID) != STEAM_ID_PENDING
Esempio n. 41
0
def _is_validated(user_ID):
    """Return whether ot not a given user"s network ID has been validated by
    the server.

    Arguments:
    user_ID - the unique session ID of the user.
    """
    return es.getplayersteamid(user_ID) != STEAM_ID_PENDING
Esempio n. 42
0
def winner_menu_cmd(userid, args):
    # Make sure player exists
    if not es.exists('userid', userid) and userid != 0:
        return

    # Get the winners list with a limit of the top 50 winners
    currentWinners = get_winners_list(50)
    rankings = []
    rank = 0

    # Empty database ?
    if currentWinners == []:
        rankings = ['Nobody has won yet!']

    # 1 Winner ?
    elif isinstance(currentWinners, dict):
        # Check to see if the player requesting the menu is the player being
        # listed
        if currentWinners["uniqueid"] == es.getplayersteamid(userid):
            rank = 1

        # Add the player
        rankings.append('[%s] %s' % (currentWinners['wins'],
                                                       currentWinners['name']))

    # Update popup list
    else:
        count = 0

        for player in currentWinners:
            count += 1

            # Check to see if the player requesting the menu is the player
            # being listed
            if player["uniqueid"] == es.getplayersteamid(userid):
                rank = count

            # Add the player
            rankings.append('[%s] %s' % (player['wins'], player['name']))

    # Create a new OrderedMenu
    ggWinnersMenu = OrderedMenu(userid, 'GunGame: Winners Menu', rankings,
                                                        highlightIndex=rank)

    # Send the OrderedMenu
    ggWinnersMenu.send_page(1)
Esempio n. 43
0
def getplayerid(userid, issteamid=0): #플레이어 고유번호 함수
    try:
        if issteamid: steamid = userid
        else: steamid = es.getplayersteamid(userid)
        if steamid == "BOT": return "BOT"
        return steamid[3:13].replace(":", "")
    except:
        return "None"
Esempio n. 44
0
 def __init__(self, userid): 
     # set up a player instance of playlib 
     self.uid = int(userid) 
     # some more stuff of use 
     self.plib = playerlib.getPlayer(self.uid) 
     self.steamid = es.getplayersteamid(self.uid) 
     # get some initial data 
     self.spawntime = False 
Esempio n. 45
0
def getplayerid(userid, issteamid=0):  #플레이어 고유번호 함수
    try:
        if issteamid: steamid = userid
        else: steamid = es.getplayersteamid(userid)
        if steamid == "BOT": return "BOT"
        return steamid[3:13].replace(":", "")
    except:
        return "None"
Esempio n. 46
0
 def __init__(self, userid): 
     # set up a player instance of playlib 
     self.uid = int(userid) 
     # some more stuff of use 
     self.plib = playerlib.getPlayer(self.uid) 
     self.steamid = es.getplayersteamid(self.uid) 
     # get some initial data 
     self.spawntime = False 
Esempio n. 47
0
def welcome(userid, args):
    # Do not send to bots or non-existent players
    if es.getplayersteamid(userid) == 'BOT' or not es.exists('userid', userid):
        return

    # If the user has the popup open, remove it
    popuplib.unsendname('gg_welcome', userid)
    # Send the popup
    popuplib.send('gg_welcome', userid)
Esempio n. 48
0
def welcome(userid, args):
    # Do not send to bots or non-existent players
    if es.getplayersteamid(userid) == 'BOT' or not es.exists('userid', userid):
        return

    # If the user has the popup open, remove it
    popuplib.unsendname('gg_welcome', userid)
    # Send the popup
    popuplib.send('gg_welcome', userid)
Esempio n. 49
0
def loop():
    timer = es.import_addon('trikztimer/plugins/timer')
    for userid in es.getUseridList():
        if not userid in specs:
            specs[userid] = {}
            specs[userid]["last_spec"] = None
            specs[userid]["n"] = []
        getPlayer(userid).update()

    for n in specs:
        a = specs[n]['n']
        for spec in a:
            if not es.exists("userid", spec):
                a.remove(spec)
                if es.getplayersteamid(n) in timer.player:
                    timer.player[es.getplayersteamid(n)]['spectators'] = a

    gamethread.delayedname(0.1, ('spectarget_loop'), loop)
def voteKickCheck(userid, choice, popupid):
    """
    Executed when a player has chosen another to vote kick. Get the steamid
    of the victim, and check for the amount of kicks needed. Kick 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 kick user %s [%s]" %
        (es.getplayername(choice), es.getplayersteamid(choice)), userid)
    userids[userid]["kicks"].append(choice)
    targets[steamid]["kicks"] += 1

    kicksRemaining = getKicksRemaining(steamid)

    if kicksRemaining == 0:
        """ There has been enough kicks passed, kick the player. """
        removePlayer(steamid)
        es.server.queuecmd(
            'kickid %s "You have been votekicked from the server"' % choice)
        tokens = {}
        tokens['name'] = es.getplayername(choice)
        for player in playerlib.getPlayerList('#all'):
            es.tell(int(player), '#multi',
                    xalanguage('player kicked', tokens, player.get("lang")))
        xavotekickban.logging.log("has been vote kicked" % choice)
    else:
        tokens = {}
        tokens['name'] = es.getplayername(choice)
        tokens['amount'] = kicksRemaining
        for player in playerlib.getPlayerList("#all"):
            es.tell(
                int(player), '#multi',
                xalanguage('player votes kicked', tokens, player.get("lang")))
        xavotekickban.logging.log(
            "needs %s more votes till they are kicked" % kicksRemaining,
            choice)
Esempio n. 51
0
def updateTimes():
    for userid in playerlib.getUseridList('#human'):
        steamid = es.getplayersteamid(userid)
        players.update(steamid,'lastseen',time.time())
        players.add(steamid,'time',time.time() - players.query(steamid,'sessionstart'))
        players.update(steamid,'sessionstart',time.time())
        cteam = players.query(steamid,'current_team')
        if not cteam == '0':
            players.add(steamid,'team_%s_time' % cteam,time.time() - players.query(steamid,'teamchange_time'))
        players.update(steamid,'teamchange_time',time.time())
Esempio n. 52
0
def _addadmin_select(userid,choice,popupid):
    es.dbgmsg(1,'*****_addadmin_select')
    if choice[1]:
        id = es.getuserid(choice[0])
        steamid = es.getplayersteamid(id)
        basicadmins = str(es.ServerVar('BASIC_AUTH_ADMIN_LIST'))
        basicadmins = basicadmins.split(';')
        if steamid not in basicadmins:
            _update_badmins(steamid,choice[0],'0','0')
        else:
            es.tell(userid, '#multi', prefix + choice[0] + ' is already an admin.')
Esempio n. 53
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)
Esempio n. 54
0
def cmd_top(userid,args):
    if str(userid) in xs.pending:
        es.tell(userid,txt.getSimple('sorry_pending'))
        return
    myargs = [scfg.default_top_x,None]
    for x in range(len(args)):
        myargs[x] = args[x]
    steamid = es.getplayersteamid(userid)
    method = method if not xs.players.query(steamid,'settings_method') else xs.players.query(steamid,'settings_method')
    method = xs.getMethod(myargs[1])
    displayTop(userid, int(myargs[0]), method)
Esempio n. 55
0
def cmd_rank(userid,args):
    if str(userid) in xs.pending:
        es.tell(userid,txt.getSimple('messages','sorry_pending'))
        return
    steamid = es.getplayersteamid(userid)
    if len(args) == 1:
        method = xs.getMethod(args[0].lower())
    else:
        method = xs.getMethod(xs.players.query(steamid,'settings_method'))
    rank,score,totalplayers = xs.getRankScore(steamid,method, True)
    es.tell(userid,text.getCmdString(steamid,'rank',method,score,rank,totalplayers))
Esempio n. 56
0
def _bauthmain_select(userid,choice,popupid):
    es.dbgmsg(1,'*****_bauthmain_select')
    master = es.getplayersteamid(userid)
    b_admins = shelve.open(b_admins_path)
    if b_admins.has_key(master) and int(b_admins[master][1]):
        if choice == 'players':
            _playerlist(userid)
        elif choice == 'admins':
            _adminlist(userid)
    else:
        es.tell(userid,'#multi', prefix + lang('master access only'))
    b_admins.close	
Esempio n. 57
0
def getScore(steamid,method,ignore_negative=False):
    if method in players.columns:
        score = players.query(steamid,method)
        if method in scfg.negative_columns and not ignore_negative:
            return -score
        return score
    if method not in methods:
        method = dcfg['default_method'].strip()
    steamidlist = map(lambda x: es.getplayersteamid(x),playerlib.getUseridList('#human'))
    if not steamid in steamidlist:
        return toplist.query(steamid,method)
    return methods[method](players,steamid)
Esempio n. 58
0
 def plant(self, userid, site, mapname):
     if active:
         if site != bombsitesNum[self.defaultSiteLetter]:
             if es.getplayersteamid(userid) != 'BOT':
                 playerlib.getPlayer(userid).set("push", (0, 300, 1))
                 es.tell(userid, '#multi', '#green[#lightgreenBombsite#green-#lightgreenLimiter#lightgreen]#default Due to the low number of CT\'s this round, you must #lightgreenonly plant at site #green%s#lightgreen!'%self.defaultSiteLetter)
                 es.centertell(userid, 'You must only plant at %s site!'%self.defaultSiteLetter)
                 gamethread.delayed(1, es.centertell, (userid, 'You must only plant at %s site!'%self.defaultSiteLetter))
             else:
                 x, y, z = random.choice(coords)
                 es.server.queuecmd('es_xsetpos %s %s %s %s'%(userid, x, y, z))
                 es.msg('#multi','#green[#lightgreenBombsite#green-#lightgreenLimiter#green]#lightgreen %s #defaultwas teleported for planting at the wrong bombsite and being a bot!' % es.getplayername(userid))
Esempio n. 59
0
def banPlayerMenu(playerid, selectedBanLength, popupid):
  # Now set the ban length selected to the correct admin in the admin keylist
  # Stored to the keylist so that it can be "passed" on
  # And to prevent other admins from stomping on each other
  es.keysetvalue('clanMembers', es.getplayersteamid(playerid), 'banLength', selectedBanLength)

  # Create keymenu called banmenu for admin to select a player from
  banmenu = keymenulib.create("banmenu", "userToBan", banInGame, "playerlist", "#keyvalue name", "#key", "Player List")
  banmenu.send(playerid)

  # Delete the playerlist
  es.server.queuecmd('es_xkeygroupdelete playerlist')