コード例 #1
0
ファイル: xateleport.py プロジェクト: StarsGame/source_addons
def sendSecondMenu(userid, choice, popupid):
    oldChoice, target = choice
    if oldChoice == 2:
        steamid           = playerlib.uniqueid(userid, False)
        lang              = playerlib.getPlayer(userid).get("lang")
        if steamid not in locations:
            es.tell(userid, "#green", xalanguage("no locations", {}, lang) )
            return
        currentMap = str(es.ServerVar('eventscripts_currentmap'))
        if currentMap not in locations[steamid]:
            es.tell(userid, "#green", xalanguage("no map locations", {}, lang) )
            return
        if es.getplayerprop(target, 'CBasePlayer.pl.deadflag'):
            es.tell(userid, xalanguage('one player died', {}, playerlib.getPlayer(userid).get("lang") ) )
            return
        x, y, z = locations[steamid][currentMap]
        es.server.queuecmd('es_xsetpos %s %s %s %s' % (target, x, y, z + 10) )
        if not int(xa_anonymous):
            args           = {}
            args["player"] = es.getplayername(target)
            args["admin"]  = es.getplayername(userid)
            for player in playerlib.getPlayerList("#all"):
                es.tell(int(player), xalanguage("teleport to location", args, player.get("lang") ) )
        xateleport.logging.log("has teleported user %s [%s] to their saved location" % (es.getplayername(target), es.getplayersteamid(target)), userid)
    else:
        lang = playerlib.getPlayer(userid).get("lang")
        popupMenu = popuplib.easymenu("xa_teleport_players", "_popup_choice", teleportPlayerToPlayer)
        popupMenu.settitle(xalanguage["player select to send to"])
        for player in filter(lambda x: not es.getplayerprop(x, "CBasePlayer.pl.deadflag"), es.getUseridList()):
            popupMenu.addoption([target, player], es.getplayername(player), lang=lang)
        popupMenu.send(userid)
コード例 #2
0
ファイル: __init__.py プロジェクト: fizek/source_addons
def player_activate(event_var):
    userid = int(event_var['userid'])
    steamid = playerlib.uniqueid(userid, True)
    for setting in gSettings:
        if not steamid in gSettings[setting].keyvalues['users']:
            gSettings[setting].initUser(userid)
        gSettings[setting].updateTime(userid)
コード例 #3
0
 def set(self, key, userid=None):
     option = self.isValidOption(key)
     if option:
         if userid:
             steamid = playerlib.uniqueid(userid, True)
             if steamid:
                 if not steamid in self.keyvalues['users']:
                     self.initUser(int(userid))
                 for thisoption in list(
                         self.keyvalues['users'][steamid]['data'].keys()):
                     if thisoption == option:
                         self.keyvalues['users'][steamid]['data'][
                             thisoption]['state'] = 1
                     else:
                         self.keyvalues['users'][steamid]['data'][
                             thisoption]['state'] = 0
             else:
                 raise IndexError(
                     f'Settinglib: Cannot find userid {userid}')
         else:
             for thisoption in list(self.keyvalues['options'].keys()):
                 if thisoption == option:
                     self.keyvalues['options'][thisoption]['globstate'] = 1
                 else:
                     self.keyvalues['options'][thisoption]['globstate'] = 0
     else:
         raise IndexError(
             f'Settinglib: Cannot set option {key}, it does not exists')
