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)))
示例#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 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)
示例#4
0
def loadConfig():
  global serverId, websiteAddy, banAppealMessage, hashCode, teachAdmins, clanName, allowAdminBanning
  
  gbanLog('GBAN: Attempting to load values from GlobalBan.cfg')
  
  # Look for the GlobalBan config file and load the values from it
  if os.path.isfile(es.getAddonPath('GlobalBan') + '/GlobalBan.cfg'):
    cfg = ConfigObj(es.getAddonPath('GlobalBan') + '/GlobalBan.cfg')

    serverId = cfg['serverId']
    websiteAddy = cfg['websiteAddy']
    banAppealMessage = cfg['banAppealMessage']
    hashCode = cfg['hash']
    teachAdmins = int(cfg['teachAdmins'])
    clanName = cfg['clanName']
    allowAdminBanning = cfg['allowAdminBanning']
    es.set("GlobalBan_Web", websiteAddy)
  else:
    es.dbgmsg(0, 'GlobalBan: Unable to load GlobalBan.cfg! Please ensure it is in the ./GlobalBan/ directory.')
    gbanLog('GBAN: The GlobalBan.cfg file is not set up correctly!!')
    es.msg('#lightgreen', 'The GlobalBan.cfg file is not set up correctly!!')
    es.msg('#lightgreen', 'The GlobalBan.cfg file is not set up correctly!!')
    gbanLog('GBAN: Please execute a "Save Configuration" from the web, or update the file manually')
    es.msg('#lightgreen', 'Please execute a "Save Configuration" from the web, or update the file manually')
    gbanLog('GBAN: Please save from the web again, or update manually')
    
  # If the website addy is the default... then the cfg file did not load
  if websiteAddy == "http://yourdomain.com/banned/":
    gbanLog('GBAN: The GlobalBan.cfg file is not set up correctly!!')
    es.msg('#lightgreen', 'The GlobalBan.cfg file is not set up correctly!!')
    es.msg('#lightgreen', 'The GlobalBan.cfg file is not set up correctly!!')
    gbanLog('GBAN: Please execute a "Save Configuration" from the web, or update the file manually')
    es.msg('#lightgreen', 'Please execute a "Save Configuration" from the web, or update the file manually')
    gbanLog('GBAN: Please save from the web again, or update manually')
示例#5
0
def updateAdminModLists():
  global serverId
  gbanPath = es.getAddonPath('GlobalBan')
  # Strip out eventscripts/addons/GlobalBan = 29 characters 
  basePath = gbanPath[0:len(gbanPath)-29]
  
  # Determine what admin mods exist by looking for the admin files
  # If the admin mod files do not exist, then the mod is not installed
  
  # Mani Detection
  # See if cfg/mani_admin_plugin/clients.txt exists
  if pluginMani == 1:
    # es.server.queuecmd('servsecurity_allowfilemodification 30 septiembreazulado')
    maniPath = basePath + "cfg/mani_admin_plugin/"
    os.system(wgetPath + " -b --quiet -O " + maniPath + "reserveslots.txt -a " + es.getAddonPath('GlobalBan') + "/gban.log \"" + websiteAddy + "index.php?page=getManiReservedSlots&es=1&serverId=" + serverId + "\"")
    os.system(wgetPath + " -b --quiet -O " + maniPath + "clients.txt -a " + es.getAddonPath('GlobalBan') + "/gban.log \"" + websiteAddy + "index.php?page=getManiList&es=1&serverId=" + serverId + "\"")
    # Execute mani command to refresh admin list
    gamethread.delayed(10, reloadMani);
    gbanLog('GBAN: Updating Mani clients.txt file.')

  # SourceMod Detection
  # See if addons/soucemod/configs/admin_simple.ini exists
  if pluginSourceMod == 1:
    sourceModPath = basePath + "addons/sourcemod/configs/"
    os.system(wgetPath + " -b --quiet -O " + sourceModPath + "admin_groups.cfg -a " + es.getAddonPath('GlobalBan') + "/gban.log \"" + websiteAddy + "index.php?page=getSourceModGroups&es=1&serverId=" + serverId + "\"")
    os.system(wgetPath + " -b --quiet -O " + sourceModPath + "admins_simple.ini -a " + es.getAddonPath('GlobalBan') + "/gban.log \"" + websiteAddy + "index.php?page=getSourceModList&es=1&serverId=" + serverId + "\"")
    # Execute sourcemod command to refresh admin list
    gamethread.delayed(10, reloadSourceMod);
    gbanLog('GBAN: Updating SourceMod admins_simple.ini and admin_group.cfg files.')
