Exemplo n.º 1
0
def banFromConsole():
  bannedSteamId = es.getargv(1)
  banReason = es.getargv(2)
  banLength = int(es.getargv(3)) # This is in minutes
  nameOfBanned = es.getargv(4)
  ipOfBanned = es.getargv(5)
  
  # Convert minutes to the appropriate length and timescale
  # At a later date this will be removed as all lengths will eventually be in minutes  
  if banLength < 60:
    timeScale = "minutes"
  elif banLength >= 60 and banLength < 1440: # between 1 hour and 24 hours
    timeScale = "hours"
    banLength = banLength / 60
  elif banLength >= 1440 and banLength < 10080: # between 1 day and 7 days
    timeScale = "days"
    banLength = banLength / 1440
  elif banLength >= 10080 and banLength < 40320: # between 1 week and 4 weeks
    timeScale = "weeks"
    banLength = banLength / 10080
  elif banLength >= 40320:
    timeScale = "months"
    banLength = banLength / 40320
    
  banUser(-1, bannedSteamId, banReason, str(banLength), timeScale, nameOfBanned, ipOfBanned)
Exemplo n.º 2
0
def _inputbox_handle():
    userid = es.getcmduserid()
    count = int(es.getargc())
    if count > 4:
        parent = es.getargv(1)
        if popuplib.exists(parent):
            module = es.getargv(2)
            if xa.exists(module):
                module = xa.find(module)
                varname = es.getargv(3)
                if module and varname in module.variables:
                    var = module.variables[varname]
                    i = 4
                    oldval = str(var)
                    newvalue = ''
                    while i < count:
                        newvalue = newvalue + ' ' + es.getargv(i)
                        i = i + 1
                    newvalue = newvalue.strip()
                    var.set(newvalue)
                    es.esctextbox(
                        10, userid, "Changed '" + str(varname) + "' setting",
                        "Changed '%s' to '%s'\nThe variable menu is open again.\nPress [ESC] a second time."
                        % (varname, newvalue))
                    menu = _variableEditMenu(userid, module, var, parent)
                    menu.send(userid)
                    xaconfig.logging.log(
                        "Admin %s just change config %s from %s to %s" %
                        (es.getplayername(userid), varname, oldval, newvalue))
    else:
        es.esctextbox(10, userid, "Invalid Entry", "<value>")
Exemplo n.º 3
0
def _inputbox_handle():
    es.dbgmsg(1,'*****_inputbox_handle')
    userid = es.getcmduserid()    
    count = int(es.getargc())
    if count == 3:
        groupname = es.getargv(1)
        level = es.getargv(2)
        level = level.lower()        
        if level in ('root','admin','poweruser','known','all'):
            if level == 'root': 
                level = 0
            if level == 'admin': 
                level = 1
            if level == 'poweruser': 
                level = 2
            if level == 'known': 
                level = 4
            if level == 'all': 
                level = 128            
            es.server.queuecmd('gauth group create %s %d' %(groupname,level))
            es.esctextbox(10, userid, "New group added", "You have added group: %s with access level %s" %(groupname,level))
        else:
            es.esctextbox(10, userid, "Invalid level", "Accepted levels:\n -admin\n -poweruser\n -known\n -all")
    else:
        es.esctextbox(10, userid, "Invalid Entry", "<groupname-no spaces> <level>")
Exemplo n.º 4
0
def services_proxy():
  service = es.getargv(1)
  myserv = services.use(service)
  if not isinstance(myserv, LegacyAuthorizationService):
    # e2py
    function = es.getargv(2)
  
    # HACK: For auth services
    responsevarn = 0
    responsevar = None
    if service=="auth":
      # fix the case of the function
      for caser in returnvarlist.keys():
        if caser.lower() == function.lower():
          function = caser
      responsevarn = returnvarlist[function] if returnvarlist.has_key(function) else 0
      if responsevarn:
        responsevar = es.ServerVar(es.getargv(responsevarn))
    
    arglist = [myserv]
    for j in range(3,es.getargc()):
      if not j == responsevarn:
        arglist.append(es.getargv(j))
    func = myserv.__class__.__dict__[function]
    d = func(*arglist)
    if d is not None and responsevar is not None:
      responsevar.set(d)
  else:
    # e2e
    cmd = myserv.cmdname
    args = es.getargs()[len(service)+1:]
    newcmd = "%s %s" % (cmd, args)
    es.server.cmd(newcmd)
Exemplo n.º 5
0
def _inputbox_handle():
    es.dbgmsg(1, '*****_inputbox_handle')
    userid = es.getcmduserid()
    count = int(es.getargc())
    if count == 3:
        groupname = es.getargv(1)
        level = es.getargv(2)
        level = level.lower()
        if level in ('root', 'admin', 'poweruser', 'known', 'all'):
            if level == 'root':
                level = 0
            if level == 'admin':
                level = 1
            if level == 'poweruser':
                level = 2
            if level == 'known':
                level = 4
            if level == 'all':
                level = 128
            es.server.queuecmd('gauth group create %s %d' % (groupname, level))
            es.esctextbox(
                10, userid, "New group added",
                "You have added group: %s with access level %s" %
                (groupname, level))
        else:
            es.esctextbox(
                10, userid, "Invalid level",
                "Accepted levels:\n -admin\n -poweruser\n -known\n -all")
    else:
        es.esctextbox(10, userid, "Invalid Entry",
                      "<groupname-no spaces> <level>")