コード例 #4
0
 def send(self, pUsers, prio=False, locked=False):
     try:
         # try if pUsers is just a single userid
         userid = int(pUsers)
         pUsers = [userid]
     except TypeError:
         pass
     if locked:
         optionstate = 0
     else:
         optionstate = 1
     for userid in pUsers:
         player = playerlib.getPlayer(userid)
         if player:
             steamid = playerlib.uniqueid(userid, True)
             helpline = self.languages('setting '+self.keyvalues['config']['type']+' help', (), player.get('lang'))
             self.popup[userid] = popuplib.easymenu('_setting_%s_user%s' % (self.name, userid), '_setting_choice', settinglib._submit)
             self.popup[userid].settingid = self.name
             self.popup[userid].c_titleformat = self.keyvalues['config']['descr'] + (' '*(30-len(self.keyvalues['config']['descr']))) + ' (%p/%t)\n' + helpline
             if not steamid in self.keyvalues['users']:
                 self.initUser(userid)
             for option in self.keyvalues['options']:
                 display = self.keyvalues['options'][option]['display']
                 userdata = self.keyvalues['users'][steamid]['data']
                 if option in userdata:
                     if userdata[option]['state']:
                         active = self.languages('setting list active', (), player.get('lang'))
                         self.popup[userid].addoption(int(option), display + ' ('+active+')', optionstate)
                         continue
                 self.popup[userid].addoption(int(option), display, optionstate)
             if self.backmenuvar:
                 self.popup[userid].submenu(10, self.backmenuvar)
             self.popup[userid].send(userid, prio)
コード例 #5
0
def sendFirstPlayer(userid, choice, popupid):
    if 3 < choice < 10:
        xateleportmenu.send(userid)
    if choice == 1:
        steamid = playerlib.uniqueid(userid, False)
        if steamid not in locations:
            locations[steamid] = {}
        locations[steamid][str(es.ServerVar(
            'eventscripts_currentmap'))] = es.getplayerlocation(userid)
        lang = playerlib.getPlayer(userid).get("lang")
        saveDatabase()
        es.tell(userid, "#green", xalanguage("location saved", {}, lang))
        xateleport.logging.log(
            "has updated their saved teleport location for map %s" %
            str(es.ServerVar('eventscripts_currentmap')), userid, True)
    elif 4 > choice > 1:
        lang = playerlib.getPlayer(userid).get("lang")
        popupMenu = popuplib.easymenu("xa_teleport_players", "_popup_choice",
                                      sendSecondMenu)
        popupMenu.settitle(xalanguage["player select"])
        for player in filter(
                lambda x: not es.getplayerprop(x, "CBasePlayer.pl.deadflag"),
                es.getUseridList()):
            popupMenu.addoption([choice, player],
                                es.getplayername(player),
                                lang=lang)
        popupMenu.send(userid)
コード例 #6
0
ファイル: __init__.py プロジェクト: StarsGame/source_addons
 def updateTime(self, userid):
     if es.exists('userid',userid):
         steamid = playerlib.uniqueid(userid, True)
         if steamid in self.keyvalues['users']:
             self.keyvalues['users'][steamid]['time'] = int(time.time())
         else:
             self.initUser(userid)
コード例 #7
0
ファイル: list.py プロジェクト: Ayuto/EventScripts-Emulator
 def send(self, pUsers, prio=False, locked=False):
     try:
         # try if pUsers is just a single userid
         userid = int(pUsers)
         pUsers = [userid]
     except TypeError:
         pass
     if locked:
         optionstate = 0
     else:
         optionstate = 1
     for userid in pUsers:
         player = playerlib.getPlayer(userid)
         if player:
             steamid = playerlib.uniqueid(userid, True)
             menuname = '_setting_%s_user%s' % (self.name, userid)
             helpline = self.languages('setting '+self.keyvalues['config']['type']+' help', (), player.get('lang'))
             if not popuplib.active(userid)['name'] == menuname and not popuplib.isqueued(menuname, userid) or prio:
                 self.popup[userid] = popuplib.easymenu(menuname, '_setting_choice', settinglib._submit)
                 self.popup[userid].settingid = self.name
                 self.popup[userid].c_titleformat = self.keyvalues['config']['descr'] + (' '*(30-len(self.keyvalues['config']['descr']))) + ' (%p/%t)\n' + helpline
                 if not steamid in self.keyvalues['users']:
                     self.initUser(userid)
                 for option in list(self.keyvalues['options'].keys()):
                     display = self.keyvalues['options'][option]['display']
                     userdata = self.keyvalues['users'][steamid]['data']
                     if option in userdata:
                         if userdata[option]['state']:
                             active = self.languages('setting list active', (), player.get('lang'))
                             self.popup[userid].addoption(option, display + ' ('+active+')', optionstate)
                             continue
                     self.popup[userid].addoption(option, display, optionstate)
                 if self.backmenuvar:
                     self.popup[userid].submenu(10, self.backmenuvar)
                 self.popup[userid].send(userid, prio)
