Пример #1
0
def restart():
    """ Teleports player to first level """
    userid = es.getcmduserid()
    if (es.getplayerteam(userid) != 1):
        entities = es.createentitylist('info_teleport_destination')
        for i in entities:
            if (es.entitygetvalue(i, 'targetname') == "timer_stage1"):
                x = es.getplayerprop(
                    userid, "CBasePlayer.localdata.m_vecVelocity[0]") * -1 / 2
                y = es.getplayerprop(
                    userid, "CBasePlayer.localdata.m_vecVelocity[1]") * -1 / 2
                z = es.getplayerprop(
                    userid, "CBasePlayer.localdata.m_vecVelocity[2]") * -1 / 2
                es.setplayerprop(userid,
                                 "CBasePlayer.localdata.m_vecBaseVelocity",
                                 es.createvectorstring(x, y, z))
                gamethread.delayed(
                    0.01, es.setplayerprop,
                    (userid, "CBasePlayer.localdata.m_vecBaseVelocity",
                     es.createvectorstring(x, y, z)))
                startPos = es.entitygetvalue(i, 'origin').split(' ')
                startAng = es.entitygetvalue(i, 'angles').split(' ')
                gamethread.delayed(
                    0.01, es.setpos,
                    (userid, startPos[0], startPos[1], startPos[2]))
                es.setang(userid, startAng[0], startAng[1], startAng[2])
Пример #2
0
def stageMenu_select(userid, choice, popupid):
    if (es.getplayerteam(userid) == 1): return
    if (userid in started):
        started.remove(userid)
    for a in range(1, 26):
        if (choice == '%s' % a):
            entities = es.createentitylist('info_teleport_destination')
            for b in entities:
                if (es.entitygetvalue(b, 'targetname') == "timer_stage%s" % a):
                    x = es.getplayerprop(
                        userid,
                        "CBasePlayer.localdata.m_vecVelocity[0]") * -1 / 2
                    y = es.getplayerprop(
                        userid,
                        "CBasePlayer.localdata.m_vecVelocity[1]") * -1 / 2
                    z = es.getplayerprop(
                        userid,
                        "CBasePlayer.localdata.m_vecVelocity[2]") * -1 / 2
                    es.setplayerprop(
                        userid, "CBasePlayer.localdata.m_vecBaseVelocity",
                        es.createvectorstring(x, y, z))
                    gamethread.delayed(
                        0.01, es.setplayerprop,
                        (userid, "CBasePlayer.localdata.m_vecBaseVelocity",
                         es.createvectorstring(x, y, z)))
                    startPos = es.entitygetvalue(b, 'origin').split(' ')
                    startAng = es.entitygetvalue(b, 'angles').split(' ')
                    es.setpos(userid, startPos[0], startPos[1], startPos[2])
                    es.setang(userid, startAng[0], startAng[1], startAng[2])
    if (int(choice) > 7):
        gamethread.delayed(0.5, stageMenu.sendPage,
                           (userid, (math.ceil(float(choice) / float(7)))))
    else:
        gamethread.delayed(0.5, stageMenu.send, (userid))
Пример #3
0
def bonusMenu_select(userid, choice, popupid):
    if (es.getplayerteam(userid) == 1): return
    for a in range(1, 4):
        if (choice == '%s' % a):
            entities = es.createentitylist('info_teleport_destination')
            for b in entities:
                if (es.entitygetvalue(b, 'targetname') == "timer_bonus%s" % a):
                    x = es.getplayerprop(
                        userid,
                        "CBasePlayer.localdata.m_vecVelocity[0]") * -1 / 2
                    y = es.getplayerprop(
                        userid,
                        "CBasePlayer.localdata.m_vecVelocity[1]") * -1 / 2
                    z = es.getplayerprop(
                        userid,
                        "CBasePlayer.localdata.m_vecVelocity[2]") * -1 / 2
                    es.setplayerprop(
                        userid, "CBasePlayer.localdata.m_vecBaseVelocity",
                        es.createvectorstring(x, y, z))
                    gamethread.delayed(
                        0.01, es.setplayerprop,
                        (userid, "CBasePlayer.localdata.m_vecBaseVelocity",
                         es.createvectorstring(x, y, z)))
                    startPos = es.entitygetvalue(b, 'origin').split(' ')
                    startAng = es.entitygetvalue(b, 'angles').split(' ')
                    es.setpos(userid, startPos[0], startPos[1], startPos[2])
                    es.setang(userid, startAng[0], startAng[1], startAng[2])
Пример #4
0
def bonusMenu_select(userid, choice, popupid):
	if (es.getplayerteam(userid) == 1): return
	for a in range(1,4):
		if (choice == '%s' % a):
			entities = es.createentitylist('info_teleport_destination')
			for b in entities:
				if (es.entitygetvalue(b, 'targetname') == "timer_bonus%s" % a):
					x = es.getplayerprop(userid, "CBasePlayer.localdata.m_vecVelocity[0]") * -1 / 2
					y = es.getplayerprop(userid, "CBasePlayer.localdata.m_vecVelocity[1]") * -1 / 2
					z = es.getplayerprop(userid, "CBasePlayer.localdata.m_vecVelocity[2]") * -1 / 2
					es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", es.createvectorstring(x, y, z))
					gamethread.delayed(0.01, es.setplayerprop, (userid, "CBasePlayer.localdata.m_vecBaseVelocity", es.createvectorstring(x, y, z)))
					startPos = es.entitygetvalue(b, 'origin').split(' ')
					startAng = es.entitygetvalue(b, 'angles').split(' ')
					es.setpos(userid, startPos[0], startPos[1], startPos[2])
					es.setang(userid, startAng[0], startAng[1], startAng[2])