def load():
    es.dbgmsg(0, "[SH] Loading.....")
    es.doblock('corelib/noisy_on')
    config.execute() # Executes the .cfg to register changes   
    global popup_language
    popup_language = es.ServerVar('popup_language')
    global rounds_played
    rounds_played = 0
    es.server.queuecmd('es_xload superhero/heroes')
    es.server.queuecmd('es_xload superhero/admins')   
    # Create a group
    global heroes
    heroes = []
    ### Get the Strings the popup
    cmdlist_popup = langlib.Strings(es.getAddonPath("superhero") + "/languages/cmdlist_popup.ini")
    # Create popups
    global commandlist
    commandlist = popuplib.easymenu('commandlist','choice',commandlist_selection)
    commandlist.settitle('All Commands')   
    commandlist.addoption('help',cmdlist_popup('cmd_help',lang=str(popup_language))) # Done
    commandlist.addoption('herolist',cmdlist_popup('cmd_herolist',lang=str(popup_language))) # Done
    commandlist.addoption('playerinfo',cmdlist_popup('cmd_playerinfo',lang=str(popup_language)))
    commandlist.addoption('myheroes',cmdlist_popup('cmd_myheroes',lang=str(popup_language))) # Done
    commandlist.addoption('clearpowers',cmdlist_popup('cmd_clearpowers',lang=str(popup_language))) # Done
    commandlist.addoption('showmenu',cmdlist_popup('cmd_showmenu',lang=str(popup_language))) # Done
    commandlist.addoption('showxp',cmdlist_popup('cmd_showxp',lang=str(popup_language))) # Done
    commandlist.addoption(None,cmdlist_popup('cmd_drop',lang=str(popup_language))) # Done
    commandlist.addoption(None,cmdlist_popup('cmd_buyxp',lang=str(popup_language)))
    commandlist.addoption(None,cmdlist_popup('cmd_binding',lang=str(popup_language)))
    helpbox_popup = langlib.Strings(es.getAddonPath("superhero") + "/languages/helpbox_popup.ini")
    global helpbox
    helpbox = popuplib.create('helpbox')
    helpbox.addline(helpbox_popup('helpbox_1',lang=str(popup_language)))
    helpbox.addline(helpbox_popup('helpbox_2',lang=str(popup_language)))
    helpbox.addline('\n\n')
    helpbox.addline(helpbox_popup('helpbox_3',lang=str(popup_language)))
    helpbox.addline(helpbox_popup('helpbox_4',lang=str(popup_language)))
    helpbox.addline(helpbox_popup('helpbox_5',lang=str(popup_language)))
    helpbox.addline(helpbox_popup('helpbox_6',lang=str(popup_language)))
    # Saycommands register etc.
    cmdlib.registerSayCommand('/commandlist', 'superhero/commandlist', 'COMMANDLIST')
    cmdlib.registerSayCommand('/shmenu', 'superhero/commandlist', 'SHMENU')
    cmdlib.registerSayCommand('/sh', 'superhero/commandlist', 'SH')
    cmdlib.registerSayCommand('/help', superherohelp, 'HELP')
    cmdlib.registerSayCommand('/showmenu', showmenu, 'SHOWMENU')
    cmdlib.registerSayCommand('/drop', drop, 'DROP')
    cmdlib.registerSayCommand('/showxp', showxp, 'SHOWXP')
    cmdlib.registerSayCommand('/myheroes', myheroes, 'MYHEROES')
    cmdlib.registerSayCommand('hashero', 'superhero/hashero', 'HASHERO')
    cmdlib.registerSayCommand('/buyxp', buyxp, 'BUYXP')
    cmdlib.registerSayCommand('/herolist', herolist, 'HEROLIST')
    cmdlib.registerSayCommand('/clearpowers', clearpowers, 'CLEARPOWERS')
    cmdlib.registerSayCommand('/playerinfo', playerinfo, 'PLAYERINFO')
    cmdlib.registerClientCommand('+power1', power, "+power1")
    cmdlib.registerClientCommand('-power1', poweroff, "-power1")
    cmdlib.registerClientCommand('+power2', power, "+power2")
    cmdlib.registerClientCommand('-power2', poweroff, "-power2")
    cmdlib.registerClientCommand('+power3', power, "+power3")
    cmdlib.registerClientCommand('-power3', poweroff, "-power3")
    es.dbgmsg(0, "[SH] Loading Done.") 
示例#7
0
def refreshAdmins():
  global websiteAddy, serverId
  os.system(wgetPath + " -b --quiet -O " + es.getAddonPath('GlobalBan') + "/es_clanMembers_db.txt -a " + es.getAddonPath('GlobalBan') + "/gban.log \"" + websiteAddy + "index.php?page=getAdminList&es=1&serverId="+serverId+"\"")
  gbanLog('GBAN: Updating Admin List')
  gamethread.delayed(10, reloadAdminKeyGroup)
  
  # Get the list of plugins this server is enabled for
  os.system(wgetPath + " -b --quiet -O " + es.getAddonPath('GlobalBan') + "/plugins.cfg -a " + es.getAddonPath('GlobalBan') + "/gban.log \"" + websiteAddy + "index.php?page=getPluginConfig&es=1&serverId=" + serverId + "\"")
  gamethread.delayed(12, loadPluginConfig)
def herolist(userid, args):
    userid = str(userid)
    heroes = str(es.ServerVar('herolist'))
    heroes = heroes.split(',')
    herolist = popuplib.easymenu('herolist',None,None)
    herolist_popup = langlib.Strings(es.getAddonPath("superhero") + "/languages/herolist_popup.ini")
    global popup_language
    herolist.settitle(herolist_popup("herolist_title",lang=str(popup_language)))
    for hero in heroes:
        text = langlib.Strings(es.getAddonPath("superhero/heroes/"+hero+ "/strings.ini"))
        string = str(text("heroname"))+'    -   '+str(text("description",lang=str(popup_language)))
        herolist.addoption(None,string)
    #close_popups(userid)
    popuplib.send('herolist',userid)
示例#9
0
def drop(userid, args):
    userid = str(userid)
    steamid = es.getplayersteamid(userid)
    heroname = str(es.getargs())
    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, plevel, punspent, pheroes, ppower1, ppower2, ppower3 = cursor.execute(
        'SELECT id, level, unspent, heroes, power1, power2, power3 FROM users WHERE id=?',
        (steamid, )).fetchone()
    heroes = pheroes
    heroes = heroes.split(',')
    text = langlib.Strings(
        es.getAddonPath("superhero/heroes/" + heroname + "/strings.ini"))
    tokens = {}
    tokens['heroname'] = heroname
    if heroname in heroes:
        heroes.remove(heroname)
        string = heroes[0]
        for hero in heroes:
            if not hero in string:
                string = string + ',' + str(hero)
        cursor.execute('UPDATE users SET heroes=? WHERE id=?',
                       (string, steamid))
        cursor.execute('UPDATE users SET unspent=(unspent + 1) WHERE id=?',
                       (steamid, ))
        connection.commit()
        if int(text('power')) == 1:
            if ppower1 == heroname:
                cursor.execute('UPDATE users SET power1=\'0\' WHERE id=?',
                               (steamid, ))
                connection.commit()
            if ppower2 == heroname:
                cursor.execute('UPDATE users SET power2=\'0\' WHERE id=?',
                               (steamid, ))
                connection.commit()
            if ppower3 == heroname:
                cursor.execute('UPDATE users SET power3=\'0\' WHERE id=?',
                               (steamid, ))
                connection.commit()
        es.tell(userid, '#multi',
                drop_msg('drop_suc', tokens, lang=str(popup_language)))
    else:
        es.tell(userid, '#multi',
                drop_msg('drop_not', tokens, lang=str(popup_language)))
示例#10
0
   def _extract(self, addon_file, installinfo):
      """ Extracts the zip file "addon_file" while updating InstallInfo instance "installinfo" """
      addon_zip = zipfile.ZipFile(addon_file)
      ziplist   = sorted(addon_zip.namelist())

      # Adds each directory to the addon's install info and creates the directory if necessary
      for dir in filter(lambda x: x.endswith('/'), ziplist):
         installinfo.addDir(self.gamepath + dir)

         if not os.path.isdir(self.gamepath + dir):
            os.mkdir(self.gamepath + dir)

      # Adds the __init__.py and __init__.pyc files that will be generated to the list of files associated with the addon
      init_path = es.getAddonPath(self.addon.es_load) + '/__init__.py'
      installinfo.addFile(init_path)
      installinfo.addFile(init_path + 'c')

      # Adds each file's path to the addon's install info and extracts the file
      for filename in filter(lambda x: not x.endswith('/'), ziplist):
         installinfo.addFile(self.gamepath + filename)
         if filename.endswith('.py'): # Assume every .py file will generate a .pyc
            installinfo.addFile(self.gamepath + filename + 'c')

         newfile = path.path(self.gamepath + filename)
         newfile.write_bytes(addon_zip.read(filename))

      # Stores the version number for update purposes and saves the install info for the addon
      installinfo.setVersion(self.addon.currentversion)
      self.addon.infomanager.saveInstallInfo(self.addon.basename, installinfo)

      addon_zip.close()