コード例 #8
0
ファイル: __init__.py プロジェクト: StarsGame/source_addons
def player_activate(event_var):
    userid = int(event_var['userid'])
    steamid = playerlib.uniqueid(userid, True)
    for setting in gSettings:
        if not steamid in gSettings[setting].keyvalues['users']:
            gSettings[setting].initUser(userid)
        gSettings[setting].updateTime(userid)
コード例 #9
0
ファイル: __init__.py プロジェクト: fizek/source_addons
 def updateTime(self, userid):
     if es.exists('userid', userid):
         steamid = playerlib.uniqueid(userid, True)
         if steamid in self.keyvalues['users']:
             self.keyvalues['users'][steamid]['time'] = int(time.time())
         else:
             self.initUser(userid)
コード例 #10
0
def sendSecondMenu(userid, choice, popupid):
    oldChoice, target = choice
    if oldChoice == 2:
        steamid           = playerlib.uniqueid(userid, False)
        lang              = playerlib.getPlayer(userid).get("lang")
        if steamid not in locations:
            es.tell(userid, "#green", xalanguage("no locations", {}, lang) )
            return
        currentMap = str(es.ServerVar('eventscripts_currentmap'))
        if currentMap not in locations[steamid]:
            es.tell(userid, "#green", xalanguage("no map locations", {}, lang) )
            return
        if es.getplayerprop(target, 'CBasePlayer.pl.deadflag'):
            es.tell(userid, xalanguage('one player died', {}, playerlib.getPlayer(userid).get("lang") ) )
            return
        x, y, z = locations[steamid][currentMap]
        es.server.queuecmd('es_xsetpos %s %s %s %s' % (target, x, y, z + 10) )
        if not int(xa_anonymous):
            args           = {}
            args["player"] = es.getplayername(target)
            args["admin"]  = es.getplayername(userid)
            for player in playerlib.getPlayerList("#all"):
                es.tell(int(player), xalanguage("teleport to location", args, player.get("lang") ) )
        xateleport.logging.log("has teleported user %s [%s] to their saved location" % (es.getplayername(target), es.getplayersteamid(target)), userid)
    else:
        lang = playerlib.getPlayer(userid).get("lang")
        popupMenu = popuplib.easymenu("xa_teleport_players", "_popup_choice", teleportPlayerToPlayer)
        popupMenu.settitle(xalanguage["player select to send to"])
        for player in filter(lambda x: not es.getplayerprop(x, "CBasePlayer.pl.deadflag"), es.getUseridList()):
            popupMenu.addoption([target, player], es.getplayername(player), lang=lang)
        popupMenu.send(userid)
コード例 #11
0
ファイル: toggle.py プロジェクト: fizek/source_addons
 def set(self, option, state=None, userid=None):
     arg = option
     option = self.isValidOption(option)
     if option:
         if userid:
             steamid = playerlib.uniqueid(userid, True)
             if steamid:
                 if not steamid in self.keyvalues['users']:
                     self.initUser(int(userid))
                 if state:
                     self.keyvalues['users'][steamid]['data'][option][
                         'state'] = 1
                 else:
                     self.keyvalues['users'][steamid]['data'][option][
                         'state'] = 0
             else:
                 raise IndexError('Settinglib: Cannot find userid %s' %
                                  userid)
         else:
             if state:
                 self.keyvalues['options'][option]['globstate'] = 1
             else:
                 self.keyvalues['options'][option]['globstate'] = 0
     else:
         raise IndexError(
             'Settinglib: Cannot set option #%s, it does not exists' % arg)
コード例 #12
0
ファイル: __init__.py プロジェクト: StarsGame/source_addons
 def initUser(self, userid):
     if es.exists('userid',userid):
         steamid = playerlib.uniqueid(userid, True)
         self.keyvalues['users'][steamid] = self.createKey(steamid)
         self.keyvalues['users'][steamid]['time'] = int(time.time())
         self.keyvalues['users'][steamid]['data'] = self.createKey('data')
         for option in self.keyvalues['options']:
             self.keyvalues['users'][steamid]['data'][option] = self.createKey(option)
             self.keyvalues['users'][steamid]['data'][option]['state'] = self.keyvalues['options'][option]['state']
