Beispiel #1
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()
def wcs_ulti_roots():
	userid = int(es.ServerVar('wcs_userid'))
	count = 0

	if es.getplayerteam(userid) >= 2:
		if playerlib.getUseridList('#alive'):
			usermsg.fade(userid, 0, 1, 1, 10, 55, 5, 200)
			x,y,z = es.getplayerlocation(userid)
			radius = float(es.ServerVar('wcs_radius'))
			time = float(es.ServerVar('wcs_freezetime'))

			for user in playerlib.getUseridList('#alive,#'+['ct','t'][es.getplayerteam(userid)-2]):
				x1,y1,z1 = es.getplayerlocation(user)

				if ((x1 - x) ** 2 + (y1 - y) ** 2 + (z1 - z) ** 2) ** 0.5 <= radius:
					#check for wall between...

					if not tools.wcsgroup.wcsgroup.getUser(user, 'ulti_immunity'):
						playerlib.getPlayer(user).freeze = 1
						gamethread.delayed(time, reset, (user, 'freeze', 0))
						count += 1

					else:
						es.tell(user, '#multi', '#lightgreenYour ultimate was blocked, the enemy is #greenimmune.')
						es.tell(userid, '#multi', '#lightgreenYou #greenblocked #lightgreenan ultimate skill.')

	if count:
		es.centertell('Entangling Roots: %s' % (count))
	else:
		es.tell(userid, '#multi','#lightgreenEntangling Roots #greenfailed#lightgreen, because no enemy is close enough.')
		es.server.queuecmd('es wcs_reset_cooldown %s' % (userid))
def wcs_ulti_chain():
	userid = int(es.ServerVar('wcs_userid'))
	count = 0

	if es.getplayerteam(userid) >= 2:
		if playerlib.getUseridList('#alive'):
			usermsg.fade(userid, 0, 2, 1, 240, 240, 240, 100)
			x,y,z = es.getplayerlocation(userid)
			radius = float(es.ServerVar('wcs_radius'))
			es.ServerVar('vector1').set(','.join(map(str, (x,y,z))))

			for user in playerlib.getUseridList('#alive,#'+['ct','t'][es.getplayerteam(userid)-2]):
				x1,y1,z1 = es.getplayerlocation(user)

				if ((x1 - x) ** 2 + (y1 - y) ** 2 + (z1 - z) ** 2) ** 0.5 <= radius:
					#check for wall between...

					if not tools.wcsgroup.wcsgroup.getUser(user, 'ulti_immunity'):
						tools.expand.expand.damage(user, 32, userid)
						count += 1

						if es.ServerVar('wcs_cfg_graphicfx'):
							es.server.insertcmd('es_xset vector2 '+','.join(map(str, (x1,y1,z1)))+';es_xdoblock wcs/addons/effect/ChainLightning')

					else:
						es.tell(user, '#multi', '#lightgreenYour ultimate was blocked, the enemy is #greenimmune.')
						es.tell(userid, '#multi', '#lightgreenYou #greenblocked #lightgreenan ultimate skill.')

	if count:
		es.centertell('Chain Lightning: %s players damaged' % (count))
	else:
		es.tell(userid, '#multi', '#lightgreenChain Lightning #greenfailed#lightgreen, because no enemy is close enough to be damaged.')
		es.server.queuecmd('es wcs_reset_cooldown %s' % (userid))
Beispiel #4
0
def healingwarden():
    userid = str(es.ServerVar('wcs_userid'))
    count = int(wcsgroup.getUser(userid, 'ability_count'))

    if count:
        param = str(wcsgroup.getUser(userid, 'ability_parameter'))

        if param:
            param = param.split('_')
            team = int(es.getplayerteam(userid))

            if team == 2:
                teamtarget = '2'
                teamtargetn = '#t'
                color = '255 0 10 150'

            elif team == 3:
                teamtarget = '3'
                teamtargetn = '#ct'
                color = '10 0 255 150'

            x, y, z = es.getplayerlocation(userid)
            es.server.queuecmd('wcs_healingwarden ' + userid + ' ' + param[0] +
                               ' ' + param[1] + ' ' + param[2] + ' ' +
                               teamtarget + ' ' + teamtargetn + ' ' + str(x) +
                               ' ' + str(y) + ' ' + str(z) + ' ' +
                               str(es.ServerVar('wcs_roundcounter')))

            tell(userid, 'a_wardencreated')

        if count and not count == -1:
            wcsgroup.setUser(userid, 'ability_count', count - 1)

    else:
        tell(userid, 'a_failed')