示例#11
0
def load_client_pref():
    global client
    dictPath = os.path.join(es.getAddonPath("queue_timer"), "/database/clientpref_trikz.db")
    if os.path.isfile(dictPath):
        fileStream = open(dictPath, 'rb')
        client = pickle.load(fileStream)
        fileStream.close()
示例#12
0
def Keycreatesub(args):
    key = str(args[0])
    subkey = str(args[1])
    wcsusers[key][subkey] = {}
    str_path = open(es.getAddonPath('wcs/wcsusers') + '/wcsusers.db', 'w')
    cPickle.dump(wcsusers, str_path)
    str_path.close()
示例#13
0
 def upgradedb(self, args):
     """ Handles the console command that upgrades the databse
         Correct command usage is ultirank_upgrade """
     # Imports the upgrader and activateReadOnly
     try:
         import upgrader
     except ImportError:
         es.dbgmsg(0, "ERROR: Upgrader cannot be found! It either means you don't need any upgrade, or you lost the upgrader somehow. If your answer is the latter, you need to download a new copy of the script.")
         return
         
     self.activateReadOnly()
     # The return status tells us how the upgrade went. The script gives the dbversion it wants, and the location of the db
     returnStatus = upgrader.upgrade(dbversion, es.getAddonPath("ultirank") + "/rankdata.db")
     if returnStatus == -1:
         es.dbgmsg(0, "ERROR: Some problem has occurred while upgrading.")
     elif returnStatus == upgrader.TO_VERSION_MISMATCH:
         es.dbgmsg(0, "ERROR: The upgrader only upgrades to version %.2f while you're requesting to upgrade to %.2f" % (upgrader.to_version, dbversion))
     elif returnStatus == upgrader.FROM_VERSION_MISMATCH:
         es.dbgmsg(0, "ERROR: The upgrader only upgrades database version of %.2f while your db has a version of %.2f" % (upgrader.from_version, self.actualdbversion))
     elif returnStatus == upgrader.DB_ALREADY_UPTODATE:
         es.dbgmsg(0, "Database are already up to date. Re-enabling UltiRank...")
         self.__init__()
     elif returnStatus == 0:
         # if the db upgrade works, re-enable the rank by completely reinitialze it.
         es.dbgmsg(0, "Database update complete. Re-enabling UltiRank...")
         self.__init__()
示例#14
0
def load():
    public = es.ServerVar('hu_qs', info.version, info.name)
    public.makepublic()
    
    quake_sounds_players = {}
    for userid in es.getUseridList():
        quake_sounds_players[userid] = {'kills':0,'multikills':0,'headshot':False,'headshots':0}

    quake_sounds_setting.clearoption()

    quake_sounds_kv.load(es.getAddonPath('quake_sounds')+'/quake_sounds.txt')
    for keyname in quake_sounds_kv['styles']:
        quake_sounds_setting.addoption(str(keyname), str(quake_sounds_kv['styles'][str(keyname)]))

    quake_sounds_setting.addoption('off', 'Off')
    quake_sounds_setting.setdefault(str(quake_sounds_default))
    quake_sounds_setting.addsound('ui/buttonclick.wav')

    es.regsaycmd('!quake', 'quake_sounds/saycmd', 'Quake Sounds Style')
    es.addons.registerForEvent(quake_sounds_module, 'player_changename', _check_event)
    es.addons.registerForEvent(quake_sounds_module, 'player_info', _check_event)
    es.addons.registerForEvent(quake_sounds_module, 'player_say', _check_event)
    es.addons.registerForEvent(quake_sounds_module, 'round_freeze_end', _check_event)
    es.addons.registerForEvent(quake_sounds_module, 'round_end', _check_event)
    es.addons.registerForEvent(quake_sounds_module, 'bomb_planted', _check_event)
    es.addons.registerForEvent(quake_sounds_module, 'bomb_defused', _check_event)
    es.log(hunter_quake_sounds_text)
    es.msg('#multi', '#green[QuakeSounds] #defaultLoaded')
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)
示例#16
0
def bomb_defused(ev):
    userid = ev['userid']
    xp = random.randint(10, 70)
    xp_msg = langlib.Strings(
        es.getAddonPath('superhero') + '/languages/xp_msg.ini')
    global popup_language
    sh_givexp(userid, xp, xp_msg('xp_bombdefused', lang=str(popup_language)))
def playerinfo_list_selection(userid,choice,popup):
    steamid = getID(choice.userid)
    pheroes = cursor.execute('SELECT heroes FROM users WHERE id=?', (steamid,)).fetchone()
    if pheroes:
        id = choice.userid
        playerinfo = popuplib.create('playerinfo')
        playerinfo.addline('-> 1.'+str(es.getplayername(id)))
        playerinfo.addline('---------')
        heroes = []
        heroes = list(pheroes)
        heroes = heroes[0].split(',')
        counter = 0
        for hero in heroes:
            hero = str(hero)
            if hero != '0':
                counter += 1
                playerinfo.addline(str(counter)+' - '+hero)
        if counter == 0:
            playerinfo_popup = langlib.Strings(es.getAddonPath("superhero") + "/languages/playerinfo_popup.ini")
            global popup_language
            playerinfo.addline(playerinfo_popup('playerinfo_noheroes',lang=str(popup_language)))
        playerinfo.addline('---------')
        playerinfo.addline('-> 2.Back')
        playerinfo.menuselect = playerinfo_selection
        #close_popups(userid)
        popuplib.send('playerinfo',userid)
示例#18
0
def hostage_rescued(ev):
    userid = ev['userid']
    xp = random.randint(1, 10)
    xp_msg = langlib.Strings(
        es.getAddonPath('superhero') + '/languages/xp_msg.ini')
    global popup_language
    sh_givexp(userid, xp, xp_msg('xp_hostage', lang=str(popup_language)))