コード例 #13
0
ファイル: playerdata.py プロジェクト: StarsGame/source_addons
 def get(self, userid):
     if es.exists("userid", userid):
         steamid = playerlib.uniqueid(userid, True)
         if steamid in gKeyValues[self.module][self.name]:
             return gKeyValues[self.module][self.name][steamid]
         else:
             return False
     else:
         return False
コード例 #14
0
 def get(self, userid):
     if es.exists("userid", userid):
         steamid = playerlib.uniqueid(userid, True)
         if steamid in gKeyValues[self.module][self.name]:
             return gKeyValues[self.module][self.name][steamid]
         else:
             return False
     else:
         return False
コード例 #15
0
ファイル: playerdata.py プロジェクト: StarsGame/source_addons
 def set(self, userid, value):
     if es.exists("userid", userid):
         steamid = playerlib.uniqueid(userid, True)
         gKeyValues[self.module][self.name][steamid] = value
         if gKeyValues[self.module][self.name][steamid] == value:
             return True
         else:
             return False
     else:
         return False
コード例 #16
0
 def set(self, userid, value):
     if es.exists("userid", userid):
         steamid = playerlib.uniqueid(userid, True)
         gKeyValues[self.module][self.name][steamid] = value
         if gKeyValues[self.module][self.name][steamid] == value:
             return True
         else:
             return False
     else:
         return False
コード例 #17
0
def uniqueid_cmd(args):
    ''' Console command to return the uniqueid for a player or a bot.
        If you want the bot's actual name, provide the final optional parameter.
        uniqueid <var> <userid> [add botname]'''
    if len(args) in (2, 3):
        returnvar = es.ServerVar(args[0])
        # get the uniqueid, telling it to append botname if the final arg is given
        id = playerlib.uniqueid(userid=args[1], botname=(args[2] if len(args) == 3 else None))
        returnvar.set(id)
    else:
        es.dbgmsg(0, 'Syntax: uniqueid <var> <userid> [add botname]')
コード例 #18
0
ファイル: __init__.py プロジェクト: fizek/source_addons
 def initUser(self, userid):
     if es.exists('userid', userid):
         steamid = playerlib.uniqueid(userid, True)
         self.keyvalues['users'][steamid] = self.createKey(steamid)
         self.keyvalues['users'][steamid]['time'] = int(time.time())
         self.keyvalues['users'][steamid]['data'] = self.createKey('data')
         for option in self.keyvalues['options']:
             self.keyvalues['users'][steamid]['data'][
                 option] = self.createKey(option)
             self.keyvalues['users'][steamid]['data'][option][
                 'state'] = self.keyvalues['options'][option]['state']
コード例 #19
0
ファイル: __init__.py プロジェクト: StarsGame/source_addons
 def getvar(self, variable, userid=None):
     if userid:
         if es.exists('userid',userid):
             steamid = playerlib.uniqueid(userid, True)
             if not steamid in self.keyvalues['users']:
                 self.initUser(int(userid))
         else:
             raise IndexError('Settinglib: Cannot find userid %s, it does not exists'%userid)
     else:
         steamid = 'global'
     return self.keyvalues['variables'][steamid][variable]
コード例 #20
0
    def get(self, userid):
        """
            Get the set value for an individual player
        """
        # Check if our user's setting has a value
        if self.exists(userid):
            # Get the userid's uniqueid
            steamid = playerlib.uniqueid(userid, True)

            # Return the user's setting value
            return gPlayerData[self.module][self.name][steamid]
        return None
コード例 #21
0
 def set(self, userid, value):
     """
         Set the setting value for an individual player
     """
     # Get the userid's uniqueid
     steamid = playerlib.uniqueid(userid, True)
     
     # Set the user's setting to the new value
     gPlayerData[self.module][self.name][steamid] = value
     
     # Return if our user's setting has the new value
     return gPlayerData[self.module][self.name][steamid] == value