Beispiel #5
0
def es_map_start(event_var):
    global map_list
    global startTime
    global round_count
    mapfilename = str(es.ServerVar('eventscripts_gamedir')).replace(
        '\\', '/') + '/' + str(vote_map_file)
    if os.path.exists(mapfilename):
        map_file = open(mapfilename, 'r')
        map_list = filter(
            lambda x: False
            if x == '' or x.startswith('//') else os.path.isfile(
                str(es.ServerVar('eventscripts_gamedir')).replace('\\', '/') +
                '/maps/%s.bsp' % x),
            map(lambda x: x.replace('\n', ''), map_file.readlines()))
        map_file.close()
    else:
        es.dbgmsg(
            0,
            "xavote.py: Note: Cannot find maplist file '" + mapfilename + "'")

    gamethread.cancelDelayed('votemap_timer')
    round_count = {}
    round_count['round_counting'] = 0
    round_count['t_wins'] = 0
    round_count['c_wins'] = 0
    round_count['frag_kills'] = 0
    startTime = time.time()
    if int(time_before_end_of_map_vote):
        gamethread.delayed(10, DelayTimer)
    previousMaps.append(event_var['mapname'])
    if len(previousMaps) and len(previousMaps) > int(ignore_last_map_amount):
        previousMaps.remove(previousMaps[0])
Beispiel #6
0
def Keyexists(args):
    buffer = str(args[0])
    key = str(args[1])
    if wcsusers.has_key(key):
        es.ServerVar(buffer).set('1')
    else:
        es.ServerVar(buffer).set('0')
Beispiel #7
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)
Beispiel #8
0
def wcs_ulti_roots():
    userid = int(es.ServerVar('wcs_userid'))
    player = Player.from_userid(userid)
    if player.team >= 2:
        count = 0
        wcs_commands.fade(userid, 10, 55, 5, 200, 1)
        radius = float(es.ServerVar('wcs_radius'))
        time = float(es.ServerVar('wcs_duration'))
        atk_origin = player.origin
        for play in PlayerIter('alive'):
            if play.team != player.team:
                vic_origin = play.origin
                if vic_origin.get_distance(atk_origin) <= radius:
                    if not wcsgroup.getUser(play.userid, 'ulti_immunity'):
                        play.move_type = MoveType.NONE
                        count += 1
                        Delay(time, remove_freeze, (play, ))
                        es.emitsound('player', play.userid, 'wcs/root.wav',
                                     1.0, 0.6)
                        queue_command_string(
                            'es est_effect_06 #a 0 sprites/laser.vmt "%s,%s,%s" "%s,%s,%s" 10 1 5 5 10 4 0 160 0 155 2'
                            %
                            (atk_origin[0], atk_origin[1], atk_origin[2] + 35,
                             vic_origin[0], vic_origin[1], vic_origin[2] + 35))
                        queue_command_string(
                            'es est_effect_06 #a 0 sprites/laser.vmt "%s,%s,%s" "%s,%s,%s" 10 1 4 4 10 2 0 108 0 180 2'
                            %
                            (atk_origin[0], atk_origin[1], atk_origin[2] + 35,
                             vic_origin[0], vic_origin[1], vic_origin[2] + 35))
                        queue_command_string(
                            'es est_effect_06 #a 0 sprites/laser.vmt "%s,%s,%s" "%s,%s,%s" 10 1 5 5 10 4 0 80 0 190 2'
                            %
                            (atk_origin[0], atk_origin[1], atk_origin[2] + 35,
                             vic_origin[0], vic_origin[1], vic_origin[2] + 35))
                        queue_command_string(
                            'es est_effect 10 #a 0 sprites/laser.vmt %s %s %s 60 20 1 3 3 5 0 80 0 155 0 255 2'
                            %
                            (vic_origin[0], vic_origin[1], vic_origin[2] + 10))
                        queue_command_string(
                            'es est_effect 10 #a 0 sprites/laser.vmt %s %s %s 75 35 1 3 3 6 0 108 0 190 0 255 2'
                            %
                            (vic_origin[0], vic_origin[1], vic_origin[2] + 25))
                    else:
                        es.tell(
                            player.userid, '#multi',
                            '#lightgreenYour ultimate was blocked, the enemy is #greenimmune.'
                        )
                        es.tell(
                            play.userid, '#multi',
                            '#lightgreenYou #greenblocked #lightgreenan ultimate skill.'
                        )
    if count > 0:
        es.centertell(userid, 'Entangling Roots: %s' % (count))
    else:
        es.tell(
            userid, '#multi',
            '#lightgreenEntangling Roots #greenfailed#lightgreen, because no enemy is close enough.'
        )
        cancel(userid, 'player_ultimate')