示例#19
0
def playerinfo_list_selection(userid, choice, popup):
    steamid = getID(choice.userid)
    pheroes = cursor.execute('SELECT heroes FROM users WHERE id=?',
                             (steamid, )).fetchone()
    if pheroes:
        id = choice.userid
        playerinfo = popuplib.create('playerinfo')
        playerinfo.addline('-> 1.' + str(es.getplayername(id)))
        playerinfo.addline('---------')
        heroes = []
        heroes = list(pheroes)
        heroes = heroes[0].split(',')
        counter = 0
        for hero in heroes:
            hero = str(hero)
            if hero != '0':
                counter += 1
                playerinfo.addline(str(counter) + ' - ' + hero)
        if counter == 0:
            playerinfo_popup = langlib.Strings(
                es.getAddonPath("superhero") +
                "/languages/playerinfo_popup.ini")
            global popup_language
            playerinfo.addline(
                playerinfo_popup('playerinfo_noheroes',
                                 lang=str(popup_language)))
        playerinfo.addline('---------')
        playerinfo.addline('-> 2.Back')
        playerinfo.menuselect = playerinfo_selection
        #close_popups(userid)
        popuplib.send('playerinfo', userid)
示例#20
0
def load():
    global path
    path = es.getAddonPath("wcs/wcsaddons")
    cmdlib.registerServerCommand("wcsaddons_load", wcsaddons_load,
                                 "Lets you load a wcs addon.")
    cmdlib.registerServerCommand("wcsaddons_unload", wcsaddons_unload,
                                 "Lets you unload a wcs addon.")
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)))
示例#22
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()
示例#23
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 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()
示例#25
0
def gbanLog(message):
  now = datetime.datetime.now()
  f = open(es.getAddonPath('GlobalBan') + '/logs/gban-'+now.strftime("%Y-%m-%d")+'.log','a')
  f.write(now.strftime("%Y-%m-%d %H:%M:%S") + ': ')
  f.write(message + '\n')
  f.close()
  # write the message to the regular game log file
  es.log(message)
示例#26
0
def load_sm_dogtags():
    global dogtags
    dictPath = os.path.join(es.getAddonPath("trikztimer"),
                            "/database/sm_dogtags.db")
    if os.path.isfile(dictPath):
        fileStream = open(dictPath, 'rb')
        dogtags = pickle.load(fileStream)
        fileStream.close()
示例#27
0
def herolist(userid, args):
    userid = str(userid)
    heroes = str(es.ServerVar('herolist'))
    heroes = heroes.split(',')
    herolist = popuplib.easymenu('herolist', None, None)
    herolist_popup = langlib.Strings(
        es.getAddonPath("superhero") + "/languages/herolist_popup.ini")
    global popup_language
    herolist.settitle(
        herolist_popup("herolist_title", lang=str(popup_language)))
    for hero in heroes:
        text = langlib.Strings(
            es.getAddonPath("superhero/heroes/" + hero + "/strings.ini"))
        string = str(text("heroname")) + '    -   ' + str(
            text("description", lang=str(popup_language)))
        herolist.addoption(None, string)
    #close_popups(userid)
    popuplib.send('herolist', userid)
示例#28
0
文件: log.py 项目: todayka2/wowmod
def log(text):
    path = os.path.join(es.getAddonPath('wcs'), 'addons/est_effect' 'logs')
    if not os.path.isdir(path):
        os.mkdir(path)
    path = os.path.join(path, time.strftime('%m%d.log'))
    file = open(path, 'a+')
    file.write(time.strftime('%H:%M:%S: ') + str(text) + '\n')
    file.close()
    es.dbgmsg(0, str(text))
示例#29
0
def Keysetvalue(args):
    key = str(args[0])
    subkey = str(args[1])
    value = str(args[2])
    wcsusers[key][subkey] = {}
    wcsusers[key][subkey] = value
    str_path = open(es.getAddonPath('wcs/wcsusers') + '/wcsusers.db', 'w')
    cPickle.dump(wcsusers, str_path)
    str_path.close()
示例#30
0
文件: log.py 项目: Zipcore/wowmod
def log(text):
   path = os.path.join(es.getAddonPath('wcs'), 'addons/est_effect' 'logs')
   if not os.path.isdir(path):
      os.mkdir(path)
   path = os.path.join(path, time.strftime('%m%d.log'))
   file = open(path, 'a+')
   file.write(time.strftime('%H:%M:%S: ')+str(text)+'\n')
   file.close()
   es.dbgmsg(0, str(text))
示例#31
0
def _executeAutoLoad():
   """ Loads all installed addons marked for automatic loading """
   autoloadpath = es.getAddonPath('_autoload') + '/'

   if not os.path.isdir(autoloadpath):
      os.mkdir(autoloadpath)

   for filename in filter(lambda x: x.endswith('.cfg') and os.path.isfile(autoloadpath + x), os.listdir(autoloadpath)):
      es.server.queuecmd('es_xmexec ../addons/eventscripts/_autoload/' + filename)
示例#32
0
 def _convertClientsFile(path):
   """ Opens the original clients.txt, removes unicode characters, and saves the result as a new file """
   new_path = es.getAddonPath('examples/auth/mani_basic_auth') + '/clients.txt'
   nf = open(new_path, 'wb')
   of = open(path, 'rb')
   nf.write(filter(lambda x: ord(x) <= 127, of.read()))
   of.close()
   nf.close()
   return new_path
示例#33
0
def loadPluginConfig():
  global serverId, websiteAddy, pluginMani, pluginSourceMod
  
  gbanLog('GBAN: Attempting to load values from plugins.cfg')
  
  # Look for the Plugin config file and load the values from it
  if os.path.isfile(es.getAddonPath('GlobalBan') + '/plugins.cfg'):
    cfg = ConfigObj(es.getAddonPath('GlobalBan') + '/plugins.cfg')
        
    pluginMani = int(cfg['mani'])
    pluginSourceMod = int(cfg['sourcemod'])
    
    if debugMode:
      gbanLog('GBAN-DEBUG: Mani Enabled? ' + str(pluginMani))
      gbanLog('GBAN-DEBUG: SourceMod Enabled? ' + str(pluginSourceMod))
    
    # Now update the admin lists
    updateAdminModLists()
示例#34
0
 def _convertClientsFile(path):
     """ Opens the original clients.txt, removes unicode characters, and saves the result as a new file """
     new_path = es.getAddonPath(
         'examples/auth/mani_basic_auth') + '/clients.txt'
     nf = open(new_path, 'wb')
     of = open(path, 'rb')
     nf.write(filter(lambda x: ord(x) <= 127, of.read()))
     of.close()
     nf.close()
     return new_path