コード例 #22
0
ファイル: __init__.py プロジェクト: fizek/source_addons
 def getvar(self, variable, userid=None):
     if userid:
         if es.exists('userid', userid):
             steamid = playerlib.uniqueid(userid, True)
             if not steamid in self.keyvalues['users']:
                 self.initUser(int(userid))
         else:
             raise IndexError(
                 'Settinglib: Cannot find userid %s, it does not exists' %
                 userid)
     else:
         steamid = 'global'
     return self.keyvalues['variables'][steamid][variable]
コード例 #23
0
ファイル: list.py プロジェクト: StarsGame/source_addons
 def get(self, userid=None):
     if userid:
         steamid = playerlib.uniqueid(userid, True)
         if steamid:
             if not steamid in self.keyvalues["users"]:
                 self.initUser(userid)
             for thisoption in self.keyvalues["users"][steamid]["data"]:
                 if self.keyvalues["users"][steamid]["data"][thisoption]["state"]:
                     return self.keyvalues["options"][thisoption]["keyname"]
         else:
             raise IndexError("Settinglib: Cannot find userid %s" % option)
     else:
         for thisoption in self.keyvalues["options"]:
             if self.keyvalues["options"][thisoption]["globstate"]:
                 return self.keyvalues["options"][thisoption]["keyname"]
コード例 #24
0
 def get(self, userid=None):
     if userid:
         steamid = playerlib.uniqueid(userid, True)
         if steamid:
             if not steamid in self.keyvalues['users']:
                 self.initUser(userid)
             for thisoption in self.keyvalues['users'][steamid]['data']:
                 if self.keyvalues['users'][steamid]['data'][thisoption]['state']:
                     return self.keyvalues['options'][thisoption]['keyname']
         else:
             raise IndexError('Settinglib: Cannot find userid %s'%option)
     else:
         for thisoption in self.keyvalues['options']:
             if self.keyvalues['options'][thisoption]['globstate']:
                 return self.keyvalues['options'][thisoption]['keyname']
コード例 #25
0
ファイル: list.py プロジェクト: Ayuto/EventScripts-Emulator
 def get(self, userid=None):
     if userid:
         steamid = playerlib.uniqueid(userid, True)
         if steamid:
             if not steamid in self.keyvalues['users']:
                 self.initUser(userid)
             for thisoption in list(self.keyvalues['users'][steamid]['data'].keys()):
                 if self.keyvalues['users'][steamid]['data'][thisoption]['state']:
                     return self.keyvalues['options'][thisoption]['keyname']
         else:
             raise IndexError(f'Settinglib: Cannot find userid {option}')
     else:
         for thisoption in list(self.keyvalues['options'].keys()):
             if self.keyvalues['options'][thisoption]['globstate']:
                 return self.keyvalues['options'][thisoption]['keyname']
コード例 #26
0
 def set(self, key, state=None, userid=None):
     option = self.isValidOption(key)
     if option:
         if userid:
             steamid = playerlib.uniqueid(userid, True)
             if steamid:
                 if not steamid in self.keyvalues['users']:
                     self.initUser(int(userid))
                 self.keyvalues['users'][steamid]['data'][option]['state'] = 1 if state else 0
             else:
                 raise IndexError('Settinglib: Cannot find userid %s'%userid)
         else:
             self.keyvalues['options'][option]['globstate'] = 1 if state else 0
     else:
         raise IndexError('Settinglib: Cannot set option %s, it does not exists'%key)
コード例 #27
0
ファイル: toggle.py プロジェクト: Ayuto/EventScripts-Emulator
 def get(self, key, userid=None):
     option = self.isValidOption(key)
     if option:
         if userid:
             steamid = playerlib.uniqueid(userid, True)
             if steamid:
                 if not steamid in self.keyvalues['users']:
                     self.initUser(int(userid))
                 try:
                     return bool(self.keyvalues['users'][steamid]['data'][option]['state'])
                 except KeyError:
                     return bool(self.keyvalues['options'][option]['state'])
             else:
                 raise IndexError(f'Settinglib: Cannot find userid {userid}')
         else:
             return bool(self.keyvalues['options'][option]['globstate'])
     else:
         raise IndexError(f'Settinglib: Cannot get option {key}, it does not exists')