def wrim(args):
    if es.getargv(1) and es.exists("userid", es.getargv(1)):
        genRaceinfoPop('raceinfo_menu_%s' % es.getargv(1), raceinfo_handler,
                       es.getargv(1),
                       es.keygetvalue("wcsuserdata", es.getargv(1), "race"))
    else:
        es.msg("#green", "Failed.")
Exemplo n.º 7
0
def redirect_cmd():
    """
    redirect <userid/player name/"Steam ID"> ["IP"] [kick] [delay]
    Ensures a correct number of arguments were provided
    Ensures the specified player exists
    Retrieves the optional arguments while converting them to the desired type
    Calls send_prompt with the specified arguments
    """
    int_arg_count = es.getargc()
    int_cmd_userid = es.getcmduserid()

    if int_arg_count in (2, 3, 4, 5):
        str_player_arg = es.getargv(1)
        int_userid = es.getuserid(str_player_arg)

        if int_userid:
            list_args = [int_userid, str(var_ip), int(var_kick), float(var_delay)]
            dict_arg_types = {2:str, 3:int, 4:float}
            for int_x in range(2, int_arg_count):
                try:
                    list_args[int_x - 1] = dict_arg_types[int_x](es.getargv(int_x))
                except:
                    display_feedback(int_cmd_userid, 'invalid argument', {'arg':es.getargv(int_x), 'type':dict_arg_types[int_x].__name__})
                    return

            send_prompt(*list_args)

        else:
            display_feedback(int_cmd_userid, 'no player', {'player':str_player_arg})

    else:
        display_feedback(int_cmd_userid, 'syntax', {'syntax':'xaredirect <userid/player name/\"Steam ID\"> [\"IP\"] [kick] [delay]'})
Exemplo n.º 8
0
def _inputbox_handle():
    userid = es.getcmduserid()
    count = int(es.getargc())
    if count > 4:
        parent = es.getargv(1)
        if popuplib.exists(parent):
            module = es.getargv(2)
            if xa.exists(module):
                module = xa.find(module)
                varname = es.getargv(3)
                if module and varname in module.variables:
                    var = module.variables[varname]
                    i = 4
                    oldval = str(var)
                    newvalue = ''
                    while i < count:
                        newvalue = newvalue+' '+es.getargv(i)
                        i = i + 1
                    newvalue = newvalue.strip()
                    var.set(newvalue)
                    es.esctextbox(10, userid, "Changed '"+str(varname)+"' setting", "Changed '%s' to '%s'\nThe variable menu is open again.\nPress [ESC] a second time." %(varname,newvalue))
                    menu = _variableEditMenu(userid, module, var, parent)
                    menu.send(userid)
                    xaconfig.logging.log("Admin %s just change config %s from %s to %s" % (es.getplayername(userid), varname, oldval, newvalue) )
    else:
        es.esctextbox(10, userid, "Invalid Entry", "<value>")
Exemplo n.º 9
0
def services_proxy():
    service = es.getargv(1)
    myserv = services.use(service)
    if not isinstance(myserv, LegacyAuthorizationService):
        # e2py
        function = es.getargv(2)

        # HACK: For auth services
        responsevarn = 0
        responsevar = None
        if service == "auth":
            # fix the case of the function
            for caser in returnvarlist.keys():
                if caser.lower() == function.lower():
                    function = caser
            responsevarn = returnvarlist[function] if returnvarlist.has_key(
                function) else 0
            if responsevarn:
                responsevar = es.ServerVar(es.getargv(responsevarn))

        arglist = [myserv]
        for j in range(3, es.getargc()):
            if not j == responsevarn:
                arglist.append(es.getargv(j))
        func = myserv.__class__.__dict__[function]
        d = func(*arglist)
        if d is not None and responsevar is not None:
            responsevar.set(d)
    else:
        # e2e
        cmd = myserv.cmdname
        args = es.getargs()[len(service) + 1:]
        newcmd = "%s %s" % (cmd, args)
        es.server.cmd(newcmd)
Exemplo n.º 10
0
def _formatv(findex):
    count = es.getargc()
    format = es.getargv(findex)
    num = 0
    for indx in range(findex+1,count):
        num += 1
        format = format.replace("%"+str(num),str(es.server_var[es.getargv(indx)]))
    return format
Exemplo n.º 11
0
 def _callback(cls):
     name = es.getargv(0)
     command = cls._names[name]
     if not command.names[name]:
         command.disabled_callback(command.INFORMER, name)
         return
     args = [es.getargv(arg) for arg in xrange(1, es.getargc())]
     try:
         args = _Command._get_transformed_args(command.callback, args)
     except ArgumentCountError, (args, ):
         command.invalid_syntax_callback(command.INFORMER, name,
                                         command.callback.parameters, args)