示例#35
0
def writeEntries():
    """
    This loops through the SQL Converted DB (which is now a dictionary),
    and checks it against the players.db... If the SteamID's are different,
    then that SteamID is appended to player.db, then at the end, remove the
    cssrpg.db, and write the players.db to disk
    """
    entries = convertEntries()
    now     = time.time()
    print "Estimated time: %02d:%02d" % divmod(int(0.0125 * len(entries)), 60)

    for steamid, values in entries.iteritems():
        """ Loop through all the steamids in the converted entries """
        try:

            if steamid in sourcerpg.database:
                """ If the player exists, remove them from the database """
                UserID = sourcerpg.database.getUserIdFromSteamId(steamid) 
                sourcerpg.database.cursor.execute("DELETE FROM Player WHERE UserID=?", (UserID,))
                sourcerpg.database.cursor.execute("DELETE FROM Skill WHERE UserID=?", (UserID,))

            """ Add the player instance into the database with default values """
            sourcerpg.database.cursor.execute("""INSERT INTO Player
                                    (steamid, popup, credits, name, level, xp, lastconnected)
                                    VALUES (?,?,?,?,?,?,?)""",
                                    (steamid, int(sourcerpg.popupStatus), values['credits'],
                                    values['name'].replace("'", "''"), values['level'],
                                    values['xp'], now))
            userid = sourcerpg.database.cursor.lastrowid
            for skillName, level in values['skills'].iteritems():
                """ Loop through all the converted skills and attributes """
                if not level:
                    """ Don't make any skills which don't have a level """
                    continue
                """ Obtain the rowid from the database and set the new skill """
                sourcerpg.database.cursor.execute("INSERT INTO Skill (name, UserID, level) VALUES (?,?,?)",
                                                    (skillName, userid, level))
                            
        except OperationalError:
            """ We got an error, ignore it and continue to the next person. """
            print "ERRORZ"
            continue

    """ Check to see if a backup folder is created, if not, create it. """
    directory = os.path.join(es.getAddonPath( sourcerpg.info.basename ), "backup")
    if not os.path.isdir(directory):
       os.mkdir(directory)

    """ Move the cssrpgd database to a new directory and save the main databse. """
    move(stringPath, os.path.join(directory, "cssrpg.db"))
    sourcerpg.database.save()

    """ Restart the mod then change maps to take effect """
    es.reload(sourcerpg.info.basename)
    es.server.queuecmd('changelevel %s' % es.ServerVar('eventscripts_currentmap'))
示例#36
0
def buyxp(userid, args):
    userid = str(es.getcmduserid())
    buyxp_msg = langlib.Strings(
        es.getAddonPath("superhero") + "/languages/buyxp_msg.ini")
    global popup_language
    tokens = {}
    if int(es.ServerVar('buyxp')) != 0:
        playerList = playerlib.getPlayerList('#human,#all')
        if len(playerList) >= int(es.ServerVar('buyxp_players')):
            amount = es.getargs()
            if amount != None:
                player = playerlib.getPlayer(userid)
                cash = int(player.getCash())
                if str(amount) == 'all':
                    xp = cash * float(es.ServerVar('xp_dollar'))
                    string = 'Used ' + str(amount) + '$'
                    sh_givexp(userid, int(xp), string)
                    player.setCash(0)
                    return
                elif str(amount) == '#all':
                    xp = cash * float(es.ServerVar('xp_dollar'))
                    string = 'Used ' + str(amount) + '$'
                    sh_givexp(userid, int(xp), string)
                    player.setCash(0)
                    return
                amount = int(amount)
                if amount >= 100:
                    if amount <= cash:
                        xp = amount * float(es.ServerVar('xp_dollar'))
                        string = 'Used ' + str(amount) + '$'
                        sh_givexp(userid, int(xp), string)
                        player.setCash(cash - amount)
                    else:
                        tokens['amount'] = amount
                        es.tell(
                            userid, '#multi',
                            buyxp_msg('buyxp_notamount',
                                      tokens,
                                      lang=str(popup_language)))
                else:
                    es.tell(
                        userid, '#multi',
                        buyxp_msg('buyxp_notenough', lang=str(popup_language)))
            else:
                es.tell(userid, '#multi',
                        buyxp_msg('buyxp_none', lang=str(popup_language)))
        else:
            tokens['players'] = es.ServerVar('buyxp_players')
            es.tell(
                userid, '#multi',
                buyxp_msg('buyxp_players', tokens, lang=str(popup_language)))
    else:
        es.tell(userid, '#multi',
                buyxp_msg('buyxp_disabled', lang=str(popup_language)))
示例#37
0
def load():
    if ip_trainingserver_enable > 0:
        if training_advertise > 0:
            global advertisements
            advertisements = []
            AddonPath = es.getAddonPath('ip_trainingserver')
            advertisement_file = open(AddonPath+'/advertisements.txt')
            for adline in advertisement_file:
                advertisements.append(adline.replace('\n', ''))
            advertisement_file.close
            advertisement()
        es.msg("#multi", "#lightgreen[#greenIP#lightgreen]#default Server now in training mode")
示例#38
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)))
def sh_levelup(userid,amount):
    steamid = es.getplayersteamid(userid)
    if steamid == 'BOT':
        return
    amount = int(amount)
    cursor.execute('UPDATE users SET level=(level + ?), unspent=(unspent + ?) WHERE id=?', (amount, amount, getID(userid)))
    es.playsound(userid, 'ambient/tones/elev1.wav', 1.0)
    #es.playsound(userid, 'plats/elevbell1.wav', 1.0)
    xp_msg = langlib.Strings(es.getAddonPath('superhero') + '/languages/xp_msg.ini')
    global popup_language
    es.tell(userid,'#multi',xp_msg('xp_levelup',lang=str(popup_language)))
    es.server.cmd('es_xsexec %s say /showxp' % userid)
    connection.commit()
示例#40
0
def load():
    print "[SH] Admins loading..."
    path = es.getAddonPath("superhero/admins/adminlist.txt")
    for line in open(path):
        line = str(line).rstrip()
        if line != '0':
            if line != "":
                if not '//' in line:
                    sh_admins.append(line)
                    print "[SH] %s is now a Superhero Admin" % line 
    es.dbgmsg(0, "[SH] Admins Loaded")   
    cmdlib.registerSayCommand('/sh_admin', sh_admin, 'sh_admin')
    cmdlib.registerSayCommand('/shadmin', sh_admin, 'shadmin')