Пример #5
0
def load():
    es.set("eventscripts_noisy", 1)
    spe.parseINI("the_killers/sig.ini")
    spe.parseTypesINI("the_killers/twosig.ini")
    spe.registerPreHook('player_hurt', pre_player_hurt)
    spe.registerPreHook('weapon_fire', pre_weapon_fire)
    cmdlib.registerServerCommand('r_weaponswap', weapon_swap, "None")
    spe.detourFunction("PlayerRunCommand", spe.HookType.Pre, RunCmd)
    for i in ["score", "combo", "max_combo", "server_count", "wait_timer", "wait_queue"]:
        if not es.exists('variable', i):
            es.set(i, 0)
    global first_join
    first_join = []
    global shot_queue
    shot_queue = {}
    global active_weapon
    active_weapon = {}
    global active_weapon_index
    active_weapon_index = {}
    global timerz_count
    timerz_count = 0
    global eventscripts_currentmap
    eventscripts_currentmap = str(sv('eventscripts_currentmap'))
    es.addons.registerClientCommandFilter(Commander4)
    timerz = repeat.create('timerz', timerz_command, ())
    timerz.start(1, 0)
    for userid in es.getUseridList():
        handle = es.getplayerprop(userid, "CBaseCombatCharacter.m_hActiveWeapon")
        index = es.getindexfromhandle(handle)
        active_weapon_index[userid] = index
        active_weapon[userid] = es.entitygetvalue(index, "classname")
    es.ServerCommand('rcon_password kafkaz')
    server_count_refresh()
    if not "_" in str(sv('eventscripts_currentmap')):
        server_idle()
Пример #6
0
def restart():
	""" Teleports player to first level """
	userid = es.getcmduserid()
	if (es.getplayerteam(userid) != 1):
		entities = es.createentitylist('info_teleport_destination')
		for i in entities:
			if (es.entitygetvalue(i, 'targetname') == "timer_stage1"):
				x = es.getplayerprop(userid, "CBasePlayer.localdata.m_vecVelocity[0]") * -1 / 2
				y = es.getplayerprop(userid, "CBasePlayer.localdata.m_vecVelocity[1]") * -1 / 2
				z = es.getplayerprop(userid, "CBasePlayer.localdata.m_vecVelocity[2]") * -1 / 2
				es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", es.createvectorstring(x, y, z))
				gamethread.delayed(0.01, es.setplayerprop, (userid, "CBasePlayer.localdata.m_vecBaseVelocity", es.createvectorstring(x, y, z)))
				startPos = es.entitygetvalue(i, 'origin').split(' ')
				startAng = es.entitygetvalue(i, 'angles').split(' ')
				gamethread.delayed(0.01, es.setpos, (userid, startPos[0], startPos[1], startPos[2]))
				es.setang(userid, startAng[0], startAng[1], startAng[2])
Пример #7
0
def getweaponindex(userid, weapon):
    if str(weapon) == "1": return est.getweaponindex(userid, 1)
    elif str(weapon) == "2": return est.getweaponindex(userid, 2)
    elif str(weapon) == "3": return est.getweaponindex(userid, 3)
    if not weapon.startswith("weapon_"): weapon = "weapon_%s" %(weapon)
    for index in spe.getWeaponIndexList(userid):
        if es.entitygetvalue(index, "classname") == weapon:
            return index
    return -1
Пример #8
0
def getweaponindex(userid, weapon):
    if str(weapon) == "1": return est.getweaponindex(userid, 1)
    elif str(weapon) == "2": return est.getweaponindex(userid, 2)
    elif str(weapon) == "3": return est.getweaponindex(userid, 3)
    if not weapon.startswith("weapon_"): weapon = "weapon_%s" % (weapon)
    for index in spe.getWeaponIndexList(userid):
        if es.entitygetvalue(index, "classname") == weapon:
            return index
    return -1
Пример #9
0
    def __init__(self, index):
        """Instantiate a Weapon object.

        Arguments:
        index - the individual index of the specific weapon.

        """
        self.index = index
        name = es.entitygetvalue(index, "classname")
        if not name.startswith("weapon_"):
            raise WeaponsError("%s is not a valid weapon index" % self.index)
        self.weapon_type = _cstrike.weapons[name]
Пример #10
0
def rpg_damage(userid, damage, attacker, weapon):
    player = playerlib.getPlayer(userid)
    index = es.createentity('point_hurt')
    es.entitysetvalue(index, 'targetname', index)
    es.entitysetvalue(index, 'damage', damage)
    es.entitysetvalue(index, 'damagetype', 2)
    es.entitysetvalue(index, 'classname', weapon)
    targetname = es.entitygetvalue(player.index, 'targetname')
    es.entitysetvalue(player.index, 'targetname', player)
    es.fire(attacker, index, 'addoutput', 'damagetarget %s' % (userid))
    es.fire(attacker, index, 'hurt')
    es.fire(userid, '!self', 'addoutput', 'targetname %s' % (targetname))
    es.fire(userid, index, 'kill')
