Esempio n. 1
0
    def msg(self, filter, string, tokens={}, prefix=False):
        # Format the filter
        filter = self.__format_filter(filter)

        # Format the message with the prefix if needed
        prefix = self.__format_prefix(prefix, string)

        # Check if this is a normal message
        if not str(string) in __strings__:
            if isinstance(filter, int):
                # Send message to the userid
                return es.tell(filter, '#multi',
                               '#default%s%s' % (prefix, string))

            # Send message to the userids from the playerlib filter
            for userid in getUseridList(filter):
                es.tell(userid, '#multi', '#default%s%s' % (prefix, string))
        else:
            if isinstance(filter, int):
                # Send message to the userid
                return es.tell(
                    filter, '#multi', '#default%s%s' %
                    (prefix, self.__format_string(string, tokens, filter)))

            # Send message to the userids from the playerlib filter
            for userid in getUseridList(filter):
                es.tell(
                    userid, '#multi', '#default%s%s' %
                    (prefix, self.__format_string(string, tokens, userid)))
Esempio n. 2
0
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))
Esempio n. 3
0
    def msg(self, filter, string, tokens={}, prefix=False):
        # Format the filter
        filter = self.__format_filter(filter)

        # Format the message with the prefix if needed
        prefix = self.__format_prefix(prefix, string)

        # Check if this is a normal message
        if not str(string) in __strings__:
            if isinstance(filter, int):
                # Send message to the userid
                return es.tell(
                    filter, '#multi', '#default%s%s' % (prefix, string))

            # Send message to the userids from the playerlib filter
            for userid in getUseridList(filter):
                es.tell(userid, '#multi', '#default%s%s' % (prefix, string))
        else:
            if isinstance(filter, int):
                # Send message to the userid
                return es.tell(filter, '#multi', '#default%s%s'
                    % (prefix, self.__format_string(string, tokens, filter)))

            # Send message to the userids from the playerlib filter
            for userid in getUseridList(filter):
                es.tell(userid, '#multi', '#default%s%s'
                    % (prefix, self.__format_string(string, tokens, userid)))