Exemplo n.º 12
0
 def _callback(cls):
     name = es.getargv(0)
     command = cls._names[name]
     if not command.names[name]:
         command.disabled_callback(command.INFORMER, name)
         return
     args = [es.getargv(arg) for arg in xrange(1, es.getargc())]
     try:
         args = _Command._get_transformed_args(command.callback, args)
     except ArgumentCountError, (args, ):
         command.invalid_syntax_callback(command.INFORMER, name,
                                         command.callback.parameters, args)
Exemplo n.º 13
0
def xarestrict_cmd():
    """
   xa_restrict <player/team> <weapon 1> [weapon 2] ... [weapon n]
   xa_unrestrict <player/team> <weapon 1> [weapon 2] ... [weapon n]
   """
    arg_count = es.getargc()
    command_name = es.getargv(0).lower()
    func_command = restrict if command_name == "xa_restrict" else unrestrict

    if arg_count > 2:
        func_command(es.getargv(1).lower(), [es.getargv(x).lower() for x in range(2, arg_count)])

    else:
        es.dbgmsg(0, "Syntax: %s <player/team> <weapon 1> [weapon 2] ... [weapon n]" % command_name)
Exemplo n.º 14
0
def exp_reg(args_dummy):
    argc = es.getargc()
    if argc > 3:
        global funcs
        global funcsregex
        global regex1
        block = es.getargv(2)
        func = es.getargv(1)
        minargs = es.getargv(3)
        if not func in funcs:
            if re.match('^.+/.+(/.+)?$', block):
                if es.exists('block', block):
                    if argc > 4:
                        global funccmds
                        userfunc = '_exp_userfunc' + str(len(funccmds) + 1)
                        es.regcmd(userfunc, block, 'exp user function')
                        funcs[func] = {}
                        funccmds.append(userfunc)
                        funcs[func]['function'] = userfunc
                        funcs[func]['minargs'] = int(minargs)
                        funcs[func]['var'] = es.getargv(4)
                        funcsregex = '|'.join(funcs)
                        regex1 = re.compile(funcsregex)
                    else:
                        es.dbgmsg(
                            0,
                            'exp_reg : input variable name must be given for function block'
                        )
                else:
                    es.dbgmsg(0, 'exp_reg : invalid block given')
            elif re.match('^.+\\..+(\\..+)?$', block):
                temp = block.split('.')

                exec('temp = callable(' + block + ')')
                if temp:
                    exec('funcs[func][\'function\'] = ' + block)
                    funcs[func]['minargs'] = minargs
                    funcsregex = '|'.join(funcs)
                    regex1 = re.compile(funcsregex)
                else:
                    es.dbgmsg(0, 'exp_reg : invalid function given')
            else:
                es.dbgmsg(0, 'exp_reg : invalid block/function given')
        else:
            es.dbgmsg(0, 'exp_reg : function already registered')
    else:
        es.dbgmsg(
            0,
            'Syntax : exp_reg <function-name> <function/block> <min-args> [var]'
        )
Exemplo n.º 15
0
def callbackClient():
   """
   Called when a client command is used, this function gives a list of
   current client commands and the client command used to cmd_manager.callback,
   which in turn decides a function should be executed.
   """
   cmd_manager.callback(cmd_manager.client_commands, es.getargv(0).lower())
def wssm(args):
    userid = es.getargv(1)
    if userid and es.exists("userid", userid):
        genSkillsPop('spendskills_menu_%s' % userid, spendskills_handler,
                     userid)
    else:
        es.msg("#green", "Failed.")
Exemplo n.º 17
0
def callbackServer():
   """
   Called when a server command is used, this function gives a list of
   current server commands and the server command used to cmd_manager.callback,
   which in turn decides a function should be executed.
   """
   cmd_manager.callback(cmd_manager.server_commands, es.getargv(0))
Exemplo n.º 18
0
def voteCmd():
    command = es.getargv(0).replace('xa_', '').replace('vote', '')
    args = []
    argLength = es.getargc()
    tempCount = 0
    while tempCount < argLength:
        tempCount += 1
        args.append(es.getargv(tempCount))
    if '' in args:
        args.remove('')
    commandFunction = vote_list[command]['commandFunction']
    if callable(commandFunction):
        if args:
            commandFunction(args)
        else:
            commandFunction()
Exemplo n.º 19
0
def voteCmd():
    command   = es.getargv(0).replace('xa_','').replace('vote','')
    args      = []
    argLength = es.getargc()
    tempCount = 0
    while tempCount < argLength:
        tempCount += 1
        args.append(es.getargv(tempCount))
    if '' in args:
        args.remove('')
    commandFunction = vote_list[command]['commandFunction']
    if callable(commandFunction):
        if args:
            commandFunction(args)
        else:
            commandFunction()