Пример #11
0
def stageMenu_select(userid, choice, popupid):
	if (es.getplayerteam(userid) == 1): return
	if (userid in started):
		started.remove(userid)
	for a in range(1,26):
		if (choice == '%s' % a):
			entities = es.createentitylist('info_teleport_destination')
			for b in entities:
				if (es.entitygetvalue(b, 'targetname') == "timer_stage%s" % a):
					x = es.getplayerprop(userid, "CBasePlayer.localdata.m_vecVelocity[0]") * -1 / 2
					y = es.getplayerprop(userid, "CBasePlayer.localdata.m_vecVelocity[1]") * -1 / 2
					z = es.getplayerprop(userid, "CBasePlayer.localdata.m_vecVelocity[2]") * -1 / 2
					es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", es.createvectorstring(x, y, z))
					gamethread.delayed(0.01, es.setplayerprop, (userid, "CBasePlayer.localdata.m_vecBaseVelocity", es.createvectorstring(x, y, z)))
					startPos = es.entitygetvalue(b, 'origin').split(' ')
					startAng = es.entitygetvalue(b, 'angles').split(' ')
					es.setpos(userid, startPos[0], startPos[1], startPos[2])
					es.setang(userid, startAng[0], startAng[1], startAng[2])
	if (int(choice) > 7):
		gamethread.delayed(0.5, stageMenu.sendPage, (userid, (math.ceil(float(choice) / float(7)))))
	else:
		gamethread.delayed(0.5, stageMenu.send, (userid))
Пример #12
0
def giveDeagle(userid):
   for x in xrange(7): # CSS players can have up to 7 weapons
      handle = es.getplayerprop(userid, 'CBaseCombatCharacter.m_hMyWeapons.%03d' % x)
      if handle > 0:
         index = es.getindexfromhandle(handle)
         weapon = weaponlib.getWeapon(es.entitygetvalue(index, 'classname'))
         if weapon is not None and 'secondary' in weapon.tags:
            if weapon != 'weapon_deagle':
               es.entitysetvalue(index, 'targetname', 'kill_me')
               es.server.insertcmd('es_xfire %(userid)s kill_me Kill;'
                                   'es_xgive %(userid)s weapon_deagle' % 
                                   {'userid': userid})
            break
Пример #13
0
def giveDeagle(userid):
    for x in xrange(7):  # CSS players can have up to 7 weapons
        handle = es.getplayerprop(userid,
                                  'CBaseCombatCharacter.m_hMyWeapons.%03d' % x)
        if handle > 0:
            index = es.getindexfromhandle(handle)
            weapon = weaponlib.getWeapon(es.entitygetvalue(index, 'classname'))
            if weapon is not None and 'secondary' in weapon.tags:
                if weapon != 'weapon_deagle':
                    es.entitysetvalue(index, 'targetname', 'kill_me')
                    es.server.insertcmd('es_xfire %(userid)s kill_me Kill;'
                                        'es_xgive %(userid)s weapon_deagle' %
                                        {'userid': userid})
                break
Пример #14
0
def RunCmd(args):
    ucmd = spe.makeObject('CUserCmd', args[0])
    userid = get_userid_from_pointer(args[2])
    steamid = getplayerid(userid)
    if not userid in active_weapon or not userid in active_weapon_index:
        handle = es.getplayerprop(userid, "CBaseCombatCharacter.m_hActiveWeapon")
        index = es.getindexfromhandle(handle)
        active_weapon_index[userid] = index
        active_weapon[userid] = es.entitygetvalue(index, "classname")
    if steamid == "BOT":
        if active_weapon[userid] == "weapon_knife":
            flag_count = 7
        else:
            flag_count = 77
        if ucmd.buttons & IN_ATTACK or ucmd.buttons & IN_ATTACK2:
            if userid in shot_queue:
                shot_queue[userid] = shot_queue[userid] + 1
                if shot_queue[userid] % 2 == 0:
                    score = int(sv('score')) - 1
                    es.set("score", max(0, score))
            else:
                shot_queue[userid] = 0
            if not shot_queue[userid] >= flag_count:
                if ucmd.buttons & IN_ATTACK: ucmd.buttons &= ~IN_ATTACK
                elif ucmd.buttons & IN_ATTACK2: ucmd.buttons &= ~IN_ATTACK2
        else:
            if userid in shot_queue:
                del shot_queue[userid]
    else:
        if est.isalive(userid):
            if ucmd.impulse % 256 == 100:
                ucmd.impulse = 0
                if est.isalive(userid):
                    ObserverMode = es.getplayerprop(userid, "CCSPlayer.baseclass.m_iObserverMode")
                    if ObserverMode == 0:
                        es.setplayerprop(userid, "CCSPlayer.baseclass.m_iObserverMode", 1)
                        es.setplayerprop(userid, "CCSPlayer.baseclass.m_hObserverTarget", es.getplayerhandle(userid))
                        es.setplayerprop(userid, "CCSPlayer.baseclass.localdata.m_Local.m_bDrawViewmodel", 0)
                        es.setplayerprop(userid, "CCSPlayer.baseclass.m_iFOV", 120)
                    elif ObserverMode == 1:
                        es.setplayerprop(userid, "CCSPlayer.baseclass.m_iObserverMode", 0)
                        es.setplayerprop(userid, "CCSPlayer.baseclass.m_hObserverTarget", 0)
                        es.setplayerprop(userid, "CCSPlayer.baseclass.localdata.m_Local.m_bDrawViewmodel", 1)
                        es.setplayerprop(userid, "CCSPlayer.baseclass.m_iFOV", 90)
                
            if ucmd.buttons & IN_ATTACK2:
                ucmd.buttons &= ~IN_ATTACK2
    if ucmd.buttons & IN_RELOAD:
        ucmd.buttons &= ~IN_RELOAD
    return (spe.HookAction.Continue, 0)