Beispiel #9
0
def load():
    config.execute()
    lmv['command'] = str(lmv_command)
    if lmv['command']:
        cmdlib.registerSayCommand(lmv['command'],sendVote,'Send Player Vote popup')
        cmdlib.registerClientCommand(lmv['command'],sendVote,'Send Player Vote popup')
    ini = cfglib.AddonINI(addonpath + '/strings.ini')
    ini.addValueToGroup('Vote on GamePlay','en','Vote for next GamePlay:')
    ini.addValueToGroup('Vote on Map','en','Vote on a Map:')
    ini.addValueToGroup('Start GamePlay Vote','en','#green[LooneyMapVote]#default Use the command "#lightgreen$command#default" to vote for the next GamePlay')
    ini.addValueToGroup('End GamePlay Vote','en','#green[LooneyMapVote]#default Next GamePlay will be#lightgreen $gameplay#default!')
    ini.addValueToGroup('Start Map Vote','en','#green[LooneyMapVote]#default Use the command "#lightgreen$command#default" to Vote for the next Map')
    ini.addValueToGroup('End Map Vote','en','#green[LooneyMapVote]#default Next Map is#lightgreen $nextmap#default!')
    ini.addValueToGroup('Vote Not Started','en','#green[LooneyMapVote]#default Vote has not started yet')
    ini.addValueToGroup('Between Votes','en','#green[LooneyMapVote]#default Please wait to use this command, we are between votes')
    ini.addValueToGroup('Vote Over','en','#green[LooneyMapVote]#default Sorry, voting is over')
    ini.addValueToGroup('NextMap Decided','en','#green[LooneyMapVote]#default NextMap has already been decided.#lightgreen  NextMap#default:#green $nextmap')
    ini.addValueToGroup('Already Voted','en','#green[LooneyMapVote]#default You already voted for#lightgreen $playervote')
    ini.addValueToGroup('Player Vote','en','#green[LooneyMapVote]#default $player voted for#lightgreen $choice')
    ini.addValueToGroup('Time Remaining','en','#green[LooneyMapVote]#default Vote ends in $seconds seconds')
    ini.addValueToGroup('One Second Remains','en','#green[LooneyMapVote]#default Vote ends in 1 second')
    lmv['maps'] = cfglib.AddonINI(addonpath + '/maptypes.ini')
    for mapbsp in os.listdir(str(es.ServerVar('eventscripts_gamedir')) + '/maps/'):
        if not mapbsp.endswith('.bsp'): continue
        mapname = mapbsp[0:~3]
        if mapname in str(lmv_maps_to_not_use).split(','): continue
        allmaps.add(mapname)
        if notInHeader(mapname):
            prefix = mapname.split('_')[0] + '_'
            lmv['maps'].addValueToGroup(prefix,getNumber(prefix),mapname)
    lmv['maps'].write()
    serverlang = langlib.getDefaultLang()
    for gameplay in lmv['maps']:
        ini.addValueToGroup(gameplay,serverlang,gameplay)
    first = True
    for group in ini:
        if first:
            first = False
        else:
            ini.setGroupComments(group,'')
    ini.write()
    lmv['lang'] = langlib.Strings(ini)
    if lmv_scripts_for_gameplay:
        scriptpath = addonpath + '/scriptmanager'
        if not os.path.isdir(scriptpath):
            os.makedirs(scriptpath)
        for gameplay in lmv['maps']:
            gameplay_ini[gameplay] = cfglib.AddonINI(scriptpath + '/%s.ini'%gameplay)
            gameplay_ini[gameplay].addValueToGroup('Scripts','1','')
            gameplay_ini[gameplay].setGroupComments('Scripts',['Set scripts to be loaded for maptype below','Use a different number for each and follow the same syntax'])
            gameplay_ini[gameplay].addValueToGroup('Configs','1','')
            gameplay_ini[gameplay].setGroupComments('Configs',['Set .cfg files to be executed for maptype below','Use a different number for each and follow the same syntax','Please use the path relative to <gamename>','For instance, if your cfg is in <gamename>/cfg/myconfigs/configone.cfg, you would use "cfg/myconfigs/configone"'])
            gameplay_ini[gameplay].write()
    mapVote.mapStart(str(lmv_default_gameplay))
    mapVote.resetMapVote(str(es.ServerVar('eventscripts_currentmap')))
    startTimeVote()