Esempio n. 4
0
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))
Esempio n. 5
0
    def saytext2(self, filter, index, string, tokens={}, prefix=False):
        # Setup filter
        self.__format_filter(filter)

        # Format the message with the prefix if needed
        prefix = self.__format_prefix(prefix, string)

        # Check if this is a normal message
        if not str(string) in __strings__:
            # Send message to the userid
            if isinstance(filter, int):
                return usermsg.saytext2(filter, index, '\1%s%s'
                    % (prefix, string), 0, 0, 0, 0)

            # Playerlib filter
            for userid in getUseridList(filter):
                usermsg.saytext2(userid, index, '\1%s%s' % (prefix, string), 0,
                    0, 0, 0)
        else:
            # Send message to the userid
            if isinstance(filter, int):
                return usermsg.saytext2(filter, index, '\1%s%s'
                    % (prefix, self.__format_string(string, tokens, filter)),
                        0, 0, 0, 0)

            # Send message to the userids from the playerlib filter
            for userid in getUseridList(filter):
                usermsg.saytext2(userid, index, '\1%s%s'
                    % (prefix, self.__format_string(string, tokens, userid)),
                        0, 0, 0, 0)

        # Show in console
        '''
Esempio n. 6
0
def voteStart():
    # Create a new vote
    global ggVote
    ggVote = popuplib.easymenu("gg_map_vote", None, voteSubmit)

    msg("#human", "PlaceYourVotes", {}, True)

    # Set question and add some options
    ggVote.settitle("Please vote for the next map:")

    # Add maps as options
    for map_name in getMapList():
        ggVote.addoption(map_name, map_name.lower())
        mapVoteOptions[map_name] = []

    # Users eligable to vote
    voteUserids.extend(getUseridList("#human"))

    # Only send to dead players ?
    if int(gg_map_vote_after_death):
        voteSentUserids.extend(getUseridList("#human, #dead"))
        ggVote.send(voteSentUserids)

    # Send it to everyone
    else:
        ggVote.send(voteUserids)

    # Start the repeat
    voteRepeat = repeat.create("gg_map_vote", voteCountDown)
    voteRepeat.start(1, int(gg_map_vote_time))

    # Fire event
    GG_Vote().fire()
Esempio n. 7
0
def voteStart():
    # Create a new vote
    global ggVote
    ggVote = popuplib.easymenu('gg_map_vote', None, voteSubmit)

    msg('#human', 'PlaceYourVotes', {}, True)

    # Set question and add some options
    ggVote.settitle('Please vote for the next map:')

    # Add maps as options
    for map_name in getMapList():
        ggVote.addoption(map_name, map_name.lower())
        mapVoteOptions[map_name] = []

    # Users eligable to vote
    voteUserids.extend(getUseridList('#human'))

    # Only send to dead players ?
    if int(gg_map_vote_after_death):
        voteSentUserids.extend(getUseridList('#human, #dead'))
        ggVote.send(voteSentUserids)

    # Send it to everyone
    else:
        ggVote.send(voteUserids)

    # Start the repeat
    voteRepeat = repeat.create('gg_map_vote', voteCountDown)
    voteRepeat.start(1, int(gg_map_vote_time))

    # Fire event
    GG_Vote().fire()
Esempio n. 8
0
def _play_quakesound(soundname, userid, attackerid):
    if soundname in quake_sounds_kv:
        if 'mode' in quake_sounds_kv[soundname]:
            mode = int(quake_sounds_kv[soundname]['mode'])
        else:
            mode = '1'
        if 'visual_mode' in quake_sounds_kv[soundname]:
            visual_mode = int(quake_sounds_kv[soundname]['visual_mode'])
        else:
            visual_mode = '1'
        if mode == 0:
            useridlist_sound = []
        elif mode == 1:
            useridlist_sound = playerlib.getUseridList('#human')
        elif mode == 2:
            useridlist_sound = [userid, attackerid]
        elif mode == 3:
            useridlist_sound = [attackerid]
        elif mode == 4:
            useridlist_sound = [userid]
        else:
            useridlist_sound = playerlib.getUseridList('#human')
        if visual_mode == 0:
            useridlist_text = []
        elif visual_mode == 1:
            useridlist_text = playerlib.getUseridList('#human')
        elif visual_mode == 2:
            useridlist_text = [userid, attackerid]
        elif visual_mode == 3:
            useridlist_text = [attackerid]
        elif visual_mode == 4:
            useridlist_text = [userid]
        else:
            useridlist_text = playerlib.getUseridList('#human')
        if (userid > 0) and (attackerid > 0):
            langdata = {"username":es.getplayername(userid), "attackername":es.getplayername(attackerid)}
        elif userid > 0:
            langdata = {"username":es.getplayername(userid)}
        elif attackerid > 0:
            langdata = {"attackername":es.getplayername(attackerid)}
        else:
            langdata = {}
        for userid in useridlist_sound:
            if not es.isbot(userid):
                soundfile = None
                style = str(quake_sounds_setting.get(userid))
                if style != 'off':
                    if style in quake_sounds_kv[soundname]['sound']:
                        soundfile = str(quake_sounds_kv[soundname]['sound'][style])
                    elif 'standard' in quake_sounds_kv[soundname]['sound']:
                        soundfile = str(quake_sounds_kv[soundname]['sound']['standard'])
                    if soundfile:
                        es.playsound(userid, soundfile, 1.0)
        for userid in useridlist_text:
            if not es.isbot(userid):
                style = str(quake_sounds_setting.get(userid))
                if style != 'off':
                    player = playerlib.getPlayer(userid)
                    soundtext = quake_sounds_language(soundname, langdata, player.get("lang"))
                    usermsg.centermsg(userid, str(soundtext))
Esempio n. 9
0
def getusers(users):
    # http://www.eventscripts.com/pages/Est_PlayerSelection
    # Python style #alive, #all, #bot, #ct, #dead, #human, #spec, #t, #un
    # EST style #a, #c, #3, #t, #2, #s, #1, #u, #0, #h, #b, #l, #d
    # ex1: #alive,#ct (for CT who is alive)
    # ex2: #23!d (for all T and CT who is alive)
    # issue: names start with # are not supported
    global pyfilter
    if str(users).startswith("#"):
        status = 0
        notfilter = ""
        if "," in users:
            status = 1
        if "!" in users:
            all = users.split("!")
            users = all[0]
            notfilter = all[1]
            status = 2
        if status == 0:
            if users in pyfilter:
                status = 1
            else:
                status = 2
        if status == 2:
            global filter_table
            filter = []
            for item in filter_table:
                if item[0] in users:
                    idlist = playerlib.getUseridList(item[1])
                    filter.extend(idlist)
            users = set(filter)
            if notfilter != "":
                filter = []
                for item in filter_table:
                    if item[0] in notfilter:
                        idlist = playerlib.getUseridList(item[1])
                        filter.extend(idlist)
                notfilter = set(filter)
                for item in notfilter:
                    if int(item) in users:
                        users.remove(int(item))
        else:
            users = playerlib.getUseridList(users)
        return users
    allusers = es.getUseridList()
    if not isinstance(users, tuple) and not isinstance(users, list):
        user = finduserid(users, allusers)
        if user:
            return (user, )
        return ()
    test = []
    for user in users:
        user = finduserid(user, allusers)
        if user:
            test.append(user)
    return users
Esempio n. 10
0
def round_end(ev):
    dbg( 'round end')
    wt,lt = 'ct','t'
    if ev['winner'] == '2':
        wt,lt = lt,wt
    for userid in playerlib.getUseridList('#human,#%s' % wt):
        players.increment(es.getplayersteamid(userid),'win')
    for userid in playerlib.getUseridList('#human,#%s' % lt):
        players.increment(es.getplayersteamid(userid),'lose')
    dcfg.sync()
    updateTimes()
    db.commit()
Esempio n. 11
0
def dod_round_win(ev):
    wt,lt = 'ct','t'
    dbg( 'round won')
    if ev['team'] == '2':
        wt,lt = lt,wt
    for userid in playerlib.getUseridList('#human,#%s' % wt):
        players.increment(es.getplayersteamid(userid),'win')
    for userid in playerlib.getUseridList('#human,#%s' % lt):
        players.increment(es.getplayersteamid(userid),'lose')
    dcfg.sync()
    updateTimes()
    db.commit()
Esempio n. 12
0
def es_map_start(event_var):
    '''Method to be ran on es_map_start event'''

    # Make the sounds downloadable
    make_downloadable()

    # Load custom GunGame events
    gg_resource_file.load()

    # Execute GunGame's server.cfg file
    es.delayed(1, 'exec gungame51/gg_server.cfg')

    # Reset all players
    reset_players()

    # Reset current leaders
    LeaderManager().reset()

    # Prune the Database
    prune_winners_db()

    # Loop through all human players
    for userid in getUseridList('#human'):

        # Update players in winner's database
        Player(userid).database_update()

    # Is the weapon order sort type set to #random?
    if str(gg_weapon_order_sort_type) == '#random':

        # Re-randomize the weapon order
        get_weapon_order().randomize()

    # Check to see if gg_start needs fired after everything is loaded
    delayed(2, check_gg_start)
Esempio n. 13
0
def testcase():
    playercount = len(playerlib.getUseridList('#all'))
    weaponcount = len(weaponlib.getWeaponList('#all'))
    entitycount = len(es.createentitylist('env_fire'))
    for line in (
            'profile begin foreach_test', 'profile begin foreach_player',
            'testlib begin foreach_player "foreach player #all"',
            'es_xset _foreach_count 0',
            'foreach player _foreach_testvar #all "es_xmath _foreach_count + 1"',
            'testlib fail_unless _foreach_count equalto %d' % playercount,
            'testlib end', 'profile end foreach_player',
            'profile begin foreach_weapon',
            'testlib begin foreach_weapon "foreach weapon #all"',
            'es_xset _foreach_count 0',
            'foreach weapon _foreach_testvar #all "es_xmath _foreach_count + 1"',
            'testlib fail_unless _foreach_count equalto %d' % weaponcount,
            'testlib end', 'profile end foreach_weapon',
            'profile begin foreach_entity',
            'testlib begin foreach_entity "foreach entity env_fire"',
            'es_xset _foreach_count 0',
            'foreach entity _foreach_testvar _foreach_testvar env_fire "es_xmath _foreach_count + 1"',
            'testlib fail_unless _foreach_count equalto %d' % entitycount,
            'testlib end', 'profile end foreach_entity',
            'profile begin foreach_token',
            'testlib begin foreach_token "foreach token"',
            'es_xset _foreach_count 0',
            'foreach token _foreach_testvar "a-ab-abc-abcd-abcde" - "es_xmath _foreach_count + 1"',
            'testlib fail_unless _foreach_count equalto 5', 'testlib end',
            'profile end foreach_token', 'profile begin foreach_part',
            'testlib begin foreach_part "foreach part"',
            'es_xset _foreach_count 0',
            'foreach part _foreach_testvar "a1b2c3d4e5" 2 "es_xmath _foreach_count + 1"',
            'testlib fail_unless _foreach_count equalto 5', 'testlib end',
            'profile end foreach_part', 'profile end foreach_test'):
        es.server.cmd(line)
Esempio n. 14
0
def _play_sound(soundfile, soundname, userid):
    player = playerlib.getPlayer(userid)
    if userid in playerlimit:
        playerlimit[userid] = playerlimit[userid] + 1
    else:
        playerlimit[userid] = 1
    if (playerlimit[userid] < int(sounds_per_round)) or (
            xasounds.isUseridAuthorized(userid, "play_adminsound") == True):
        if (int(sounds_filter_if_dead) == 1) and int(
                player.get('isdead')) == 1:
            useridlist_sound = playerlib.getUseridList('#dead')
        else:
            useridlist_sound = es.getUseridList()
        langdata = {
            "username": es.getplayername(userid),
            "sound": str(soundname)
        }
        for userid in useridlist_sound:
            if int(xaplayerdata_sounds.get(userid)) == 1:
                es.playsound(userid, soundfile, 1.0)
        for userid in useridlist_sound:
            if int(xaplayerdata_sounds.get(userid)) == 1:
                player = playerlib.getPlayer(userid)
                soundtext = xalanguage('played sound', langdata,
                                       player.get("lang"))
                es.tell(userid, soundtext)
    else:
        soundtext = xalanguage('sound limit', {}, player.get("lang"))
        es.tell(userid, soundtext)
Esempio n. 15
0
def _get_matching_players(users):
    '''Return a set() of players matching the given filter...'''
    
    # Get a set to store the matching players...
    return_value = set()
    
    # Is the player a single userid?
    if es.exists('userid', users):
        
        # Add that player...
        return_value.add(int(users))
        
    # Otherwise, is that a playerlib's filter?
    elif str(users).startswith('#'):
        
        # Loop through all matching players...
        for userid in playerlib.getUseridList(users):
            
            # Add the player...
            return_value.add(userid)
            
    # Otherwise...
    else:
        
        # Try to find a userid...
        userid = es.getuserid(users)
        
        # Any match found?
        if userid:
            
            # Add the player...
            return_value.add(userid)
            
    # Finaly, return the matching players...
    return return_value
Esempio n. 16
0
def _play_sound(soundfile, soundname, userid):
    player = playerlib.getPlayer(userid)
    if userid in playerlimit:
        playerlimit[userid] = playerlimit[userid] + 1
    else:
        playerlimit[userid] = 1
    if (playerlimit[userid] < int(sounds_per_round)) or (
        xasounds.isUseridAuthorized(userid, "play_adminsound") == True
    ):
        if (int(sounds_filter_if_dead) == 1) and int(player.get("isdead")) == 1:
            useridlist_sound = playerlib.getUseridList("#dead")
        else:
            useridlist_sound = es.getUseridList()
        langdata = {"username": es.getplayername(userid), "sound": str(soundname)}
        for userid in useridlist_sound:
            if int(xaplayerdata_sounds.get(userid)) == 1:
                es.playsound(userid, soundfile, 1.0)
        for userid in useridlist_sound:
            if int(xaplayerdata_sounds.get(userid)) == 1:
                player = playerlib.getPlayer(userid)
                soundtext = xalanguage("played sound", langdata, player.get("lang"))
                es.tell(userid, soundtext)
    else:
        soundtext = xalanguage("sound limit", {}, player.get("lang"))
        es.tell(userid, soundtext)
Esempio n. 17
0
def register(args):
	if len(args) >= 1:
		target = str(args[0]).lower()

		if target == 'player':
			if len(args) >= 4:
				var = str(args[1])
				id  = str(args[2])
				cmd = ' '.join(args[3:])

				if id.startswith('#'):
					for user in getUseridList(id):
						server.insertcmd('es_xset '+var+' '+str(user)+';'+cmd)
				else:
					server.insertcmd('es_xset '+var+' '+id+';'+cmd)

		elif target == 'weapon':
			if len(args) >= 4:
				var = str(args[1])
				id  = str(args[2])
				cmd = ' '.join(args[3:])

				for weapon in getWeaponList(id):
					server.insertcmd('es_xset '+var+' '+str(weapon)+';'+cmd)

		elif target == 'token':
			if len(args) >= 5:
				var    = str(args[1])
				string = str(args[2])
				sep    = str(args[3])
				cmd    = ' '.join(args[3:])

				for token in string.split(sep):
					if len(token):
						server.insertcmd('es_xset '+var+' '+str(token)+';'+cmd)
Esempio n. 18
0
def _punish_player(userid, punishment, adminid, args = [], force = False):
    if adminid == 0 or xapunishments.isUseridAuthorized(adminid, punishment+"_player") or force:
        if (not xapunishments.isUseridAuthorized(userid, "immune_"+punishment)) or (userid == adminid) or force:
            if userid in playerlib.getUseridList("#alive") or True == punishment_ondead[punishment]:
                if callable(punishment_method[punishment]):
                    xapunishments.logging.log("used punishment %s on user %s [%s]" % (punishment, es.getplayername(userid), es.getplayersteamid(userid)), adminid, True)
                    try:
                        punishment_method[punishment](userid, adminid, args, force)
                    except TypeError:
                        try:
                            punishment_method[punishment](userid, adminid, args)
                        except TypeError:
                            punishment_method[punishment](userid, adminid)
                    return True
                else:
                    es.dbgmsg(0, "xapunishments.py: Cannot find method '"+str(punishment_method[punishment])+"'!")
                    return False
            else:
                if userid not in dead_delayed:
                    dead_delayed[userid] = []
                dead_delayed[userid].append(punishment,adminid,args,force)
                xapunishments.logging.log("will be punished when he next spawns", userid)
                es.tell(adminid, xalanguage("dead", {'username':es.getplayername(userid)}, playerlib.getPlayer(adminid).get("lang")))
                return False
        else:
            es.tell(adminid, xalanguage("immune", {'username':es.getplayername(userid)}, playerlib.getPlayer(adminid).get("lang")))
            return False
    else:
        es.tell(adminid, xalanguage("not allowed", (), playerlib.getPlayer(adminid).get("lang")))
        return False
Esempio n. 19
0
def _run_bomb(tick):
    if tick.isdigit():
        soundtext = '%s sec'%tick
    elif tick == 'P':
        soundtext = 'Bomb Planted'
    elif tick == 'D':
        soundtext = 'Bomb Defused'
    elif tick == 'E':
        soundtext = 'Bomb Exploded'
    if 'command_%s'%tick in bomb_timer_language.keys():
        for commandname in bomb_timer_language['command_%s'%tick].keys():
            es.server.queuecmd(bomb_timer_language['command_%s'%tick][commandname].strip())
    for userid in playerlib.getUseridList('#human'):
        if bomb_timer_setting.get('display', userid):
            if int(bomb_timer_middle_screen) == 1:
                usermsg.hudhint(userid, soundtext)
            elif int(bomb_timer_middle_screen) == 2:
                usermsg.centermsg(userid, soundtext)
        if bomb_timer_setting.get('text', userid):
            if 'text_%s'%tick in bomb_timer_language.keys():
                es.tell(userid, '#multi', bomb_timer_language('text_%s'%tick, {}, playerlib.getPlayer(userid).get('lang')))
        if bomb_timer_setting.get('sound', userid):
            if int(es.getplayerteam(userid)) < 2:
                keyname = 'spec'
            elif int(es.getplayerteam(userid)) == 2:
                keyname = 't'
            elif int(es.getplayerteam(userid)) == 3:
                keyname = 'ct'
            if 'sound_%s'%tick in bomb_timer_language.keys():
                es.playsound(userid, bomb_timer_language['sound_%s'%tick][keyname], 1.0)
Esempio n. 20
0
def _punish_player(userid, punishment, adminid, args = [], force = False):
    if adminid == 0 or xapunishments.isUseridAuthorized(adminid, punishment+"_player") or force:
        if (not xapunishments.isUseridAuthorized(userid, "immune_"+punishment)) or (userid == adminid) or force:
            if userid in playerlib.getUseridList("#alive"):
                if callable(punishment_method[punishment]):
                    xapunishments.logging.log("Player "+es.getplayername(adminid)+ " used punishment "+str(punishment)+" on player "+es.getplayername(userid))
                    try:
                        punishment_method[punishment](userid, adminid, args, force)
                    except TypeError:
                        try:
                            punishment_method[punishment](userid, adminid, args)
                        except TypeError:
                            punishment_method[punishment](userid, adminid)
                    return True
                else:
                    es.dbgmsg(0, "xapunishments.py: Cannot find method '"+str(punishment_method[punishment])+"'!")
                    return False
            else:
                es.tell(adminid, xalanguage("dead", {'username':es.getplayername(userid)}, playerlib.getPlayer(adminid).get("lang")))
                return False
        else:
            es.tell(adminid, xalanguage("immune", {'username':es.getplayername(userid)}, playerlib.getPlayer(adminid).get("lang")))
            return False
    else:
        es.tell(adminid, xalanguage("not allowed", (), playerlib.getPlayer(adminid).get("lang")))
        return False
Esempio n. 21
0
def unload():
    # Delete the popup if it exists
    if popuplib.exists('ggLevelMenu'):
        popuplib.unsendname('ggLevelMenu', getUseridList('#human'))
        popuplib.delete('ggLevelMenu')

    # Unregister commands
    unregisterSayCommand('!level')
Esempio n. 22
0
def leader_menu_cmd(userid, args):
    global leaderList

    # Make sure player exists
    if not es.exists('userid', userid) and userid != 0:
        return

    # Get menu contents
    newLeaderList = ['->1. Current Leaders:']
    leaderNames = get_leader_names()

    # Add names if we have leaders
    if leaderNames:
        # Add leader level and weapon
        leaderLevel = get_leader_level()
        newLeaderList.append('    Level %s (%s)' % (leaderLevel,
                                get_level_weapon(leaderLevel)))

        # Divider
        newLeaderList.append('-' * 26)

        # Add player names
        for player_name in leaderNames:
            newLeaderList.append('   * %s' % player_name)

    # No leader
    else:
        newLeaderList.extend(('-' * 26, '   * There currently is no leader'))

    # Finish popup with divider and exit
    newLeaderList.extend(('-' * 26, '0. Exit'))

    # Does the popup exists ?
    if popuplib.exists('ggLeaderMenu'):

        # Send the user the current popup ?
        if newLeaderList == leaderList:
            popuplib.send('ggLeaderMenu', userid)
            return

        # Delete the popup
        popuplib.unsendname('ggLeaderMenu', getUseridList('#human'))
        popuplib.delete('ggLeaderMenu')

    # Build new popup
    ggLeaderMenu = popuplib.create('ggLeaderMenu')
    ggLeaderMenu.timeout('send', 10)
    ggLeaderMenu.timeout('view', 10)

    # Add lines to new popup
    for line in newLeaderList:
        ggLeaderMenu.addline(line)

    # Save current popup
    leaderList = newLeaderList

    # Send it
    popuplib.send('ggLeaderMenu', userid)
def _beacon_loop(userid):
    if userid in playerlib.getUseridList("#alive"):
        es.emitsound('player', userid, xa_adminbeacon_sound, '1.0', '0.7') 
        r, g, b, a = str(xa_adminbeacon_color).split() 
        location = es.getplayerlocation(userid) 
        effectlib.drawCircle(location, 150, steps=50, model="materials/sprites/laser.vmt", seconds=0.2, width=20, endwidth=10, red=r, green=g, blue=b, brightness = a, speed=70) 
        gamethread.delayedname(0.8, 'beacon_%s'%userid, _beacon_loop, userid)
    else:
        players[userid]['beaconed'] = 0 
Esempio n. 24
0
 def stop(self, cancel=None, internal=None):
     if self.running:
         self.popup.unsend(playerlib.getUseridList("#human"))
         self.popup.delete()
         self.popup = None
         if self.endblock:
             if cancel:
                 gVariables['vote_name'].set(self.name)
                 gVariables['vote_id'].set(0)
                 gVariables['vote_text'].set(0)
                 gVariables['vote_count'].set(0)
                 gVariables['vote_percent'].set(0)
                 gVariables['vote_votes'].set(self.votes)
                 gVariables['vote_tie'].set(0)
                 gVariables['vote_canceled'].set(1)
             else:
                 gVariables['vote_name'].set(self.name)
                 gVariables['vote_votes'].set(self.votes)
                 gVariables['vote_canceled'].set(0)
                 gVariables['vote_count'].set(0)
                 for option in self.options:
                     if int(self.options[option]) > int(
                             gVariables['vote_count']):
                         gVariables['vote_id'].set(option)
                         gVariables['vote_text'].set(
                             self.options[option].getText())
                         gVariables['vote_count'].set(
                             self.options[option].submits)
                         gVariables['vote_tie'].set(0)
                         gVariables['vote_percent'].set(
                             int((self.options[option].submits * 100) /
                                 self.votes) if self.votes > 0 else 100)
                     elif int(self.options[option]) == int(
                             gVariables['vote_count']) and int(
                                 gVariables['vote_count']) > 0:
                         gVariables['vote_tie'].set(1)
             if callable(self.endblock):
                 self.endblock(
                     self.name, int(gVariables['vote_id']),
                     str(gVariables['vote_text']),
                     int(gVariables['vote_count']),
                     int(gVariables['vote_percent']), self.votes,
                     True if int(gVariables['vote_tie']) else False,
                     True if cancel else False)
             else:
                 es.doblock(self.endblock)
         self.running = False
         self.votes = 0
         self.time = 0
         for userid in gUsers:
             user = gUsers[userid]
             user.state[self.name] = False
             user.voted[self.name] = None
     else:
         es.dbgmsg(
             0, "Votelib: Cannot stop vote '%s', it is not running" %
             self.name)
Esempio n. 25
0
    def echo(self, filter, level, string, tokens={}, prefix=False):
        # Setup filter
        filter = self.__format_filter(filter)
        '''
        # Is the debug level high enough?
        if int(gungameDebugLevel) < level:
            return
        '''

        # Format the message with the prefix if needed
        prefix = self.__format_prefix(prefix, string)

        # Check if this is a normal message
        if not str(string) in __strings__:
            # Get clean string
            string = self.__clean_string(string)

            # Console or Userid
            if isinstance(filter, int):
                # Send message
                return usermsg.echo(filter, '%s%s' % (prefix, string))

            # Send message to the userids from the playerlib filter
            for userid in getUseridList(filter):
                # Send message
                usermsg.echo(userid, '%s%s' % (prefix, string))
        else:
            # Console or Userid
            if isinstance(filter, int):
                # Get clean string
                string = self.__clean_string(
                    self.__format_string(string, tokens, filter))

                # Send message
                return usermsg.echo(filter, '%s%s' % (prefix, string))

            # Send message to the userids from the playerlib filter
            for userid in getUseridList(filter):
                # Send message
                usermsg.echo(
                    userid, '%s%s' %
                    (prefix,
                     self.__clean_string(
                         self.__format_string(string, tokens, userid))))
Esempio n. 26
0
 def stop(self, cancel=None, internal=None):
     if self.running:
         self.popup.unsend(playerlib.getUseridList("#human"))
         self.popup.delete()
         self.popup = None
         if self.endblock:
             if cancel:
                 gVariables["vote_name"].set(self.name)
                 gVariables["vote_id"].set(0)
                 gVariables["vote_text"].set(0)
                 gVariables["vote_count"].set(0)
                 gVariables["vote_percent"].set(0)
                 gVariables["vote_votes"].set(self.votes)
                 gVariables["vote_tie"].set(0)
                 gVariables["vote_canceled"].set(1)
             else:
                 gVariables["vote_name"].set(self.name)
                 gVariables["vote_votes"].set(self.votes)
                 gVariables["vote_canceled"].set(0)
                 gVariables["vote_count"].set(0)
                 for option in self.options:
                     if int(self.options[option]) > int(gVariables["vote_count"]):
                         gVariables["vote_id"].set(option)
                         gVariables["vote_text"].set(self.options[option].getText())
                         gVariables["vote_count"].set(self.options[option].submits)
                         gVariables["vote_tie"].set(0)
                         gVariables["vote_percent"].set(
                             int((self.options[option].submits * 100) / self.votes) if self.votes > 0 else 100
                         )
                     elif (
                         int(self.options[option]) == int(gVariables["vote_count"])
                         and int(gVariables["vote_count"]) > 0
                     ):
                         gVariables["vote_tie"].set(1)
             if callable(self.endblock):
                 self.endblock(
                     self.name,
                     int(gVariables["vote_id"]),
                     str(gVariables["vote_text"]),
                     int(gVariables["vote_count"]),
                     int(gVariables["vote_percent"]),
                     self.votes,
                     True if int(gVariables["vote_tie"]) else False,
                     True if cancel else False,
                 )
             else:
                 es.doblock(self.endblock)
         self.running = False
         self.votes = 0
         self.time = 0
         for userid in gUsers:
             user = gUsers[userid]
             user.state[self.name] = False
             user.voted[self.name] = None
     else:
         es.dbgmsg(0, "Votelib: Cannot stop vote '%s', it is not running" % self.name)
Esempio n. 27
0
def getUsers(users):
    '''
    Returns a list of existing user IDs as integers. You can pass an iterable
    containing user IDs, playerlib filter, single user ID, handle or name.
    '''

    if hasattr(users, '__iter__'):
        return map(int, filter(lambda x: es.exists('userid', x), users))

    return playerlib.getUseridList(str(users))
Esempio n. 28
0
def updateTimes():
    for userid in playerlib.getUseridList('#human'):
        steamid = es.getplayersteamid(userid)
        players.update(steamid,'lastseen',time.time())
        players.add(steamid,'time',time.time() - players.query(steamid,'sessionstart'))
        players.update(steamid,'sessionstart',time.time())
        cteam = players.query(steamid,'current_team')
        if not cteam == '0':
            players.add(steamid,'team_%s_time' % cteam,time.time() - players.query(steamid,'teamchange_time'))
        players.update(steamid,'teamchange_time',time.time())
Esempio n. 29
0
def load():
    # Delete the popup if it exists
    if popuplib.exists('ggLeaderMenu'):
        popuplib.unsendname('ggLeaderMenu', getUseridList('#human'))
        popuplib.delete('ggLeaderMenu')

    # Register commands
    registerSayCommand('!leader', leader_menu_cmd, 'Displays a !leader menu.')
    registerSayCommand('!leaders', leader_menu_cmd,
        'Displays a !leaders menu.')
Esempio n. 30
0
    def echo(self, filter, level, string, tokens={}, prefix=False):
        # Setup filter
        filter = self.__format_filter(filter)

        '''
        # Is the debug level high enough?
        if int(gungameDebugLevel) < level:
            return
        '''

        # Format the message with the prefix if needed
        prefix = self.__format_prefix(prefix, string)

        # Check if this is a normal message
        if not str(string) in __strings__:
            # Get clean string
            string = self.__clean_string(string)

            # Console or Userid
            if isinstance(filter, int):
                # Send message
                return usermsg.echo(filter, '%s%s' % (prefix, string))

            # Send message to the userids from the playerlib filter
            for userid in getUseridList(filter):
                # Send message
                usermsg.echo(userid, '%s%s' % (prefix, string))
        else:
            # Console or Userid
            if isinstance(filter, int):
                # Get clean string
                string = self.__clean_string(self.__format_string(string,
                                                            tokens, filter))

                # Send message
                return usermsg.echo(filter, '%s%s' % (prefix, string))

            # Send message to the userids from the playerlib filter
            for userid in getUseridList(filter):
                # Send message
                usermsg.echo(userid, '%s%s' % (prefix,
                    self.__clean_string(self.__format_string(string,
                                                            tokens, userid))))
def testcase():
    playercount = len(playerlib.getUseridList('#all'))
    for line in ('profile begin getplayercount_test',
                 'testlib begin getplayercount_test "getplayercount #all"',
                 'es_xset _getplayercount_testvar 0',
                 'getplayercount _getplayercount_testvar #all',
                 'testlib fail_unless _getplayercount_testvar equalto %s' %
                 playercount, 'testlib end',
                 'profile end getplayercount_test'):
        es.server.cmd(line)
def check_leader_warning(level):
    global played_knife
    global played_nade

    # Set sound to False for use later
    sound = False

    # Get the leader's weapon
    weapon = get_level_weapon(level)

    # Is the player on knife level?
    if weapon == 'knife':

        # Has the knifelevel sound been played?
        if played_knife:
            return

        # Does the knifelevel sound always get played
        # or is the leader on the last knife level?
        if not int(warn_last_level_only) or level == knife_level:

            # Set the sound to knifelevel
            sound = 'knifelevel'

            # Set played_knife so it does not get played again this round
            played_knife = True

    # Is the player on hegrenade level?
    if weapon == 'hegrenade':

        # Has the nadelevel sound been played?
        if played_nade:
            return

        # Does the nadelevel sound always get played
        # or is the leader on the last nade level?
        if not int(warn_last_level_only) or level == nade_level:

            # Set the sound to nadelevel
            sound = 'nadelevel'

            # Set played_nade so it does not get played again this round
            played_nade = True

    # Is a sound supposed to be played?
    if not sound:

        # Do not play any sound
        return

    # Loop through all human players
    for userid in getUseridList('#human'):

        # Play the leader level sound
        Player(userid).playsound(sound)
Esempio n. 33
0
def voteCountDown():
    ggRepeat = repeat.find('gg_map_vote')
    if not ggRepeat:
        return

    timeleft = ggRepeat['remaining']

    # Stop the vote ?
    if timeleft == 0:
        voteEnd()
        return

    votes = len(reduce(lambda a, b: a + b, mapVoteOptions.values()))

    voteInfo = ""
    mapsAdded = 0
    # For the map with the most votes to the least
    sortItems = []
    for map in mapVoteOptions.items():
        sortItems.append((map[0], len(map[1])))

    for map in sorted(sortItems, key=itemgetter(1), reverse=True):
        # Add up to three maps
        voteInfo += langstring('MapVotes',
                               tokens={
                                   'map': map[0],
                                   'votes': map[1]
                               })
        mapsAdded += 1
        if mapsAdded >= 3:
            break

    # Should we play the countdown beep
    if timeleft <= 5:
        for userid in getUseridList('#human'):
            Player(userid).playsound('countDownBeep')

        # Show the singular hudhint and stop here
        if timeleft == 1:
            hudhint(
                '#human', 'Countdown_Singular', {
                    'time': timeleft,
                    'voteInfo': voteInfo,
                    'votes': votes,
                    'totalVotes': len(voteUserids)
                })
            return
    # Show the normal hudhint
    hudhint(
        '#human', 'Countdown_Plural', {
            'time': timeleft,
            'voteInfo': voteInfo,
            'votes': votes,
            'totalVotes': len(voteUserids)
        })
def testcase():
    playercount = len(playerlib.getUseridList('#all'))
    for line in (
        'profile begin getplayercount_test',
        'testlib begin getplayercount_test "getplayercount #all"',
        'es_xset _getplayercount_testvar 0',
        'getplayercount _getplayercount_testvar #all',
        'testlib fail_unless _getplayercount_testvar equalto %s' % playercount,
        'testlib end',
        'profile end getplayercount_test'):
        es.server.cmd(line)
Esempio n. 35
0
def printAdverts():
   duration = int(SA_DURATION)
   if adverts:
      advert = adverts.next()
      advert_split = advert.split('|', 1)
      ad = advert_split[1]
      color = advert_split[0]
      msg = msglib.VguiDialog(title=ad, level=5, color=COLORS[color]+" 255", time=duration, mode=msglib.VguiMode.MSG)
      for userid in playerlib.getUseridList('#human'):
         msg.send(userid)
   gamethread.delayedname(duration, 'adverts_delay', printAdverts)
Esempio n. 36
0
def excepter(type1, value1, traceback1):
    mystr = traceback.format_exception(type1, value1, traceback1)
    L = ['ERROR: %s' % time.strftime("%d %b %Y %H:%M:%S"),'XS Version: %s' % info.version,'']
    L.append('Mapname: %s' % str(es.ServerVar('eventscripts_currentmap')))
    L.append('Players: %s (%s Bots)' % (len(es.getUseridList()),len(playerlib.getUseridList('#bot'))))
    for x in mystr:
        es.dbgmsg(0, x[:-1])
        L.append(x[:-1])
    L.append('')
    L += errorlog.lines(retain=False)
    errorlog.write_lines(L)
Esempio n. 37
0
def _get_users(users):
    # Is a filter
    if str(users)[0] == '#':
        users = playerlib.getUseridList(users)
    # Is not a sequence of userids
    elif not hasattr(users, '__iter__'):
        users = (users,)

    for userid in users:
        if es.exists('userid', userid):
            yield userid
Esempio n. 38
0
def getScore(steamid,method,ignore_negative=False):
    if method in players.columns:
        score = players.query(steamid,method)
        if method in scfg.negative_columns and not ignore_negative:
            return -score
        return score
    if method not in methods:
        method = dcfg['default_method'].strip()
    steamidlist = map(lambda x: es.getplayersteamid(x),playerlib.getUseridList('#human'))
    if not steamid in steamidlist:
        return toplist.query(steamid,method)
    return methods[method](players,steamid)
Esempio n. 39
0
def round_end(event_var):
    # Was a ROUND_DRAW or GAME_COMMENCING?
    if int(event_var['reason']) in [10, 16]:
        return

    # Now, we will loop through the userid list and run the AFK Punishment
    #   checks on them
    for userid in getUseridList('#alive,#human'):
        # See if the player was AFK
        if Player(userid).afk():
            # Check AFK punishment
            afkPunishCheck(userid)
Esempio n. 40
0
def rpg_poison():
    gamethread.delayedname(1.0, 'rpg_%s' %(skillname), rpg_poison, ())
    for i in nades:
        x = i[0]
        y = i[1]
        z = i[2]
        team = i[3]
        damage = i[4]
        if team == 2:
            for j in playerlib.getUseridList('#ct, #alive'):
                xp, yp, zp = es.getplayerlocation(j)
                zp += 68 #the head is 68 units above a players feet
                # Inside the smoke
                if math.sqrt((xp-x)**2 + (yp-y)**2 + (zp-z)**2) <= 170:
                    es.server.queuecmd('damage %s %s' %(j, damage))
        elif team == 3:
            for j in playerlib.getUseridList('#t, #alive'):
                xp, yp, zp = es.getplayerlocation(j)
                # Inside the smoke
                if math.sqrt((xp-x)**2 + (yp-y)**2 + (zp-z)**2) <= 170:
                    es.server.queuecmd('damage %s %s' %(j, damage))
Esempio n. 41
0
def _select_target(userid, choice, name):
    if choice == "player":
        if userid in punishment_pmenus:
            punishment_pmenus[userid].delete()
        punishment_pmenus[userid] = popuplib.construct("xapunishplayermenu"+str(userid), "players", "#alive")
        punishment_pmenus[userid].settitle(xalanguage["choose player"])
        punishment_pmenus[userid].menuselectfb = _select_player
        punishment_pmenus[userid].submenu(10, "xapunishtargetmenu")
        punishment_pmenus[userid].send(userid)
    else:
        if choice == "team3":
            playerlist = playerlib.getUseridList("#ct")
        elif choice == "team2":
            playerlist = playerlib.getUseridList("#t")
        elif choice == "all":
            playerlist = es.getUseridList()
        if playerlist:
            punishment_targetlist[userid] = playerlist
            popuplib.send("xapunishsuremenu", userid)
        else:
            popuplib.send("xapunishtargetmenu", userid)
Esempio n. 42
0
 def Loop(self):
     time_left = int(self.starttime - time.time() + float(vote_timer))
     if time_left < 0:
         time_left = 0
     SortedVotes = self.SortDict()
     format = "Vote Counter: (%ss)\n-----------------------\n" % time_left
     for index in range(min(2, len(SortedVotes))):
         option = SortedVotes[index]
         format = format + option + " - Votes: " + str(
             self.votes[option]['votes']) + "\n"
     usermsg.hudhint(playerlib.getUseridList("#human"), format)
     if time_left:
         gamethread.delayedname(1, self.name, self.Loop)
Esempio n. 43
0
def rpg_poison():
    gamethread.delayedname(rpgPoisonnadeInterval, 'rpg_%s' % (skillname),
                           rpg_poison, ())
    for i in nades:
        x = i[0]
        y = i[1]
        z = i[2]
        team = i[3]
        damage = i[4] * rpgPoisonnadeValue
        if team == 2:
            for j in playerlib.getUseridList('#ct, #alive'):
                xp, yp, zp = es.getplayerlocation(j)
                zp += 68  #the head is 68 units above a players feet
                # Inside the smoke
                if math.sqrt((xp - x)**2 + (yp - y)**2 + (zp - z)**2) <= 170:
                    es.server.queuecmd('damage %s %s' % (j, damage))
        elif team == 3:
            for j in playerlib.getUseridList('#t, #alive'):
                xp, yp, zp = es.getplayerlocation(j)
                # Inside the smoke
                if math.sqrt((xp - x)**2 + (yp - y)**2 + (zp - z)**2) <= 170:
                    es.server.queuecmd('damage %s %s' % (j, damage))
Esempio n. 44
0
def foreach_player(variable, identifier, command):
    if '#' in identifier:
        identifier = identifier.replace('#', ',#')[1:]
        for userid in playerlib.getUseridList(identifier):
            variable.set(int(userid))
            es.server.cmd(command)
    elif identifier:
        for player in playerlib.getPlayerList('#all'):
            if identifier.lower() in player.attributes['name'].lower() or identifier == player.attributes['steamid'] or identifier == str(player):
                variable.set(int(player))
                es.server.cmd(command)
    else:
        es.dbgmsg(0, 'foreach player: The identifier "%s" does not exists' % identifier)
def _punish_player(userid, punishment, adminid, args=[], force=False):
    if adminid == 0 or xapunishments.isUseridAuthorized(
            adminid, punishment + "_player") or force:
        if (not xapunishments.isUseridAuthorized(
                userid, "immune_" + punishment)) or (userid
                                                     == adminid) or force:
            if userid in playerlib.getUseridList(
                    "#alive") or True == punishment_ondead[punishment]:
                if callable(punishment_method[punishment]):
                    xapunishments.logging.log(
                        "used punishment %s on user %s [%s]" %
                        (punishment, es.getplayername(userid),
                         es.getplayersteamid(userid)), adminid, True)
                    try:
                        punishment_method[punishment](userid, adminid, args,
                                                      force)
                    except TypeError:
                        try:
                            punishment_method[punishment](userid, adminid,
                                                          args)
                        except TypeError:
                            punishment_method[punishment](userid, adminid)
                    return True
                else:
                    es.dbgmsg(
                        0, "xapunishments.py: Cannot find method '" +
                        str(punishment_method[punishment]) + "'!")
                    return False
            else:
                if userid not in dead_delayed:
                    dead_delayed[userid] = []
                dead_delayed[userid].append(punishment, adminid, args, force)
                xapunishments.logging.log(
                    "will be punished when he next spawns", userid)
                es.tell(
                    adminid,
                    xalanguage("dead", {'username': es.getplayername(userid)},
                               playerlib.getPlayer(adminid).get("lang")))
                return False
        else:
            es.tell(
                adminid,
                xalanguage("immune", {'username': es.getplayername(userid)},
                           playerlib.getPlayer(adminid).get("lang")))
            return False
    else:
        es.tell(
            adminid,
            xalanguage("not allowed", (),
                       playerlib.getPlayer(adminid).get("lang")))
        return False
Esempio n. 46
0
def rpg_medic():
    gamethread.delayedname(5.0, 'rpg_%s' %(skillname), rpg_medic, ())
    for i in playerlib.getUseridList('#ct, #alive'):
        x1, y1, z1 = es.getplayerlocation(i)
        # Get level of that skill
        level = playerlist[i].GetSkillLevel(skillname)
        if level == 0:
            continue
        for j in playerlib.getUseridList('#ct, #alive'):
            if i == j:
                continue
            x2, y2, z2 = es.getplayerlocation(j)
            if math.sqrt((x2-x1)**2 + (y2-y1)**2 + (z2-z1)**2) <= 300:
                rpg_heal(level, playerlist[j])   
    for i in playerlib.getUseridList('#t, #alive'):
        x1,y1,z1 = es.getplayerlocation(i)
        healer = playerlist[i]  
        for j in playerlib.getUseridList('#t, #alive'):
            if i == j:
                continue
            x2, y2, z2 = es.getplayerlocation(j)
            if math.sqrt((x2-x1)**2 + (y2-y1)**2 + (z2-z1)**2) <= 300:
                rpg_heal(level, playerlist[j])                                   
Esempio n. 47
0
    def send(self, name, filter_type):
        if name not in self.__loaded__:
            raise NameError('"%s" is not a loaded menu name.' % name)

        elif str(filter_type).isdigit():
            menu_instance = self.get_menu_by_name(name)
            self.call_block(menu_instance, "send_menu", filter_type)

        elif str(filter_type).startswith("#"):
            for userid in getUseridList(filter_type):
                self.send(name, userid)

        else:
            raise ValueError('"%s" is not a value filter/userid' % filter_type)
Esempio n. 48
0
def rpg_medic():
    gamethread.delayedname(rpgMedicInterval, 'rpg_%s' %(skillname), rpg_medic, ())
    for i in playerlib.getUseridList('#ct, #alive'):
        x1, y1, z1 = es.getplayerlocation(i)
        # Get level of that skill
        level = playerlist[i].GetSkillLevel(skillname)
        if level == 0:
            continue
        for j in playerlib.getUseridList('#ct, #alive'):
            if i == j:
                continue
            x2, y2, z2 = es.getplayerlocation(j)
            if math.sqrt((x2-x1)**2 + (y2-y1)**2 + (z2-z1)**2) <= rpgMedicDistance:
                rpg_heal(level, playerlist[j])   
    for i in playerlib.getUseridList('#t, #alive'):
        x1,y1,z1 = es.getplayerlocation(i)
        healer = playerlist[i]  
        for j in playerlib.getUseridList('#t, #alive'):
            if i == j:
                continue
            x2, y2, z2 = es.getplayerlocation(j)
            if math.sqrt((x2-x1)**2 + (y2-y1)**2 + (z2-z1)**2) <= rpgMedicDistance:
                rpg_heal(level, playerlist[j])                                   
Esempio n. 49
0
    def send(self, name, filter_type):
        if name not in self.__loaded__:
            raise NameError('"%s" is not a loaded menu name.' % name)

        elif str(filter_type).isdigit():
            menu_instance = self.get_menu_by_name(name)
            self.call_block(menu_instance, 'send_menu', filter_type)

        elif str(filter_type).startswith('#'):
            for userid in getUseridList(filter_type):
                self.send(name, userid)

        else:
            raise ValueError('"%s" is not a value filter/userid' % filter_type)
Esempio n. 50
0
    def toptext(self, filter, duration, color, string, tokens={}):
        # Setup filter
        filter = self.__format_filter(filter)

        # Check if this is a normal message
        if not str(string) in __strings__:
            # Send message to the userid
            if isinstance(filter, int):
                return es.toptext(filter, duration, color, string)

            # Send message to the userids from the playerlib filter
            for userid in getUseridList(filter):
                es.toptext(userid, duration, color, string)
        else:
            # Send message to the userid
            if isinstance(filter, int):
                return es.toptext(filter, duration, color,
                                  self.__format_string(string, tokens, filter))

            # Send message to the userids from the playerlib filter
            for userid in getUseridList(filter):
                es.toptext(userid, duration, color,
                           self.__format_string(string, tokens, userid))
Esempio n. 51
0
def wcs_ulti_suicide():
	userid = int(es.ServerVar('wcs_userid'))

	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'))
			magnitude = float(es.ServerVar('wcs_magnitude'))
			v = round(radius * magnitude) / 150

			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, v, userid)

					else:
						es.tell(user, '#multi', '#lightgreenYour ultimate was blocked, the enemy is #greenimmune.')
						es.tell(userid, '#multi', '#lightgreenYou #greenblocked #lightgreenan ultimate skill.')
def load():
    global gui, gui2
    gui = lambda x: x.replace('#green','').replace('#default','').replace('#lightgreen','')
    gui2 = lambda x,y: gui(x.replace('#lightgreen%s'%y,'   '))
    xavictimstats.xasettings.registerMethod(xavictimstats, sendmenu, xalang['Victim Stats Options'])
    xavictimstatscommand = xavictimstats.addCommand('xa_victimstatssetting', sendmenu, 'victimstats_settingtings', 'UNRESTRICTED')
    xavictimstatscommand.register(['console', 'server'])

    if str(victimstats_command):
        xavictimstatssaycommand = xavictimstats.addCommand(str(victimstats_command), display, 'victim_stats', 'UNRESTRICTED', 'Send player stats while alive')
        xavictimstatssaycommand.register(['say'])

    for userid in playerlib.getUseridList('#human'):
        gamethread.queue(default, str(userid))