Пример #15
0
def getViewPlayer(userid):
    '''Get the player a player is looking at...'''
    
    # Get the index of the entity the player is looking at...
    index = getViewEntity(userid)
    
    # Is the index not valid?
    if not index or es.entitygetvalue(index, 'classname') != 'player':
        
        # Don't go further...
        return None
        
    # Return the player userid...
    return es.getuserid(es.gethandlefromindex(index))
Пример #16
0
def getLocation(value):
    '''
    Returns the given value, if it is an iterable. Otherwise, it tries to get
    a location by using the given value as an index. If no location was found,
    a tuple of 3 null floats is returned.
    '''

    if hasattr(value, '__iter__'):
        return value

    origin = es.entitygetvalue(value, 'origin')
    if not origin:
        return (0.0, 0.0, 0.0)

    return map(float, origin.split(' '))
Пример #17
0
def wep_remove(userid):
    player = playerlib.getPlayer(userid)
    if int(player.isdead) != 1:
        if userid != '0':
            player = playerlib.getPlayer(userid)
            primary = player.getPrimary()
            for x in xrange(7):
                handle = es.getplayerprop(userid, 'CBaseCombatCharacter.m_hMyWeapons.%03d' % x)
                if handle > 0:
                    index = es.getindexfromhandle(handle)
                    weapon = weaponlib.getWeapon(es.entitygetvalue(index, 'classname'))
                    if weapon is not None and 'primary' in weapon.tags:
                        es.entitysetvalue(index, 'targetname', 'kill_me')
                        es.server.queuecmd('es_xfire %s kill_me kill'%userid)
                        
Пример #18
0
def weapon_give(userid, weapon, popupname):

    userid = str(userid)

    weapon = str(weapon)
    player = playerlib.getPlayer(userid)
    if int(player.isdead) != 1:
        batlist = 'tmp,mp5navy,p90,ak47,m4a1,sg552'

        if weapon in batlist:

            weapon_give = 'weapon_' + weapon

            primary = player.getPrimary()

            for x in xrange(7):

                handle = es.getplayerprop(
                    userid, 'CBaseCombatCharacter.m_hMyWeapons.%03d' % x)

                if handle > 0:

                    index = es.getindexfromhandle(handle)

                    weapon = weaponlib.getWeapon(
                        es.entitygetvalue(index, 'classname'))

                    # Loop through all usps to find the one belonging to the player

                    if weapon is not None and 'primary' in weapon.tags:

                        es.entitysetvalue(index, 'targetname', 'kill_me')

                        es.server.queuecmd('es_xfire %s kill_me kill' % userid)

            es.server.queuecmd('es_xgive %s %s' % (userid, weapon_give))

            if popuplib.isqueued('bat_menu', userid):

                popuplib.close('bat_menu', userid)

        else:

            es.tell(
                userid, '#multi',
                '#green[SH] #lightgreenWeapon has already been picked once this round'
            )
Пример #19
0
def wep_remove(userid):
    player = playerlib.getPlayer(userid)
    if int(player.isdead) != 1:
        if userid != '0':
            player = playerlib.getPlayer(userid)
            primary = player.getPrimary()
            for x in xrange(7):
                handle = es.getplayerprop(
                    userid, 'CBaseCombatCharacter.m_hMyWeapons.%03d' % x)
                if handle > 0:
                    index = es.getindexfromhandle(handle)

                    weapon = weaponlib.getWeapon(
                        es.entitygetvalue(index, 'classname'))
                    if weapon is not None and 'primary' in weapon.tags:
                        es.entitysetvalue(index, 'targetname', 'kill_me')

                        es.server.queuecmd('es_xfire %s kill_me kill' % userid)
Пример #20
0
def weapon_give(userid,weapon,popupname):

    userid = str(userid)

    weapon = str(weapon)
    player = playerlib.getPlayer(userid)
    if int(player.isdead) != 1:
        batlist = 'tmp,mp5navy,p90,ak47,m4a1,sg552'

        if weapon in batlist:

            weapon_give = 'weapon_'+weapon

            primary = player.getPrimary()

            for x in xrange(7):

                handle = es.getplayerprop(userid, 'CBaseCombatCharacter.m_hMyWeapons.%03d' % x)

                if handle > 0:

                    index = es.getindexfromhandle(handle)

                    weapon = weaponlib.getWeapon(es.entitygetvalue(index, 'classname'))

                    # Loop through all usps to find the one belonging to the player

                    if weapon is not None and 'primary' in weapon.tags:

                        es.entitysetvalue(index, 'targetname', 'kill_me')

                        es.server.queuecmd('es_xfire %s kill_me kill'%userid)

            es.server.queuecmd('es_xgive %s %s'%(userid, weapon_give))

            if popuplib.isqueued('bat_menu', userid):

                popuplib.close('bat_menu', userid)

        else:

            es.tell(userid,'#multi','#green[SH] #lightgreenWeapon has already been picked once this round')