Beispiel #10
0
def cluster_rockets():
    player = Player.from_userid(int(es.ServerVar('wcs_userid')))
    if player.team >= 2:
        nade_repeat = Repeat(create_nade,
                             (player, int(es.ServerVar('wcs_dmg'))))
        nade_repeat.start(0.2, int(es.ServerVar('wcs_rockets')), True)
        es.tell(
            player.userid, '#multi',
            '#green[WCS] #lightgreenYou fired #green%s Cluster Rockets!' %
            int(es.ServerVar('wcs_rockets')))
Beispiel #11
0
def map_cycle():
    global gMapCycle
    gMapCycle = []
    mapcycle_path = xa.gamedir() + '/' + str(es.ServerVar('mapcyclefile'))
    if os.path.isfile(mapcycle_path):
        mapfile = open(mapcycle_path, 'r')
        gMapCycle = filter(map_check, map(string.strip, mapfile.readlines()))
        mapfile.close()
    else:
        gMapCycle = [es.ServerVar('eventscripts_currentmap')]
Beispiel #12
0
def orc():
    if dice <= 15:
        if effect.EST:
            v = Vector(es.getplayerlocation(ev['attacker']))
            q = Vector(es.getplayerlocation(ev['userid']))
            effect.est_Effect(3, '#a', 0, 'sprites/plasma.vmt', v[0], v[1],
                              v[2] + 20, q[0], q[1], q[2] + 20, 0.5, 10, 10, 0,
                              255, 0, es.ServerVar('wcs_alpha'))
            effect.est_Effect(3, '#a', 0, 'sprites/heatwave.vmt', v[0], v[1],
                              v[2] + 20, q[0], q[1], q[2] + 20, 0.5, 1, 1, 0,
                              255, 0, es.ServerVar('wcs_alpha'))
Beispiel #13
0
def bloodflame():
    if dice <= 30:
        if effect.EST:
            v = Vector(es.getplayerlocation(ev['attacker']))
            q = Vector(es.getplayerlocation(ev['userid']))
            effect.est_Effect(3, '#a', 0, 'sprites/c4.vmt', v[0], v[1],
                              v[2] + 20, q[0], q[1], q[2] + 20, 0.5, 15, 15,
                              251, 255, 100, es.ServerVar('wcs_alpha'))
            effect.est_Effect(3, '#a', 0, 'sprites/crystal_beam1.vmt', v[0],
                              v[1], v[2] + 20, q[0], q[1], q[2] + 20, 0.5, 10,
                              10, 232, 111, 0, es.ServerVar('wcs_alpha'))
Beispiel #14
0
def bloodban():
    if dice <= 30:
        if effect.EST:
            v = Vector(es.getplayerlocation(ev['attacker']))
            q = Vector(es.getplayerlocation(ev['userid']))
            effect.est_Effect(3, '#a', 0, 'sprites/xbeam2.vmt', v[0], v[1],
                              v[2] + 20, q[0], q[1], q[2] + 20, 0.5, 10, 10,
                              199, 255, 248, es.ServerVar('wcs_alpha'))
            effect.est_Effect(3, '#a', 0, 'sprites/hydraspinalcord.vmt', v[0],
                              v[1], v[2] + 20, q[0], q[1], q[2] + 20, 0.5, 6,
                              6, 111, 244, 157, es.ServerVar('wcs_alpha'))