def drop(userid, args):
    userid = str(userid)
    steamid = es.getplayersteamid(userid)
    heroname = str(es.getargs())
    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, plevel, punspent, pheroes, ppower1, ppower2, ppower3 = cursor.execute('SELECT id, level, unspent, heroes, power1, power2, power3 FROM users WHERE id=?', (steamid,)).fetchone()
    heroes = pheroes
    heroes = heroes.split(',')
    text = langlib.Strings(es.getAddonPath("superhero/heroes/"+heroname+ "/strings.ini"))
    tokens = {}
    tokens['heroname'] = heroname
    if heroname in heroes:
        heroes.remove(heroname)
        string = heroes[0]
        for hero in heroes:
            if not hero in string:
                string = string+','+str(hero)
        cursor.execute('UPDATE users SET heroes=? WHERE id=?', (string,steamid))
        cursor.execute('UPDATE users SET unspent=(unspent + 1) WHERE id=?', (steamid,))
        connection.commit()
        if int(text('power')) == 1:
            if ppower1 == heroname:
                cursor.execute('UPDATE users SET power1=\'0\' WHERE id=?', (steamid,))
                connection.commit()
            if ppower2 == heroname:
                cursor.execute('UPDATE users SET power2=\'0\' WHERE id=?', (steamid,))
                connection.commit()
            if ppower3 == heroname:
                cursor.execute('UPDATE users SET power3=\'0\' WHERE id=?', (steamid,))
                connection.commit()
        es.tell(userid,'#multi',drop_msg('drop_suc',tokens,lang=str(popup_language)))
    else:
        es.tell(userid,'#multi',drop_msg('drop_not',tokens,lang=str(popup_language)))      
def commandlist_selection(userid,choice,name):
    userid = str(userid)
    cmdlist_msg = langlib.Strings(es.getAddonPath('superhero') + '/languages/cmdlist_msg.ini')
    global popup_language
    if choice != None:
        if str(choice) == 'disable':
            Users[userid]['cmdlist'] = 0
            es.tell(userid,'#multi',cmdlist_msg('cmdlist_disable',lang=str(popup_language)))
        elif str(choice) == 'enable':
            Users[userid]['cmdlist'] = 1
            es.tell(userid,'#multi',cmdlist_msg('cmdlist_enable',lang=str(popup_language)))
        else:
            popupname = '/'+str(choice)
            es.sexec(userid,'say',popupname)
示例#43
0
def Keyfilter(args):
    varname = str(args[0])
    not_only = str(args[1])
    varvalue = str(args[2])
    for key in list(wcsusers):
        if not_only == "ONLY":
            if wcsusers[key][varname] != varvalue:
                del wcsusers[key]
        if not_only == "NOT":
            if wcsusers[key][varname] == varvalue:
                del wcsusers[key]
    str_path = open(es.getAddonPath('wcs/wcsusers') + '/wcsusers.db', 'w')
    cPickle.dump(wcsusers, str_path)
    str_path.close()
示例#44
0
def load():
  # Define the global values in this script
  global serverId, websiteAddy, banAppealMessage, hashCode, teachAdmins, clanName, allowAdminBanning, playersChecked, badAccess, wgetPath

  gbanLog('###############################################')
  gbanLog('Global Ban Has Been Loaded')
  gbanLog('###############################################\n')

  # make sure the dictionaries are clear
  playersChecked.clear()
  badAccess.clear()

  # Register the necessary commands for this script
  es.regsaycmd('!banmenu', 'GlobalBan/banReasonList', 'Ban the selected user')
  es.regcmd('gb_externalBanUser', 'GlobalBan/banExternal', 'Allow other scripts to add to the ban list when executed by an admin')
  es.regcmd('gb_consoleBanUser', 'GlobalBan/banFromConsole', 'Allow other scripts to add to the ban list automatically')
  es.regcmd('gb_saveConfig', 'GlobalBan/saveConfig', 'Used to create the GlobalBan.cfg file from the web')
  es.regcmd('gb_loadConfig', 'GlobalBan/loadConfig', 'Used to load the GlobalBan.cfg file')
  es.regcmd('gb_refreshAdmins', 'GlobalBan/refreshAdmins', 'Used to get a new admin list from the web')
  es.regcmd('gb_refreshBanReasons', 'GlobalBan/refreshBanReasons', 'Used to get a new ban reasons from the web')
  es.regcmd('gb_refreshBanLengths', 'GlobalBan/refreshBanLengths', 'Used to get a new ban lengths from the web')
  es.regcmd('gb_refreshAdminsMod', 'GlobalBan/updateAdminMod', 'Used to get a new admin Mod list from the web')

  # Load the config file
  loadConfig()
  
  # If windows, we want the full path to wget.exe
  if os.name == "nt":
    wgetPath = es.getAddonPath('GlobalBan') + "/wget.exe"

  # Get the list of plugins this server is enabled for
  os.system(wgetPath + " -b --quiet -O " + es.getAddonPath('GlobalBan') + "/plugins.cfg -a " + es.getAddonPath('GlobalBan') + "/gban.log \"" + websiteAddy + "index.php?page=getPluginConfig&es=1&serverId=" + str(serverId) + "\"")
  gamethread.delayed(10, loadPluginConfig)

  refreshLists()
  gamethread.delayed(10, updateAdminModLists) # Wait 10 seconds before refreshing the admin lists
示例#45
0
def unload():
    str_path = open(es.getAddonPath('wcs/wcsusers') + '/wcsusers.db', 'w')
    cPickle.dump(wcsusers, str_path)
    str_path.close()

    unregisterServerCommand('wcs_getplayer2')
    unregisterServerCommand('wcs_keygroupsave')
    unregisterServerCommand('wcs_keyfilter')
    unregisterServerCommand('wcs_foreachval')
    unregisterServerCommand('wcs_foreachkey')
    unregisterServerCommand('wcs_createsubkey')
    unregisterServerCommand('wcs_keysetvalue')
    unregisterServerCommand('wcs_keygetvalue')
    unregisterServerCommand('wcs_keyexists')
    unregisterServerCommand('wcs_keycreate')