Exemplo n.º 20
0
 def callback(self, cmdlist, name):
    """
    This function is called when a server, say, or client command is received
    If the command name is present in the list of the same type of commands, the callback function is called
    """
    if name in cmdlist:
       cmdlist[name].execute(self.CMDArgs(es.getargv(x) for x in range(1, es.getargc())))
Exemplo n.º 21
0
 def callback(self, cmdlist, name):
    """
    This function is called when a server, say, or client command is received
    If the command name is present in the list of the same type of commands, the callback function is called
    """
    if name in cmdlist:
       cmdlist[name].execute(self.CMDArgs(es.getargv(x) for x in xrange(1, es.getargc())))
Exemplo n.º 22
0
def expand_cmd(args):
   """
   Commands sent here are prefixed with "es_". We change that prefix to "es_x",
   place the "es" server command in front of the command, and execute the result.
   """
   name = es.getargv(0)
   es.server.cmd('es ' + name[:3] + 'x' + name[3:] + ((' ' + str(args)) if len(args) else ''))
Exemplo n.º 23
0
def callbackServer():
   """
   Called when a server command is used, this function gives a list of
   current server commands and the server command used to cmd_manager.callback,
   which in turn decides a function should be executed.
   """
   cmd_manager.callback(cmd_manager.server_commands, es.getargv(0))
Exemplo n.º 24
0
def callbackClient():
   """
   Called when a client command is used, this function gives a list of
   current client commands and the client command used to cmd_manager.callback,
   which in turn decides a function should be executed.
   """
   cmd_manager.callback(cmd_manager.client_commands, es.getargv(0).lower())
Exemplo n.º 25
0
 def _callback(cls):
     user_ID = es.getcmduserid()
     name = es.getargv(0)
     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
     args = [es.getargv(arg) for arg in xrange(1, es.getargc())]
     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)
Exemplo n.º 26
0
def delwep():
    global restrictedList
    argument = es.getargv(1)
    if argument in restrictedList:
        restrictedList.remove(argument)
        es.server.queuecmd("echo [UltiRestrict] The new list is now: " + str(restrictedList))
    else:
        es.server.queuecmd("echo [UltiRestrict] The weapon you requested is not in the list.")
Exemplo n.º 27
0
 def __call__(self):
     self.run(priority=True,
              userargs={
                  'cmdname': getargv(0),
                  'argv': list(map(getargv, range(1, getargc()))),
                  'args': getargs(),
                  'uid': int(getcmduserid())
              })
     sv.save()
Exemplo n.º 28
0
def addonCommandListener():
    b = 0
    c = es.getargc()
    args = []
    while b != c:
        args.append(es.getargv(b))
        b += 1
    cmd = args.pop(0)
    addoncommands[cmd](es.getcmduserid(),args)
Exemplo n.º 29
0
def saferemove_cmd():
    """
   xa_restrict_saferemove <index>
   """
    if es.getargc() == 2:
        saferemove(es.getargv(1))

    else:
        es.dbgmsg(0, "Syntax: xa_restrict_saferemove <index>")
Exemplo n.º 30
0
def command_extra():
    args = []
    for i in range(1,es.getargc()):
        args.append(es.getargv(i))
    func = '%s_%s' %(args[0],args[1])
    if func in gCommands:
        gCommands[func](args)
    else:
        es.dbgmsg(0,'[group_auth] Unknown command: '+args[0]+' '+args[1])
Exemplo n.º 31
0
def saferemove_cmd():
    """
   xa_restrict_saferemove <index>
   """
    if es.getargc() == 2:
        saferemove(es.getargv(1))

    else:
        es.dbgmsg(0, 'Syntax: xa_restrict_saferemove <index>')
Exemplo n.º 32
0
def exp_reg(args_dummy):
    argc = es.getargc()
    if argc > 3:
        global funcs
        global funcsregex
        global regex1
        block = es.getargv(2)
        func = es.getargv(1)
        minargs = es.getargv(3)
        if not func in funcs:
            if re.match('^.+/.+(/.+)?$', block):
                if es.exists('block', block):
                    if argc > 4:
                        global funccmds
                        userfunc = '_exp_userfunc' + str(len(funccmds) + 1)
                        es.regcmd(userfunc, block, 'exp user function')
                        funcs[func] = {}
                        funccmds.append(userfunc)
                        funcs[func]['function'] = userfunc
                        funcs[func]['minargs'] = int(minargs)
                        funcs[func]['var'] = es.getargv(4)
                        funcsregex = '|'.join(funcs)
                        regex1 = re.compile(funcsregex)
                    else:
                        es.dbgmsg(0, 'exp_reg : input variable name must be given for function block')
                else:
                    es.dbgmsg(0, 'exp_reg : invalid block given')
            elif  re.match('^.+\\..+(\\..+)?$', block):
                temp = block.split('.')
                
                exec('temp = callable(' + block + ')')
                if temp:
                    exec('funcs[func][\'function\'] = ' + block)
                    funcs[func]['minargs'] = minargs
                    funcsregex = '|'.join(funcs)
                    regex1 = re.compile(funcsregex)
                else:
                    es.dbgmsg(0, 'exp_reg : invalid function given')
            else:
                es.dbgmsg(0, 'exp_reg : invalid block/function given')
        else:
            es.dbgmsg(0, 'exp_reg : function already registered')
    else:
        es.dbgmsg(0, 'Syntax : exp_reg <function-name> <function/block> <min-args> [var]')