Beispiel #15
0
def showxp(userid, args):  # Cmdlib syntax
    # Get the player's level and XP
    plevel, pxp = cursor.execute('SELECT level, xp FROM users WHERE id=?',
                                 (getID(userid), )).fetchone()
    # XP required for next level
    xp_next_level = int(es.ServerVar('xp_next_level'))
    xp_multi = float(es.ServerVar('xp_multi'))
    next_level_xp = int((plevel * plevel) * xp_next_level * xp_multi)
    # Send text
    es.tell(
        userid, '#multi', '#green[SH] Level #lightgreen%s - %s / %s XP' %
        (plevel, int(pxp), int(next_level_xp)))
Beispiel #16
0
def getcolor(args):
    userid = int(args[0])
    var = str(args[1])
    var1 = str(args[2])
    var2 = str(args[3])
    var3 = str(args[4])
    player = playerlib.getPlayer(userid)
    color = player.getColor()
    a, b, c, d = color
    es.ServerVar(var).set(a)
    es.ServerVar(var1).set(b)
    es.ServerVar(var2).set(c)
    es.ServerVar(var3).set(d)
Beispiel #17
0
def set_nextmap(mapName):
    global winningMap
    winningMap = mapName

    # Set eventscripts_nextmapoverride to the winning map
    es.ServerVar('eventscripts_nextmapoverride').set(mapName)

    # Set Mani 'nextmap' if Mani is loaded
    if str(es.ServerVar('mani_admin_plugin_version')) != '0':
        es.server.queuecmd('ma_setnextmap %s' % mapName)

    # Set SourceMod 'nextmap' if SourceMod is loaded
    if str(es.ServerVar('sourcemod_version')) != '0':
        es.server.queuecmd('sm_nextmap %s' % mapName)
Beispiel #18
0
    def clear(self):
        '''Resets all cvars in the dictionary and then clears itself'''

        # Loop through all cvars in the dictionary
        for cvar in self:

            # Set the cvar to its default value
            es.ServerVar(cvar).set(self[cvar])

            # Remove the notify flag from the cvar
            es.ServerVar(cvar).removeFlag('notify')

        # Clear the dictionary
        super(_CvarDefaults, self).clear()
Beispiel #19
0
def wcs_ulti_chain():
    userid = int(es.ServerVar('wcs_userid'))
    player = Player.from_userid(userid)
    if player.team >= 2:
        count = 0
        wcs_commands.fade(userid, 10, 55, 5, 200, 1)
        radius = float(es.ServerVar('wcs_radius'))
        atk_origin = player.origin
        for play in PlayerIter('alive'):
            if play.team != player.team:
                vic_origin = play.origin
                if vic_origin.get_distance(atk_origin) <= radius:
                    if not wcsgroup.getUser(play.userid, 'ulti_immunity'):
                        wcs_commands.damage(play.userid, 32, userid, solo=1)
                        count += 1
                        es.emitsound('player', play.userid,
                                     'wcs/lightning.wav', 1.0, 0.6)
                        queue_command_string(
                            'es est_effect_06 #a 0 sprites/lgtning.vmt "%s,%s,%s" "%s,%s,%s" 10 .2 10 1 1 13 160 160 230 255 11'
                            %
                            (atk_origin[0], atk_origin[1], atk_origin[2] + 35,
                             vic_origin[0], vic_origin[1], vic_origin[2] + 35))
                        queue_command_string(
                            'es est_effect_06 #a 0 sprites/lgtning.vmt "%s,%s,%s" "%s,%s,%s" 10 .2 10 2 2 12 150 150 255 220 8'
                            %
                            (atk_origin[0], atk_origin[1], atk_origin[2] + 35,
                             vic_origin[0], vic_origin[1], vic_origin[2] + 35))
                        queue_command_string(
                            'es est_effect_06 #a 0 sprites/lgtning.vmt "%s,%s,%s" "%s,%s,%s" 10 .2 10 1 1 14 200 200 255 235 10'
                            %
                            (atk_origin[0], atk_origin[1], atk_origin[2] + 35,
                             vic_origin[0], vic_origin[1], vic_origin[2] + 35))
                    else:
                        es.tell(
                            userid, '#multi',
                            '#lightgreenYour ultimate was blocked, the enemy is #greenimmune.'
                        )
                        es.tell(
                            play.userid, '#multi',
                            '#lightgreenYou #greenblocked #lightgreenan ultimate skill.'
                        )
    if count > 0:
        es.centertell(userid, 'Chain Lightning: %s players damaged' % (count))
    else:
        es.tell(
            userid, '#multi',
            '#lightgreenChain Lightning #greenfailed#lightgreen, because no enemy is close enough to be damaged.'
        )
        cancel(userid, 'player_ultimate')