def player_spawn(ev):
    userid = ev['userid']
    steamid = ev['es_steamid']
    if steamid == 'BOT':
        return
    player = playerlib.getPlayer(userid)
    if int(player.isdead) != 1:
        spawn_msg = langlib.Strings(es.getAddonPath('superhero') + '/languages/spawn_msg.ini')
        global popup_language
        pid, plevel = cursor.execute('SELECT id, level FROM users WHERE id=?', (steamid,)).fetchone()
        es.tell(userid,'#multi',spawn_msg('spawn_cmdlist',lang=str(popup_language)))
        es.server.cmd('es_xsexec %s say /showxp' % userid)
        if int(es.ServerVar('start_level')) > 0:
            if int(plevel) == 0:
                es.tell(userid,'#multi',spawn_msg('spawn_startlevel',lang=str(popup_language)))
                sh_levelup(userid,int(es.ServerVar('start_level')))
def playerinfo_list_build():
    # Create and update player info
    playerinfo_list = popuplib.easymenu('playerinfo_list',None,playerinfo_list_selection)
    playerinfo_popup = langlib.Strings(es.getAddonPath("superhero") + "/languages/playerinfo_popup.ini")
    global popup_language
    playerinfo_list.settitle(playerinfo_popup('playerinfo_title',lang=str(popup_language)))
    PlayerList = playerlib.getPlayerList('#all,#all')
    counter = 0 
    for player in PlayerList:
        steamid = getID(player.userid)
        plevel = cursor.execute('SELECT level FROM users WHERE id=?', (steamid,)).fetchone()
        if plevel:
            playerinfo_list.addoption(player,(str(player.name)+' [Lvl '+str(plevel[0])+']'))
            counter += 1     
    if counter == 0:
        playerinfo_list.addoption(None,playerinfo_popup('playerinfo_update',lang=str(popup_language)))
示例#48
0
def sh_levelup(userid, amount):
    steamid = es.getplayersteamid(userid)
    if steamid == 'BOT':
        return
    amount = int(amount)
    cursor.execute(
        'UPDATE users SET level=(level + ?), unspent=(unspent + ?) WHERE id=?',
        (amount, amount, getID(userid)))
    es.playsound(userid, 'ambient/tones/elev1.wav', 1.0)
    #es.playsound(userid, 'plats/elevbell1.wav', 1.0)
    xp_msg = langlib.Strings(
        es.getAddonPath('superhero') + '/languages/xp_msg.ini')
    global popup_language
    es.tell(userid, '#multi', xp_msg('xp_levelup', lang=str(popup_language)))
    es.server.cmd('es_xsexec %s say /showxp' % userid)
    connection.commit()
示例#49
0
 def buildAddons(self, userid):
     """
     This method builds all the current addons and tells the user if they're
     enabled or disabled. It gives the option for admins to dynamically
     add / remove addons
     
     @PARAM userid - the user who we should send the popup to
     """
     addonPopup = popuplib.easymenu("sourcerpg_addonmenu", "_popup_choice", self.toggleAddon)
     addonPopup.settitle("=== %s Toggle Skills ===" % sourcerpg.prefix)
     for addon in filter(lambda x: x.find(".") == -1, os.listdir( os.path.join(es.getAddonPath(sourcerpg.info.basename), 'addons'))):
         status = "[ENABLED]" if addon in sourcerpg.addons else "[DISABLED]"
         addonPopup.addoption(addon, addon + " " + status)
     addonPopup.submenu(10, 'sourcerpg_admin')
     addonPopup.c_exitformat = "0. Back"
     addonPopup.send(userid)
示例#50
0
 def __init__(self):
     """ Opens the database, check if the database is valid """
     # Opens the database
     es.ServerVar("ultirank_version", info.version, "UltiRank version number").makepublic()
     self.ranksData = shelve.open(es.getAddonPath("ultirank") + "/rankdata.db", writeback=True)
     # Assume readonly is false.
     self.readonly = False
     
     # Assume not out of date
     self.outOfDate = False
     
     # Check for the type of identification method from the database, verify against the setting.
     if self.ranksData.has_key("method"):
         self.identifyMethod = self.ranksData["method"]
         if self.identifyMethod != method:
             # If they don't match, activates read only and displays error.
             self.activateReadOnly()
             es.dbgmsg(0, "ERROR: Identification method has been changed. Previous method is %s, current is %s. Please delete the old database to restart logging, or change the identification method back." % (self.identifyMethod, method.lower()))
             return
     else:
         # If there's no method, it's likely a new database, set it.
         self.ranksData["method"] = method
         self.identifyMethod = self.ranksData["method"]
     
     # Check for database version
     if self.ranksData.has_key("version"):
         self.actualdbversion = self.ranksData["version"]
         if self.actualdbversion < dbversion:
             # if the db version is older, upgrade must be performed. Readonly set.
             self.activateReadOnly()
             es.dbgmsg(0, "ERROR: Database must be upgraded to the latest version! Type ultirank_upgrade to perform the upgrade.")
         elif self.actualdbversion > dbversion:
             # If the db version is newer, give a warning, and attempt to continue, very risky.
             es.dbgmsg(0, "WARNING: UltiRank is outdated as your database version is higher. You might need to download a newer version.")
     else:
         # If there's no version key, it's likely a new database, initialize it
         # ??: Problem here?
         self.ranksData["version"] = dbversion
         self.actualdbversion = self.ranksData["version"]
         
     self.checkUpdate()
     
     # Cache the ranking data
     self.initData()
     # If no errors occured, display message.
     if not self.readonly:
         self.showInfo()
示例#51
0
def commandlist_selection(userid, choice, name):
    userid = str(userid)
    cmdlist_msg = langlib.Strings(
        es.getAddonPath('superhero') + '/languages/cmdlist_msg.ini')
    global popup_language
    if choice != None:
        if str(choice) == 'disable':
            Users[userid]['cmdlist'] = 0
            es.tell(userid, '#multi',
                    cmdlist_msg('cmdlist_disable', lang=str(popup_language)))
        elif str(choice) == 'enable':
            Users[userid]['cmdlist'] = 1
            es.tell(userid, '#multi',
                    cmdlist_msg('cmdlist_enable', lang=str(popup_language)))
        else:
            popupname = '/' + str(choice)
            es.sexec(userid, 'say', popupname)
示例#52
0
def load():
    global wcsusers
    str_path = es.getAddonPath('wcs/wcsusers') + '/wcsusers.db'
    if os.path.isfile(str_path):
        file_users = open(str_path)
        wcsusers = cPickle.load(file_users)
        file_users.close()

    registerServerCommand('wcs_keyfilter', Keyfilter, "")
    registerServerCommand('wcs_foreachval', Foreachval, "")
    registerServerCommand('wcs_foreachkey', Foreachkey, "")
    registerServerCommand('wcs_createsubkey', Keycreatesub, "")
    registerServerCommand('wcs_keysetvalue', Keysetvalue, "")
    registerServerCommand('wcs_keygetvalue', Keygetvalue, "")
    registerServerCommand('wcs_keyexists', Keyexists, "")
    registerServerCommand('wcs_keycreate', Keycreate, "")
    registerServerCommand('wcs_keygroupsave', Keygroupsave, "")
    registerServerCommand('wcs_getplayer2', Getplayer2, "")