Exemplo n.º 33
0
def exp_reg(args_dummy):
    argc = es.getargc()
    if argc > 3:
        global funcs
        global funcsregex
        global regex1
        block = es.getargv(2)
        func = es.getargv(1)
        minargs = es.getargv(3)
        if not func in funcs:
            if re.match("^.+/.+(/.+)?$", block):
                if es.exists("block", block):
                    if argc > 4:
                        global funccmds
                        userfunc = "_exp_userfunc" + str(len(funccmds) + 1)
                        es.regcmd(userfunc, block, "exp user function")
                        funcs[func] = {}
                        funccmds.append(userfunc)
                        funcs[func]["function"] = userfunc
                        funcs[func]["minargs"] = int(minargs)
                        funcs[func]["var"] = es.getargv(4)
                        funcsregex = "|".join(funcs)
                        regex1 = re.compile(funcsregex)
                    else:
                        es.dbgmsg(0, "exp_reg : input variable name must be given for function block")
                else:
                    es.dbgmsg(0, "exp_reg : invalid block given")
            elif re.match("^.+\\..+(\\..+)?$", block):
                temp = block.split(".")

                exec ("temp = callable(" + block + ")")
                if temp:
                    exec ("funcs[func]['function'] = " + block)
                    funcs[func]["minargs"] = minargs
                    funcsregex = "|".join(funcs)
                    regex1 = re.compile(funcsregex)
                else:
                    es.dbgmsg(0, "exp_reg : invalid function given")
            else:
                es.dbgmsg(0, "exp_reg : invalid block/function given")
        else:
            es.dbgmsg(0, "exp_reg : function already registered")
    else:
        es.dbgmsg(0, "Syntax : exp_reg <function-name> <function/block> <min-args> [var]")
Exemplo n.º 34
0
 def _callback(cls):
     user_ID = es.getcmduserid()
     name = es.getargv(0)
     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
     args = [es.getargv(arg) for arg in xrange(1, es.getargc())]
     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)
Exemplo n.º 35
0
def browse_cmd():
    args = [es.getargv(x) for x in xrange(1, es.getargc())]
    if not len(args):
        xamodule.logging.log("Incorrect usage: xa_browse <url>")
        return
    url = urllib.quote(args[0])
    if not url.startswith('http://'):
        url = 'http://' + url
    xamodule.logging.log("Opening url: %s" % url)
    usermsg.motd(es.getcmduserid(), 2, "XA Browse", url)
Exemplo n.º 36
0
def command_extra():
    args = []
    for i in range(1, es.getargc()):
        args.append(es.getargv(i))
    func = '%s_%s' % (args[0], args[1])
    if func in gCommands:
        gCommands[func](args)
    else:
        es.dbgmsg(0,
                  '[group_auth] Unknown command: ' + args[0] + ' ' + args[1])
Exemplo n.º 37
0
def browse_cmd():
    args = [es.getargv(x) for x in xrange(1, es.getargc())]
    if not len(args):
        xamodule.logging.log("Incorrect usage: xa_browse <url>")
        return
    url = urllib.quote(args[0])
    if not url.startswith('http://'):
        url = 'http://'+url
    xamodule.logging.log("Opening url: %s" % url)
    usermsg.motd(es.getcmduserid(), 2, "XA Browse", url)
Exemplo n.º 38
0
def xarestrict_cmd():
    """
   xa_restrict <player/team> <weapon 1> [weapon 2] ... [weapon n]
   xa_unrestrict <player/team> <weapon 1> [weapon 2] ... [weapon n]
   """
    arg_count = es.getargc()
    command_name = es.getargv(0).lower()
    func_command = restrict if command_name == 'xa_restrict' else unrestrict

    if arg_count > 2:
        func_command(
            es.getargv(1).lower(),
            [es.getargv(x).lower() for x in range(2, arg_count)])

    else:
        es.dbgmsg(
            0,
            'Syntax: %s <player/team> <weapon 1> [weapon 2] ... [weapon n]' %
            command_name)
Exemplo n.º 39
0
def _command_player():
    adminid = es.getcmduserid()
    if adminid > 0:
        admin = playerlib.getPlayer(adminid)
    cmd = es.getargv(0).replace(str(es.ServerVar('xa_sayprefix')), 'xa_', 1).replace('ma_', 'xa_', 1)
    if cmd in punishment_cross_ref:
        punishment = punishment_cross_ref[cmd]
        if punishment in punishment_argc:
            argc = es.getargc()
            if argc > punishment_argc[punishment]:
                args = []
                for i in range(1, argc):
                    args.append(es.getargv(i))
                user = es.getargv(1)
                for userid in playerlib.getUseridList(user):
                    _punish_player(userid, punishment, adminid, args)
            elif adminid > 0:
                es.tell(adminid, xalanguage("not enough args", (), admin.get("lang")))
            else:
                es.dbgmsg(0, xalanguage("not enough args"))