Beispiel #20
0
def log(module, text, userid=None, admin=False, loglvl=0):
    """
        XA logging
        
        module:         module name (usually automatically provided)
        test:           text string to log
        userid:         optionally provide a userid as reference
        admin:          set to true if this is an admin action
        loglvl:         an optional level - messages with lower xa_log values will not be recorded
        
        Appends a line to the module's log file (found in the xa/logs directory).
        
        Includes ability to reference a specific player and also flag as an admin action
    """
    # Is logging enabled and does our module exist?
    if int(es.ServerVar('xa_log')) and int(
            es.ServerVar('xa_log')) >= loglvl and xa.exists(module):
        # Was a valid source userid specified?
        if userid and es.exists('userid', int(userid)):
            # Is this userid an admin?
            if admin:
                # Adming log
                logtext = '%s: Admin %s [%s]: %s' % (
                    module, es.getplayername(userid),
                    es.getplayersteamid(userid), text)

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

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

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

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

        # Write to the SRCDS log file
        es.log(logtext)
def country_cmd(args):
    """
   iptocountry_getcountry <country var> <abbr var> <"ip">
   Returns the country name and three-letter abbreviation associated with the IP to server variables
   """
    if len(args) == 3:
        info = iptocountry.get_country(args[2])

        es.ServerVar(args[0]).set(info[0])
        es.ServerVar(args[1]).set(info[1])

    else:
        es.dbgmsg(
            0,
            'Syntax: iptocountry_getcountry <country var> <abbr var> <"ip">')
def keyrand_cmd(args):
    if len(args) > 1:
        keygroup = args[1]
        if es.exists('keygroup', keygroup):
            kv = keyvalues.getKeyGroup(keygroup)
            if not len(args) > 2:
                es.ServerVar(args[0]).set(str(random.choice(list(kv.keys()))))
            elif es.exists('key', keygroup, args[2]):
                es.ServerVar(args[0]).set(str(random.choice(list(kv[args[2]].keys()))))
            else:
                es.dbgmsg(0, 'keyrand: Invalid key for keygroup "%s" provided: %s' % (keygroup, args[2]))
        else:
            es.dbgmsg(0, 'keyrand: Invalid keygroup provided: %s' % keygroup)
    else:
        es.dbgmsg(0, 'keyrand: Not enough arguments to keyrand. Syntax: keyrand <variable> <keygroup> [key]')
Beispiel #23
0
        def get(self, info):
            """ Returns weapon properties """
            if info == 'name':
                return self.info_name

            elif info == 'prop':
                return ('CBasePlayer.localdata.m_iAmmo.' +
                        self.info_ammoprop) if self.info_ammoprop else None

            elif info == 'tags':
                return self.info_tags

            elif info == 'slot':
                return self.info_slot

            elif info == 'clip':
                return self.info_clip

            elif info == 'maxammo':
                return int(es.ServerVar('ammo_' + self.info_maxammo +
                                        '_max')) if isinstance(
                                            self.info_maxammo,
                                            str) else self.info_maxammo

            elif info == 'indexlist':
                return list(es.createentitylist(self.name))

            raise ValueError, "No weapon info '%s'" % info
Beispiel #24
0
def memoryExecuteCommand(pathToConfigFile):
    """
    This function copies a configuration file from outside the ../cfg/ file to
    the ../cfg/ file to be executed by Valve's exec command. The reason why we
    need to copy the file is to ensure backwards compatibility as es_(x)mexec
    used to allow functionality of having configuration files outside of the
    ../cfg/ directory. Since the Valve console broke this functionality in the
    OB update, we need to simulate the functionality by copying the directory
    to a temporary unique file in the ../cfg/ directory.
    """
    pathToConfigFile = pathToConfigFile.strip('"')
    if not pathToConfigFile.startswith('..'):
        es.server.cmd('exec "%s"' % pathToConfigFile)
        return

    cfgFolder = Path(str(es.ServerVar('eventscripts_gamedir'))).joinpath('cfg')
    individualCFGFile = cfgFolder.joinpath(pathToConfigFile)

    uniqueString = hashlib.md5(str(time.time()).encode('utf-8')).hexdigest()
    configName = '%s.%s.mexec.cfg' % (individualCFGFile.namebase, uniqueString)
    newFile = cfgFolder.joinpath(configName)

    try:
        individualCFGFile.copyfile(newFile)
        es.server.cmd('exec "%s"' % configName)
        newFile.remove()
    except IOError:
        es.dbgmsg(
            0,
            "ERROR: es_mexec cannot find the file path %s" % pathToConfigFile)