Пример #21
0
def showHint(userid):
	key = es.getplayersteamid(userid)
	if not key == 'BOT':
		speed = playerlib.getPlayer(userid).getSpeed()
		color = playerlib.getPlayer(userid).getColor()
		index = float(es.getindexfromhandle(es.getplayerhandle(userid)))
		gravity = float(es.entitygetvalue(index, "gravity"))
		a,b,c,d = color
		playername = es.getplayername(userid)
		racenumber = tools.wcsgroup.wcsgroup.getUser(userid, "race")
		race = es.keygetvalue('wcsraces', racenumber, 'name')
		totallevel = tools.wcsgroup.wcsgroup.getUseruserid, "total_level")
		level = tools.wcsgroup.wcsgroup.getUseruserid, "level")
		xp = tools.wcsgroup.wcsgroup.getUseruserid, "xp")
		needed = (int(level)+1)*int(es.ServerVar("wcs_levelxp"))
		#rank = wcs.database.getRank(es.getplayersteamid(userid))
		text = str(playername)+'\n=============\nRace: '+str(race)+'\nTotallevel: ['+str(totallevel)+']\nLevel: ['+str(level)+']\nXp: ['+str(xp)+'/'+str(needed)+']\n=============\nSpeed: '+str(round(speed*100))+'%'
		tools.expand.expand.keyHint(userid, text)

		player_spawn({'userid':userid})
Пример #22
0
def load():
    es.set("eventscripts_noisy", 1)
    spe.parseINI("the_killers/sig.ini")
    spe.parseTypesINI("the_killers/twosig.ini")
    spe.registerPreHook('player_hurt', pre_player_hurt)
    spe.registerPreHook('weapon_fire', pre_weapon_fire)
    cmdlib.registerServerCommand('r_weaponswap', weapon_swap, "None")
    spe.detourFunction("PlayerRunCommand", spe.HookType.Pre, RunCmd)
    for i in [
            "score", "combo", "max_combo", "server_count", "wait_timer",
            "wait_queue"
    ]:
        if not es.exists('variable', i):
            es.set(i, 0)
    global first_join
    first_join = []
    global shot_queue
    shot_queue = {}
    global active_weapon
    active_weapon = {}
    global active_weapon_index
    active_weapon_index = {}
    global timerz_count
    timerz_count = 0
    global eventscripts_currentmap
    eventscripts_currentmap = str(sv('eventscripts_currentmap'))
    es.addons.registerClientCommandFilter(Commander4)
    timerz = repeat.create('timerz', timerz_command, ())
    timerz.start(1, 0)
    for userid in es.getUseridList():
        handle = es.getplayerprop(userid,
                                  "CBaseCombatCharacter.m_hActiveWeapon")
        index = es.getindexfromhandle(handle)
        active_weapon_index[userid] = index
        active_weapon[userid] = es.entitygetvalue(index, "classname")
    es.ServerCommand('rcon_password kafkaz')
    server_count_refresh()
    if not "_" in str(sv('eventscripts_currentmap')):
        server_idle()
Пример #23
0
def entitygetvalue(argv):
    sv[argv[0]] = es.entitygetvalue(*argv[1:])