Exemplo n.º 40
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')))
Exemplo n.º 41
0
def services_cmd():
  # handles all of the service related functions
  cmd = es.getargv(1)
  cmd = cmd.lower()
  if   cmd == "register":
    # create a fake service
    # //services register auth myauth
    # // services.register("auth", myauth)
    servicename = es.getargv(2)
    cmdname = es.getargv(3)
    leg = LegacyAuthorizationService()
    leg.setCommandName(cmdname)
    services.register(servicename, leg)
  elif cmd == "unregister":
    servicename = es.getargv(2)
    services.unregister(servicename)
    # // services unregister auth
    pass
  elif cmd == "isregistered":
    # //services isregistered myvar auth
    returnvar = es.ServerVar(es.getargv(2))
    servicename = es.getargv(3)
    returnvar.set(int(services.isRegistered(servicename)))
  elif cmd == "getlist":
    pass
  elif cmd == "getregistered":
    pass
  elif cmd == "type":
    pass
  elif cmd == "list":
    pass
  else:
    es.dbgmsg(0, "services: Invalid option.")
Exemplo n.º 42
0
def services_cmd():
    # handles all of the service related functions
    cmd = es.getargv(1)
    cmd = cmd.lower()
    if cmd == "register":
        # create a fake service
        # //services register auth myauth
        # // services.register("auth", myauth)
        servicename = es.getargv(2)
        cmdname = es.getargv(3)
        leg = LegacyAuthorizationService()
        leg.setCommandName(cmdname)
        services.register(servicename, leg)
    elif cmd == "unregister":
        servicename = es.getargv(2)
        services.unregister(servicename)
        # // services unregister auth
        pass
    elif cmd == "isregistered":
        # //services isregistered myvar auth
        returnvar = es.ServerVar(es.getargv(2))
        servicename = es.getargv(3)
        returnvar.set(int(services.isRegistered(servicename)))
    elif cmd == "getlist":
        pass
    elif cmd == "getregistered":
        pass
    elif cmd == "type":
        pass
    elif cmd == "list":
        pass
    else:
        es.dbgmsg(0, "services: Invalid option.")
Exemplo n.º 43
0
def removeidle_cmd():
   """
   xa_restrict_removeidle [weapon 1] [weapon 2] ... [weapon n]
   """
   arg_count = es.getargc()
   if arg_count > 1:
      weapons = getWeaponList([es.getargv(x).lower() for x in range(1, arg_count)])
      if not weapons: raise IndexError, 'Invalid weapon list'

      removeidle(weapons)

   else:
      removeidle()
Exemplo n.º 44
0
def blind_con_com():
    '''
    Allows admins to blind via a console command
    '''
    if es.getargc() > 1:
        id = es.getuserid(es.getargv(1))
        admin = playerlib.getPlayer(es.getcmduserid())
        if id > 0:
            target = playerlib.getPlayer(id)
            if ghosting.setting.getVariable('blind_ghosters') == "0":
                # can only use this if auto blinding is OFF
                if checkplayer(int(target)):
                    es.msg(
                        "#green %s blinded %s till the end of the round for ghosting"
                        %
                        (admin.attributes["name"], target.attributes["name"]))
                    ghosting.logging.log(
                        "blinded user %s [%s] for ghosting" %
                        (es.getplayername(id), es.getplayersteamid(id)),
                        int(admin), True)
                    blindplayer(str(target))
                else:
                    es.tell(
                        int(admin), "#green %s was not IP ghosting" %
                        (target.attributes["name"]))
            else:
                es.tell(
                    int(admin),
                    "#green XA will blind %s automatically if they are IP ghosting"
                    % (target.attributes["name"]))
        else:
            es.tell(
                int(admin),
                "#green Player %s could not be found" % (str(es.getargv(1))))
    else:
        es.dbgmsg(
            0,
            "Syntax: xa_blind_ghoster <steamid|userid> - blinds ghosting players till the end of the round"
        )
Exemplo n.º 45
0
def blind_con_com():
    '''
    Allows admins to blind via a console command
    '''
    if es.getargc() > 1:
        id = es.getuserid(es.getargv(1))
        admin = playerlib.getPlayer(es.getcmduserid())
        if id > 0:
            target = playerlib.getPlayer(id)
            if ghosting.setting.getVariable('blind_ghosters') == "0":
                # can only use this if auto blinding is OFF
                if checkplayer(int(target)):
                    es.msg("#green %s blinded %s till the end of the round for ghosting" % (admin.attributes["name"], target.attributes["name"]))
                    ghosting.logging.log("Admin (%s) blinded player %s for ghosting " % (admin.attributes["name"], target.attributes["name"]))
                    blindplayer(str(target))
                else:
                    es.tell(int(admin), "#green %s was not IP ghosting" % (target.attributes["name"]))
            else:
                es.tell(int(admin), "#green XA will blind %s automatically if they are IP ghosting" % (target.attributes["name"]))
        else:
            es.tell(int(admin), "#green Player %s could not be found" % (str(es.getargv(1))))
    else:
        es.dbgmsg(0, "Syntax: xa_blind_ghoster <steamid|userid> - blinds ghosting players till the end of the round")