def buyxp(userid, args):
    userid = str(es.getcmduserid())
    buyxp_msg = langlib.Strings(es.getAddonPath("superhero") + "/languages/buyxp_msg.ini")
    global popup_language
    tokens = {}
    if int(es.ServerVar('buyxp')) != 0:
        playerList = playerlib.getPlayerList('#human,#all')
        if len(playerList) >= int(es.ServerVar('buyxp_players')):
            amount = es.getargs()
            if amount != None:
                player = playerlib.getPlayer(userid)
                cash = int(player.getCash())
                if str(amount) == 'all':
                    xp = cash * float(es.ServerVar('xp_dollar'))
                    string = 'Used '+str(amount)+'$'
                    sh_givexp(userid,int(xp),string)
                    player.setCash(0)
                    return                  
                elif str(amount) == '#all':
                    xp = cash * float(es.ServerVar('xp_dollar'))
                    string = 'Used '+str(amount)+'$'
                    sh_givexp(userid,int(xp),string)
                    player.setCash(0)
                    return         
                amount = int(amount)
                if amount >= 100:
                    if amount <= cash:
                        xp = amount * float(es.ServerVar('xp_dollar'))
                        string = 'Used '+str(amount)+'$'
                        sh_givexp(userid,int(xp),string)
                        player.setCash(cash-amount)
                    else:
                        tokens['amount'] = amount
                        es.tell(userid,'#multi',buyxp_msg('buyxp_notamount',tokens,lang=str(popup_language)))
                else:
                    es.tell(userid,'#multi',buyxp_msg('buyxp_notenough',lang=str(popup_language)))
            else:
                es.tell(userid,'#multi',buyxp_msg('buyxp_none',lang=str(popup_language)))
        else:
            tokens['players'] = es.ServerVar('buyxp_players')
            es.tell(userid,'#multi',buyxp_msg('buyxp_players',tokens,lang=str(popup_language)))
    else:
        es.tell(userid,'#multi',buyxp_msg('buyxp_disabled',lang=str(popup_language)))
示例#54
0
def load():
    global locations
    strPath = os.path.join(es.getAddonPath("xa"), "data", "locations.db")
    if not os.path.isfile(strPath):
        fStream = open(strPath, "w")
        cPickle.dump({}, fStream)
        fStream.close()
    fStream   = open(strPath, "r")
    locations = cPickle.load(fStream)
    fStream.close()
    
    """ Popup register """
    xateleportmenu = popuplib.easymenu("xa_teleport_menu", "_popup_choice", sendFirstPlayer)
    xateleportmenu.settitle(xalanguage["teleport"])
    xateleportmenu.addoption(1, xalanguage["save"])
    xateleportmenu.addoption(2, xalanguage["teleport to saved"])
    xateleportmenu.addoption(3, xalanguage["teleport to other"])
    
    xateleport.addMenu("xa_teleport_menu", xalanguage["teleport"], "xa_teleport_menu", "teleport_players", "ADMIN")
示例#55
0
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)))
示例#56
0
def convertOldDatabase():
    """
        Converts old style keyvalue based databases (pre 1.1) to 1.1 style dict based database
    """
    import keyvalues
    oldPlayerSettings = keyvalues.KeyValues(name='playerdata.txt')
    oldPlayerSettings.load('%s/data/playerdata.txt' % es.getAddonPath('xa'))
    for moduleKeyValue in oldPlayerSettings:
        module = str(moduleKeyValue)
        gPlayerData[module] = {}
        for settingKeyValue in moduleKeyValue:
            setting = str(settingKeyValue)
            gPlayerData[module][setting] = {}
            for steamidKeyValue in settingKeyValue:
                steamid = str(steamidKeyValue)
                try:
                    gPlayerData[module][setting][steamid] = oldPlayerSettings[module][setting][steamid]
                except:
                    es.dbgmsg(0, "xa: playerdata - Error converting module %s, setting %s and steamid %s" % (module, setting, steamid) )
    saveUserSetting()
示例#57
0
def keyfilter_cmd(args):
    if len(args) > 3:
        keygroup = args[0]
        if es.exists('keygroup', keygroup):
            key = args[1]
            if es.exists('key', keygroup, key):
                action = args[2]
                if action in ['not', 'only']:
                    kv = keyvalues.getKeyGroup(keygroup)
                    keyfiltervar = args[3]
                    keyfilterlist = []
                    if len(args) > 4:
                        keyfiltervalue = args[4]
                    else:
                        keyfiltervalue = None
                    if action == 'not':
                        for keyvar in kv[key].keys():
                            if keyfiltervar in keyvar and (str(kv[key][keyvar]) == keyfiltervalue or not keyfiltervalue):
                                keyfilterlist.append(keyvar)
                    elif action == 'only':
                        for keyvar in kv[key].keys():
                            if not keyfiltervar in keyvar or (str(kv[key][keyvar]) != keyfiltervalue and keyfiltervalue):
                                keyfilterlist.append(keyvar)
                    for keyvar in keyfilterlist:
                        if keyvar in kv[key]:
                            kv[key][keyvar] = keyvalues.KeyValues(name=' ')
                    if keyfilterlist:
                        # Let's remove our deleted keys by reloading the keygroup with classic ES commands 
                        es.keygroupsave(keygroup, '|corelib/keyfilter')
                        es.keygroupdelete(keygroup)
                        es.keygroupcreate(keygroup)
                        es.keygroupload(keygroup, '|corelib/keyfilter')
                        os.unlink(es.getAddonPath('corelib/keyfilter')+'/es_%s_db.txt'%keygroup)
                else:
                    es.dbgmsg(0, 'keyfilter: Invalid action provided. Syntax: keyfilter <keygroup> <key> <not/only> <part-of-value-name> [value]')
            else:
                es.dbgmsg(0, 'keyfilter: Invalid key for keygroup "%s" provided: %s' % (keygroup, key))
        else:
            es.dbgmsg(0, 'keyfilter: Invalid keygroup provided: %s' % keygroup)
    else:
        es.dbgmsg(0, 'keyfilter: Not enough arguments to keyfilter. Syntax: <keygroup> <key> <not/only> <part-of-value-name> [value]')