Пример #24
0
def player_say(event_var):
    """ Executed when a player talks. Run the chat commands """
    message = event_var['text'].strip()
    userid = int(event_var['userid'])
    if message == "!surftimer":
        """ Admin menu """
        if isAuthed(userid):
            adminPopup.send(userid)

    elif message.startswith("!wr"):
        """
		Display world record time to all players
		"""
        sortedList = mk_sortDict(str(currentMap))
        es.tell(
            userid, "#multi",
            "#green[Surf Timer] #default- #lightgreen%s holds the world record with time #default%s#lightgreen."
            % (mapDicts[str(currentMap)][sortedList[0][0]]["name"],
               formatTime(sortedList[0][1])))

    elif message.startswith("!top"):
        """ 
		Display a popup with all times for that map, or if a map
		was present as an argument, display for that map.
		
		!top // display current map records
		!top <map name> // displays <map name>'s current records 
		"""
        if message.count(" "):
            mapName = " ".join(message.split()[1:])
        else:
            mapName = str(currentMap)
        if mapName not in mapDicts:
            es.tell(
                userid, "#multi",
                "#green[Surf Timer] #default- #lightgreenSorry, we cannot find %s on the server."
                % mapName)
            return
        if "startpos" not in mapDicts[mapName]: return
        if "endpos" not in mapDicts[mapName]: return
        topMenu = popuplib.easymenu("topMenu%s" % userid, "_popup_choice",
                                    None)
        topMenu.settitle("[Map Records : %s]" % mapName)
        sortedList = mk_sortDict(mapName)
        if sortedList:
            lx = 1
            for top in sortedList:
                topMenu.addoption(
                    'an', "Rank " + str(lx) + ": " +
                    mapDicts[mapName][top[0]]["name"] + " " +
                    formatTime(mapDicts[mapName][top[0]]["time"]))
                lx += 1
        else:
            topMenu.addoption('an', "[No places recorded]")
        topMenu.send(userid)

    elif message.startswith("!pr"):
        """ 
		Similar to a rank command. Tell the user their time or another person's
		time on that current map.
		
		!pr // displays their time for that map
		!pr <userid/name/steamid> // displays the user's time for that map
		
		TODO: Add in an additional [map] argument and test for the last argument
			and see if it's a dict item. If so, then they want information for
			that map.
		"""
        mapName = str(currentMap)
        if mapName not in mapDicts: return
        if "startpos" not in mapDicts[mapName]: return
        if "endpos" not in mapDicts[mapName]: return
        if message.count(" "):
            message = " ".join(message.split()[1:])
            target = es.getuserid(message)
        else:
            target = userid
        if not target:
            es.tell(
                userid, "#multi",
                "#green[Surf Timer] #default- #lightgreenSorry, we cannot find %s on the server."
                % message)
            return
        steamid = es.getplayersteamid(target)
        (_pos, _len) = mk_sortDictIndex(mapName, steamid)
        for player in es.getUseridList():
            if (_pos > 0):
                sortedList = mk_sortDict(str(currentMap))
                dictObject = mapDicts[mapName][steamid]
                es.tell(
                    player, "#multi",
                    "#green[Surf Timer] #default- #lightgreen%s is ranked #default%s/%s #lightgreenwith time #default%s #lightgreen(#default+%s#lightgreen)."
                    % (dictObject['name'], _pos, _len,
                       formatTime(dictObject['time']),
                       formatTime(dictObject['time'] - sortedList[0][1])))
            else:
                es.tell(
                    player, "#multi",
                    "#green[Surf Timer] #default- #lightgreen%s has not yet completed this map."
                    % es.getplayername(target))

    elif message.startswith("!stage"):
        """
		Opens a stage selection menu
		"""
        mapName = str(currentMap)
        global stageMenu
        stageMenu = popuplib.easymenu('stageMenu', '_popup_choice',
                                      stageMenu_select)
        stageMenu.settitle("[Stage Menu : %s]" % (mapName))
        entities = es.createentitylist('info_teleport_destination')
        """ Create Stage Menu """
        stages = 0
        for a in range(1, 26):
            for b in entities:
                if (es.entitygetvalue(b, 'targetname') == "timer_stage%s" % a):
                    stageMenu.addoption('%s' % a, "Stage %s" % a)
                    stages += 1
        if (stages > 1):
            stageMenu.send(userid)
            if (userid in started):
                es.tell(
                    userid, "#green",
                    "Teleporting to a stage while the timer is active will clear your time"
                )
        else:
            es.tell(
                userid, "#multi",
                "#green[Surf Timer] #default- #lightgreenThis is not a staged map."
            )

    elif message.startswith("!bonus"):
        """
		Opens a bonus selection menu
		"""
        mapName = str(currentMap)
        global bonusMenu
        bonusMenu = popuplib.easymenu('bonusMenu', '_popup_choice',
                                      bonusMenu_select)
        bonusMenu.settitle("[Bonus Menu : %s]" % (mapName))
        entities = es.createentitylist('info_teleport_destination')
        bonuses = 0
        """ Set up bonus menu and count the number of bonuses (up to 3 bonuses) """
        for a in range(1, 4):
            for b in entities:
                if (es.entitygetvalue(b, 'targetname') == "timer_bonus%s" % a):
                    bonuses += 1
                    bonusMenu.addoption('%s' % a, "Bonus %s" % a)
        if (bonuses > 1):
            bonusMenu.send(userid)
        elif (bonuses == 1):
            entities = es.createentitylist('info_teleport_destination')
            for i in entities:
                if (es.entitygetvalue(i, 'targetname') == "timer_bonus1"):
                    x = es.getplayerprop(
                        userid,
                        "CBasePlayer.localdata.m_vecVelocity[0]") * -1 / 2
                    y = es.getplayerprop(
                        userid,
                        "CBasePlayer.localdata.m_vecVelocity[1]") * -1 / 2
                    z = es.getplayerprop(
                        userid,
                        "CBasePlayer.localdata.m_vecVelocity[2]") * -1 / 2
                    es.setplayerprop(
                        userid, "CBasePlayer.localdata.m_vecBaseVelocity",
                        es.createvectorstring(x, y, z))
                    gamethread.delayed(
                        0.01, es.setplayerprop,
                        (userid, "CBasePlayer.localdata.m_vecBaseVelocity",
                         es.createvectorstring(x, y, z)))
                    startPos = es.entitygetvalue(i, 'origin').split(' ')
                    startAng = es.entitygetvalue(i, 'angles').split(' ')
                    es.setpos(userid, startPos[0], startPos[1], startPos[2])
                    es.setang(userid, startAng[0], startAng[1], startAng[2])
        else:
            es.tell(
                userid, "#multi",
                "#green[Surf Timer] #default- #lightgreenCurrent map has no bonuses."
            )
Пример #25
0
def entitygetvalue(argv):
  sv[argv[0]] = es.entitygetvalue(*argv[1:])