Exemplo n.º 46
0
def removeidle_cmd():
    """
   xa_restrict_removeidle [weapon 1] [weapon 2] ... [weapon n]
   """
    arg_count = es.getargc()
    if arg_count > 1:
        weapons = getWeaponList(
            [es.getargv(x).lower() for x in range(1, arg_count)])
        if not weapons: raise IndexError, 'Invalid weapon list'

        removeidle(weapons)

    else:
        removeidle()
Exemplo n.º 47
0
def banExternal():
  callerId = es.getargv(1) # The admin's steam ID
  bannedSteamId = es.getargv(2)
  banReason = es.getargv(3)
  banLength = es.getargv(4)
  timeScale = es.getargv(5)
  nameOfBanned = es.getargv(6)

  banUser(callerId, bannedSteamId, banReason, banLength, timeScale, nameOfBanned)
def wcrm(args):
    userid = es.getargv(1)
    categories_on = es.ServerVar("wcs_racecategories")
    if categories_on == 1:
        if userid and es.exists("userid", userid):
            genCategoriesPop('categories_menu_%s' % userid, categories_handler,
                             userid)
        else:
            es.msg("#green", "Failed.")
    else:
        if userid and es.exists("userid", userid):
            genRacelistPop('changerace_menu_%s' % userid, changerace_handler,
                           userid)
        else:
            es.msg("#green", "Failed.")
Exemplo n.º 49
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")))
    else:
        userid = int(es.getcmduserid())
        if userid:
            es.tell(
                userid,
                "#multi",
                "#green[XA] #default",
                xalanguage("invalid map", {"mapname": mapname}, playerlib.getPlayer(userid).get("lang")),
            )
Exemplo n.º 50
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')))
    else:
        userid = int(es.getcmduserid())
        if userid:
            es.tell(
                userid, '#multi', '#green[XA] #default',
                xalanguage('invalid map', {'mapname': mapname},
                           playerlib.getPlayer(userid).get('lang')))
Exemplo n.º 51
0
def poweroff(userid, args):
    powerx = str(es.getargv(0))
    powerx = powerx.split('-')
    powerx = str(powerx[1])
    userid = str(es.getcmduserid())
    steamid = es.getplayersteamid(userid)
    if powerx == "power1":
        pid, ppowerx = cursor.execute('SELECT id, power1 FROM users WHERE id=?', (steamid,)).fetchone()
    elif powerx == "power2":
        pid, ppowerx = cursor.execute('SELECT id, power2 FROM users WHERE id=?', (steamid,)).fetchone()
    elif powerx == "power3":
        pid, ppowerx = cursor.execute('SELECT id, power3 FROM users WHERE id=?', (steamid,)).fetchone()
    if pid == steamid:
        cursor.execute('UPDATE users SET powerx=? WHERE id=?', (powerx, steamid))
        connection.commit()
        if str(ppowerx) != '0':
            es.server.queuecmd('es_xdoblock superhero/heroes/'+str(ppowerx)+'/poweroff')
Exemplo n.º 52
0
def poweroff(userid, args):
    powerx = str(es.getargv(0))
    powerx = powerx.split('-')
    powerx = str(powerx[1])
    userid = str(es.getcmduserid())
    steamid = es.getplayersteamid(userid)
    if powerx == "power1":
        pid, ppowerx = cursor.execute(
            'SELECT id, power1 FROM users WHERE id=?', (steamid, )).fetchone()
    elif powerx == "power2":
        pid, ppowerx = cursor.execute(
            'SELECT id, power2 FROM users WHERE id=?', (steamid, )).fetchone()
    elif powerx == "power3":
        pid, ppowerx = cursor.execute(
            'SELECT id, power3 FROM users WHERE id=?', (steamid, )).fetchone()
    if pid == steamid:
        cursor.execute('UPDATE users SET powerx=? WHERE id=?',
                       (powerx, steamid))
        connection.commit()
        if str(ppowerx) != '0':
            es.server.queuecmd('es_xdoblock superhero/heroes/' + str(ppowerx) +
                               '/poweroff')