Beispiel #25
0
def load():
    """ Initialize and register the module with XA Core """
    xatimeleft.addCommand('timeleft', timeleft_cmd, 'display_timeleft',
                          'UNRESTRICTED').register(('console', 'say'))
    """ If XA loads late, then send es_map_start event to load the start time """
    if str(es.ServerVar('eventscripts_currentmap')) != "":
        es_map_start({})
Beispiel #26
0
	def __init__(self):
		self.unique = 0
		self.userid = 0
		self.index = es.ServerVar('eventscripts_lastgive')
		self.EST = False
		self.SPE = False
		self.NT = False
Beispiel #27
0
def createVariable(module, variable, defaultvalue=0, description=''):
    """
        Create a server variable
        
        module:         module name (usually automatically provided)
        variable:       the name of the cvar
        defaultvalue:   default value
        description:    text description of the cvar
        
        return:         (bool) true (false if module does not exist)
    """
    # Does the module exist?
    if xa.exists(module):
        # Find the module instance
        module = xa.find(module)

        # Get the variable name
        variable = getVariableName(module, variable)

        # Did we get a valid variable name?
        if variable:
            # Setup the variable
            module.variables[variable] = es.ServerVar(variable, defaultvalue,
                                                      description)
            module.variables[variable]._def = defaultvalue
            module.variables[variable]._descr = description

            # Return our new variable instance
            return module.variables[variable]

    # Fallback, variable creation failed
    return False
Beispiel #28
0
def services_cmd():
    # handles all of the service related functions
    cmd = es.getargv(1)
    cmd = cmd.lower()
    if cmd == "register":
        # create a fake service
        # //services register auth myauth
        # // services.register("auth", myauth)
        servicename = es.getargv(2)
        cmdname = es.getargv(3)
        leg = LegacyAuthorizationService()
        leg.setCommandName(cmdname)
        services.register(servicename, leg)
    elif cmd == "unregister":
        servicename = es.getargv(2)
        services.unregister(servicename)
        # // services unregister auth
        pass
    elif cmd == "isregistered":
        # //services isregistered myvar auth
        returnvar = es.ServerVar(es.getargv(2))
        servicename = es.getargv(3)
        returnvar.set(int(services.isRegistered(servicename)))
    elif cmd == "getlist":
        pass
    elif cmd == "getregistered":
        pass
    elif cmd == "type":
        pass
    elif cmd == "list":
        pass
    else:
        es.dbgmsg(0, "services: Invalid option.")
Beispiel #29
0
def services_proxy():
    service = es.getargv(1)
    myserv = services.use(service)
    if not isinstance(myserv, LegacyAuthorizationService):
        # e2py
        function = es.getargv(2)

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

        arglist = [myserv]
        for j in range(3, es.getargc()):
            if not j == responsevarn:
                arglist.append(es.getargv(j))
        func = myserv.__class__.__dict__[function]
        d = func(*arglist)
        if d is not None and responsevar is not None:
            responsevar.set(d)
    else:
        # e2e
        cmd = myserv.cmdname
        args = es.getargs()[len(service) + 1:]
        newcmd = "%s %s" % (cmd, args)
        es.server.cmd(newcmd)
Beispiel #30
0
def DelayTimer():
    gamethread.cancelDelayed('votemap_timer')
    timeLimit = int(es.ServerVar('mp_timelimit')) * 60
    if timeLimit:
        delay = timeLimit - int(time_before_end_of_map_vote) - 10
        gamethread.delayedname(delay, 'votemap_timer', EndOfMapVote,
                               "timelimit")