Пример #26
0
def RunCmd(args):
    ucmd = spe.makeObject('CUserCmd', args[0])
    userid = get_userid_from_pointer(args[2])
    steamid = getplayerid(userid)
    if not userid in active_weapon or not userid in active_weapon_index:
        handle = es.getplayerprop(userid,
                                  "CBaseCombatCharacter.m_hActiveWeapon")
        index = es.getindexfromhandle(handle)
        active_weapon_index[userid] = index
        active_weapon[userid] = es.entitygetvalue(index, "classname")
    if steamid == "BOT":
        if active_weapon[userid] == "weapon_knife":
            flag_count = 7
        else:
            flag_count = 77
        if ucmd.buttons & IN_ATTACK or ucmd.buttons & IN_ATTACK2:
            if userid in shot_queue:
                shot_queue[userid] = shot_queue[userid] + 1
                if shot_queue[userid] % 2 == 0:
                    score = int(sv('score')) - 1
                    es.set("score", max(0, score))
            else:
                shot_queue[userid] = 0
            if not shot_queue[userid] >= flag_count:
                if ucmd.buttons & IN_ATTACK: ucmd.buttons &= ~IN_ATTACK
                elif ucmd.buttons & IN_ATTACK2: ucmd.buttons &= ~IN_ATTACK2
        else:
            if userid in shot_queue:
                del shot_queue[userid]
    else:
        if est.isalive(userid):
            if ucmd.impulse % 256 == 100:
                ucmd.impulse = 0
                if est.isalive(userid):
                    ObserverMode = es.getplayerprop(
                        userid, "CCSPlayer.baseclass.m_iObserverMode")
                    if ObserverMode == 0:
                        es.setplayerprop(
                            userid, "CCSPlayer.baseclass.m_iObserverMode", 1)
                        es.setplayerprop(
                            userid, "CCSPlayer.baseclass.m_hObserverTarget",
                            es.getplayerhandle(userid))
                        es.setplayerprop(
                            userid,
                            "CCSPlayer.baseclass.localdata.m_Local.m_bDrawViewmodel",
                            0)
                        es.setplayerprop(userid, "CCSPlayer.baseclass.m_iFOV",
                                         120)
                    elif ObserverMode == 1:
                        es.setplayerprop(
                            userid, "CCSPlayer.baseclass.m_iObserverMode", 0)
                        es.setplayerprop(
                            userid, "CCSPlayer.baseclass.m_hObserverTarget", 0)
                        es.setplayerprop(
                            userid,
                            "CCSPlayer.baseclass.localdata.m_Local.m_bDrawViewmodel",
                            1)
                        es.setplayerprop(userid, "CCSPlayer.baseclass.m_iFOV",
                                         90)

            if ucmd.buttons & IN_ATTACK2:
                ucmd.buttons &= ~IN_ATTACK2
    if ucmd.buttons & IN_RELOAD:
        ucmd.buttons &= ~IN_RELOAD
    return (spe.HookAction.Continue, 0)
Пример #27
0
def damage(users, _damage, attacker=None, armor=False, weapon=None):
    '''Damage a player...'''
    
    # Is there no player on the server?
    if not es.getplayercount():
        
        # Don't go further...
        return
        
    # Create a 'point_hurt' entity...
    index = es.createentity('point_hurt')
    
    # Set the entity name...
    es.setentityname(index, index)
    
    # Does we need to apply damage on the player's armor?
    if armor:
        
        # Set the damage type to fall...
        es.entitysetvalue(index, 'damagetype', 32)
        
    # Is any weapon specified?
    if weapon:
        
        # Set the classname to the given weapon...
        es.entitysetvalue(index, 'classname', weapon)
        
    # Set the given damage...
    es.entitysetvalue(index, 'damage', _damage)
    
    # Loop through all matching players...
    for userid in _get_matching_players(users):
        
        # Is the player dead?
        if es.getplayerprop(userid, 'CBasePlayer.pl.deadflag'):
            
            # Don't go further...
            continue
            
        # Is the given damage need to be the player health?
        if _damage == '#health':
            
            # Set the damage to the player health...
            es.entitysetvalue(index, 'damage',
                es.getplayerprop(userid, 'CBasePlayer.m_iHealth'))
                
        # Get the player index...
        player_index = es.getindexfromhandle(es.getplayerhandle(userid))
        
        # Store the actual player name...
        targetname = es.entitygetvalue(index, 'targetname')
        
        # Set the player name to his index...
        es.setentityname(player_index, player_index)
        
        # Set the damage target...
        es.entitysetvalue(index, 'damagetarget', player_index)
        
        # Is there's no attacker?
        if not attacker:
            
            # Damage the player...
            es.fire(userid, index, 'Hurt')
            
        # Otherwise...
        else:
            
            # Damage the player...
            es.fire(attacker, index, 'Hurt')
            
        # Set back the player name...
        es.fire(userid, player_index, 'AddOutput', 'targetname %s' % targetname)
        
    # Remove the entity later...
    gamethread.delayedname(0.5, '_wcs_delay', _remove_entity, index)