コード例 #28
0
ファイル: xateleport.py プロジェクト: StarsGame/source_addons
def sendFirstPlayer(userid, choice, popupid):
    if 3 < choice < 10:
        xateleportmenu.send(userid)
    if choice == 1:
        steamid = playerlib.uniqueid(userid, False)
        if steamid not in locations:
            locations[steamid] = {}
        locations[steamid][str(es.ServerVar('eventscripts_currentmap'))] = es.getplayerlocation(userid)
        lang    = playerlib.getPlayer(userid).get("lang")
        saveDatabase()
        es.tell(userid, "#green", xalanguage("location saved", {}, lang) )
    elif 4 > choice > 1:
        lang = playerlib.getPlayer(userid).get("lang")
        popupMenu = popuplib.easymenu("xa_teleport_players", "_popup_choice", sendSecondMenu)
        popupMenu.settitle(xalanguage["player select"])
        for player in filter(lambda x: not es.getplayerprop(x, "CBasePlayer.pl.deadflag"), es.getUseridList()):
            popupMenu.addoption([choice, player], es.getplayername(player), lang=lang)
        popupMenu.send(userid)
コード例 #29
0
def clearUsersSettings(module, value = None):
    """ 
        Clear all user settings for a specific player
    """
    if value == None:
        value = module
    if es.exists('userid', value):
        steamid = playerlib.uniqueid(value, True)
    else:
        steamid = value
    modulesToRemove = {}
    for module in gPlayerData:
        for name in gPlayerData[module]:
            if steamid in gPlayerData[module][name]:
                modulesToRemove[module] = name
    for module, name in modulesToRemove.iteritems():
        del gPlayerData[module][name][steamid]
    saveUserSetting()
コード例 #30
0
ファイル: toggle.py プロジェクト: StarsGame/source_addons
 def send(self, pUsers, prio=False, locked=False):
     try:
         # try if pUsers is just a single userid
         userid = int(pUsers)
         pUsers = [userid]
     except TypeError:
         pass
     if locked:
         optionstate = 0
     else:
         optionstate = 1
     for userid in pUsers:
         player = playerlib.getPlayer(userid)
         if player:
             steamid = playerlib.uniqueid(userid, True)
             helpline = self.languages(
                 "setting " + self.keyvalues["config"]["type"] + " help", (), player.get("lang")
             )
             self.popup[userid] = popuplib.easymenu(
                 "_setting_%s_user%s" % (self.name, userid), "_setting_choice", settinglib._submit
             )
             self.popup[userid].settingid = self.name
             self.popup[userid].c_titleformat = (
                 self.keyvalues["config"]["descr"]
                 + (" " * (30 - len(self.keyvalues["config"]["descr"])))
                 + " (%p/%t)\n"
                 + helpline
             )
             if not steamid in self.keyvalues["users"]:
                 self.initUser(userid)
             for option in self.keyvalues["options"]:
                 display = self.keyvalues["options"][option]["display"]
                 userdata = self.keyvalues["users"][steamid]["data"]
                 if option in userdata:
                     if userdata[option]["state"]:
                         active = self.languages("setting toggle on", (), player.get("lang"))
                         self.popup[userid].addoption(int(option), display + " (" + active + ")", optionstate)
                         continue
                 active = self.languages("setting toggle off", (), player.get("lang"))
                 self.popup[userid].addoption(int(option), display + " (" + active + ")", optionstate)
             if self.backmenuvar:
                 self.popup[userid].submenu(10, self.backmenuvar)
             self.popup[userid].send(userid, prio)
コード例 #31
0
ファイル: toggle.py プロジェクト: StarsGame/source_addons
 def get(self, option=None, userid=None):
     arg = option
     option = self.isValidOption(option)
     if option:
         if userid:
             steamid = playerlib.uniqueid(userid, True)
             if steamid:
                 if not steamid in self.keyvalues["users"]:
                     self.initUser(int(userid))
                 try:
                     result = bool(self.keyvalues["users"][steamid]["data"][option]["state"])
                 except KeyError:
                     result = bool(self.keyvalues["options"][option]["state"])
                 return result
             else:
                 raise IndexError("Settinglib: Cannot find userid %s" % userid)
         else:
             return bool(self.keyvalues["options"][option]["globstate"])
     else:
         raise IndexError("Settinglib: Cannot get option #%s, it does not exists" % arg)