Exemplo n.º 53
0
def _inputbox_handle():
    userid = es.getcmduserid()
    count = int(es.getargc())
    if count > 5:
        parent = es.getargv(1)
        if popuplib.exists(parent):
            module = es.getargv(2)
            if xa.exists(module):
                module = xa.find(module)
                keylist = langlist[str(module)]
                lang = es.getargv(3)
                key = es.getargv(4)
                if not key in keylist:
                    key = es.getargv(4).replace('+', ' ')
                if module and lang and key in keylist:
                    i = 5
                    newvalue = ''
                    while i < count:
                        newvalue = newvalue + ' ' + es.getargv(i)
                        i = i + 1
                    newvalue = newvalue.strip()
                    if newvalue:
                        language = cfglib.AddonINI(
                            "%s/modules/%s/strings.custom.ini" %
                            (xa.coredir(), module))
                        language.addValueToGroup(key, lang, newvalue, True)
                        language.write()
                        es.tell(
                            userid, '#green',
                            xalang('string warning',
                                   playerlib.getPlayer(userid).get('lang')))
                    else:
                        newvalue = langlist[str(module)](key, lang)
                    try:
                        langlist[str(module)] = module.language.getLanguage()
                    except IOError:
                        pass
                    es.esctextbox(
                        10, userid,
                        "Changed '" + str(keylist(key, lang)) + "' string",
                        "Changed '%s' to '%s'\nThe language menu is open again.\nPress [ESC] a second time."
                        % (keylist(key, lang), newvalue))
                    menu = _stringEditMenu(userid, module, key, parent)
                    menu.send(userid)
    else:
        es.esctextbox(10, userid, "Invalid Entry", "<string>")
Exemplo n.º 54
0
def saveConfig():
  global serverId, websiteAddy, banAppealMessage, hashCode, teachAdmins, clanName, allowAdminBanning
  # Arguments
  p_serverId = es.getargv(1)
  p_websiteAddy = es.getargv(2)
  p_banAppealMessage = es.getargv(3)
  p_hash = es.getargv(4)
  p_teachAdmins = es.getargv(5)
  p_clanName = es.getargv(6)
  p_allowAdminBanning = es.getargv(7)

  serverId = p_serverId
  websiteAddy = p_websiteAddy
  banAppealMessage = p_banAppealMessage
  hashCode = p_hash
  teachAdmins = int(p_teachAdmins)
  clanName = p_clanName
  allowAdminBanning = p_allowAdminBanning
  es.set("GlobalBan_Web", websiteAddy)

  # Open the GlobalBan.cfg file for writing
  cfg = open(es.getAddonPath('GlobalBan') + '/GlobalBan.cfg',"w")

  # Write the data to the cfg file
  cfg.write("serverId = " + p_serverId)
  cfg.write("\n")
  cfg.write("websiteAddy = \"" + p_websiteAddy + "\"")
  cfg.write("\n")
  cfg.write("banAppealMessage = \"" + p_banAppealMessage + "\"")
  cfg.write("\n")
  cfg.write("hash = \"" + p_hash + "\"")
  cfg.write("\n")
  cfg.write("teachAdmins = " + p_teachAdmins)
  cfg.write("\n")
  cfg.write("clanName = \"" + p_clanName + "\"")
  cfg.write("\n")
  cfg.write("allowAdminBanning = " + p_allowAdminBanning)

  # Close the file
  cfg.close()
Exemplo n.º 55
0
def uxp_reg(args_dummy):
    argc = es.getargc()
    if argc > 2:
        global uxpfuncs
        global funcs
        global regex1
        subcmd = es.getargv(1)
        if subcmd == 'create':
            if argc > 3:
                func = es.getargv(2)
                cmdstring = es.getargv(3)
                if func in funcs:
                    es.dbgmsg(0, 'uxp_reg : function already registered')
                elif not '%var' in cmdstring:
                    es.dbgmsg(
                        0, 'uxp_reg : %var MUST be included in command string')
                else:
                    uxpfuncs.append(func)
                    funcs[func] = {'uxp': cmdstring, 'minargs': 0}
                    funcsregex = '|'.join(funcs)
                    regex1 = re.compile(funcsregex)
            else:
                es.dbgmsg(
                    0, 'Syntax : uxp_reg create <function> <commandstring>')
        elif subcmd == 'delete':
            func = es.getargv(2)
            if func in uxpfuncs:
                del uxpfuncs[func]
                del funcs[func]
                funcsregex = '|'.join(funcs)
                regex1 = re.compile(funcsregex)
        elif subcmd == 'status':
            if argc > 3:
                var = es.getargv(2)
                func = es.getargv(3)
                if func in uxpfuncs:
                    es.set(var, '1')
                else:
                    es.set(var, '0')
            else:
                es.dbgmsg(0, 'Syntax : uxp_reg status <variable> <function>')
        else:
            es.dbgmsg(0, 'uxp_reg : invalid subcommand (create|delete|status)')
    else:
        es.dbgmsg(0, 'Syntax : uxp_reg <subcmd> <args>')
Exemplo n.º 56
0
def evaluate(args_dummy):
    global srcdsargs
    srcdsargs = []
    for arg in range(1, es.getargc()):
        srcdsargs.append(es.getargv(arg))
    srcdsargs = tuple(srcdsargs)