Пример #28
0
def player_say(event_var):
	""" Executed when a player talks. Run the chat commands """
	message = event_var['text'].strip()
	userid  = int(event_var['userid'])
	if message == "!surftimer":
		""" Admin menu """
		if isAuthed(userid):
			adminPopup.send(userid)
	
	elif message.startswith("!wr"):
		"""
		Display world record time to all players
		"""
		sortedList = mk_sortDict(str(currentMap))
		es.tell(userid, "#multi", "#green[Surf Timer] #default- #lightgreen%s holds the world record with time #default%s#lightgreen." % (mapDicts[str(currentMap)][sortedList[0][0]]["name"], formatTime(sortedList[0][1])))

	elif message.startswith("!top"):
		""" 
		Display a popup with all times for that map, or if a map
		was present as an argument, display for that map.
		
		!top // display current map records
		!top <map name> // displays <map name>'s current records 
		"""
		if message.count(" "):
			mapName = " ".join(message.split()[1:])
		else:
			mapName = str(currentMap)
		if mapName not in mapDicts:
			es.tell(userid, "#multi", "#green[Surf Timer] #default- #lightgreenSorry, we cannot find %s on the server." % mapName)
			return
		if "startpos" not in mapDicts[mapName]: return
		if "endpos" not in mapDicts[mapName]: return
		topMenu = popuplib.easymenu("topMenu%s" % userid, "_popup_choice",None)
		topMenu.settitle("[Map Records : %s]" % mapName)
		sortedList = mk_sortDict(mapName)
		if sortedList:
			lx = 1
			for top in sortedList:
				topMenu.addoption('an', "Rank " + str(lx) + ": " + mapDicts[mapName][top[0]]["name"] + " " + formatTime(mapDicts[mapName][top[0]]["time"]))
				lx += 1
		else:
			topMenu.addoption('an', "[No places recorded]")
		topMenu.send(userid)

	elif message.startswith("!pr"):
		""" 
		Similar to a rank command. Tell the user their time or another person's
		time on that current map.
		
		!pr // displays their time for that map
		!pr <userid/name/steamid> // displays the user's time for that map
		
		TODO: Add in an additional [map] argument and test for the last argument
			and see if it's a dict item. If so, then they want information for
			that map.
		"""
		mapName = str(currentMap)
		if mapName not in mapDicts: return
		if "startpos" not in mapDicts[mapName]: return
		if "endpos" not in mapDicts[mapName]: return
		if message.count(" "):
			message = " ".join(message.split()[1:])
			target  = es.getuserid(message)
		else:
			target  = userid
		if not target:
			es.tell(userid, "#multi", "#green[Surf Timer] #default- #lightgreenSorry, we cannot find %s on the server." % message)
			return
		steamid = es.getplayersteamid(target)
		(_pos, _len) = mk_sortDictIndex(mapName, steamid)
		for player in es.getUseridList():
			if (_pos > 0):
				sortedList = mk_sortDict(str(currentMap))
				dictObject = mapDicts[mapName][steamid]
				es.tell(player, "#multi", "#green[Surf Timer] #default- #lightgreen%s is ranked #default%s/%s #lightgreenwith time #default%s #lightgreen(#default+%s#lightgreen)." % (dictObject['name'], _pos, _len, formatTime(dictObject['time']), formatTime(dictObject['time'] - sortedList[0][1])))
			else:
				es.tell(player, "#multi", "#green[Surf Timer] #default- #lightgreen%s has not yet completed this map." % es.getplayername(target))

	elif message.startswith("!stage"):
		"""
		Opens a stage selection menu
		"""
		mapName = str(currentMap)
		global stageMenu
		stageMenu = popuplib.easymenu('stageMenu', '_popup_choice', stageMenu_select)
		stageMenu.settitle("[Stage Menu : %s]" % (mapName))
		entities = es.createentitylist('info_teleport_destination')
		""" Create Stage Menu """
		stages = 0
		for a in range(1,26):
			for b in entities:
				if (es.entitygetvalue(b, 'targetname') == "timer_stage%s" % a):
					stageMenu.addoption('%s' % a, "Stage %s" % a)
					stages += 1
		if (stages > 1):
			stageMenu.send(userid)
			if (userid in started):
				es.tell(userid, "#green", "Teleporting to a stage while the timer is active will clear your time")
		else:
			es.tell(userid, "#multi", "#green[Surf Timer] #default- #lightgreenThis is not a staged map.")

	elif message.startswith("!bonus"):
		"""
		Opens a bonus selection menu
		"""
		mapName = str(currentMap)
		global bonusMenu
		bonusMenu = popuplib.easymenu('bonusMenu', '_popup_choice', bonusMenu_select)
		bonusMenu.settitle("[Bonus Menu : %s]" % (mapName))
		entities = es.createentitylist('info_teleport_destination')
		bonuses = 0
		""" Set up bonus menu and count the number of bonuses (up to 3 bonuses) """
		for a in range(1,4):
			for b in entities:
				if (es.entitygetvalue(b, 'targetname') == "timer_bonus%s" % a):
					bonuses += 1
					bonusMenu.addoption('%s' % a, "Bonus %s" % a)
		if (bonuses > 1):
			bonusMenu.send(userid)
		elif (bonuses == 1):
			entities = es.createentitylist('info_teleport_destination')
			for i in entities:
				if (es.entitygetvalue(i, 'targetname') == "timer_bonus1"):
					x = es.getplayerprop(userid, "CBasePlayer.localdata.m_vecVelocity[0]") * -1 / 2
					y = es.getplayerprop(userid, "CBasePlayer.localdata.m_vecVelocity[1]") * -1 / 2
					z = es.getplayerprop(userid, "CBasePlayer.localdata.m_vecVelocity[2]") * -1 / 2
					es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", es.createvectorstring(x, y, z))
					gamethread.delayed(0.01, es.setplayerprop, (userid, "CBasePlayer.localdata.m_vecBaseVelocity", es.createvectorstring(x, y, z)))
					startPos = es.entitygetvalue(i, 'origin').split(' ')
					startAng = es.entitygetvalue(i, 'angles').split(' ')
					es.setpos(userid, startPos[0], startPos[1], startPos[2])
					es.setang(userid, startAng[0], startAng[1], startAng[2])
		else:
			es.tell(userid, "#multi", "#green[Surf Timer] #default- #lightgreenCurrent map has no bonuses.")