コード例 #32
0
 def get(self, key, userid=None):
     option = self.isValidOption(key)
     if option:
         if userid:
             steamid = playerlib.uniqueid(userid, True)
             if steamid:
                 if not steamid in self.keyvalues['users']:
                     self.initUser(int(userid))
                 try:
                     return bool(self.keyvalues['users'][steamid]['data']
                                 [option]['state'])
                 except KeyError:
                     return bool(self.keyvalues['options'][option]['state'])
             else:
                 raise IndexError(
                     f'Settinglib: Cannot find userid {userid}')
         else:
             return bool(self.keyvalues['options'][option]['globstate'])
     else:
         raise IndexError(
             f'Settinglib: Cannot get option {key}, it does not exists')
コード例 #33
0
ファイル: toggle.py プロジェクト: StarsGame/source_addons
 def set(self, option, state=None, userid=None):
     arg = option
     option = self.isValidOption(option)
     if option:
         if userid:
             steamid = playerlib.uniqueid(userid, True)
             if steamid:
                 if not steamid in self.keyvalues["users"]:
                     self.initUser(int(userid))
                 if state:
                     self.keyvalues["users"][steamid]["data"][option]["state"] = 1
                 else:
                     self.keyvalues["users"][steamid]["data"][option]["state"] = 0
             else:
                 raise IndexError("Settinglib: Cannot find userid %s" % userid)
         else:
             if state:
                 self.keyvalues["options"][option]["globstate"] = 1
             else:
                 self.keyvalues["options"][option]["globstate"] = 0
     else:
         raise IndexError("Settinglib: Cannot set option #%s, it does not exists" % arg)
コード例 #34
0
ファイル: list.py プロジェクト: Ayuto/EventScripts-Emulator
 def set(self, key, userid=None):
     option = self.isValidOption(key)
     if option:
         if userid:
             steamid = playerlib.uniqueid(userid, True)
             if steamid:
                 if not steamid in self.keyvalues['users']:
                     self.initUser(int(userid))
                 for thisoption in list(self.keyvalues['users'][steamid]['data'].keys()):
                     if thisoption == option:
                         self.keyvalues['users'][steamid]['data'][thisoption]['state'] = 1
                     else:
                         self.keyvalues['users'][steamid]['data'][thisoption]['state'] = 0
             else:
                 raise IndexError(f'Settinglib: Cannot find userid {userid}')
         else:
             for thisoption in list(self.keyvalues['options'].keys()):
                 if thisoption == option:
                     self.keyvalues['options'][thisoption]['globstate'] = 1
                 else:
                     self.keyvalues['options'][thisoption]['globstate'] = 0
     else:
         raise IndexError(f'Settinglib: Cannot set option {key}, it does not exists')
コード例 #35
0
ファイル: toggle.py プロジェクト: fizek/source_addons
 def get(self, option=None, userid=None):
     arg = option
     option = self.isValidOption(option)
     if option:
         if userid:
             steamid = playerlib.uniqueid(userid, True)
             if steamid:
                 if not steamid in self.keyvalues['users']:
                     self.initUser(int(userid))
                 try:
                     result = bool(self.keyvalues['users'][steamid]['data']
                                   [option]['state'])
                 except KeyError:
                     result = bool(
                         self.keyvalues['options'][option]['state'])
                 return result
             else:
                 raise IndexError('Settinglib: Cannot find userid %s' %
                                  userid)
         else:
             return bool(self.keyvalues['options'][option]['globstate'])
     else:
         raise IndexError(
             'Settinglib: Cannot get option #%s, it does not exists' % arg)
コード例 #36
0
 def exists(self, userid):
     # Get the userid's uniqueid
     steamid = playerlib.uniqueid(userid, True)
     
     # Return if our user's setting has a value
     return steamid in gPlayerData[self.module][self.name]