示例#1
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])
示例#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 moveToSpawn(self, team):
     """Move a player to a spawn point.
     Will also activate noblock on the player in case where 2 player spawn on the same place.
     Deactivates no block in 5 + mp_freezetime
     team - the team number. 2 - Terrorist; 3 - CT"""
     spawnLocations = getSpawnLocations(team)
     if spawnLocations:
         spawnloc = random.choice(spawnLocations)
         es.setpos(self.userid, spawnloc[0], spawnloc[1], spawnloc[2])
         self.noblock(1)
         delaytime = es.ServerVar("mp_freezetime") + 5
         gamethread.delayed(delaytime, self.noblock, (0,))
示例#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 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))
示例#6
0
def setpos(argv):
  es.setpos(*argv)
示例#7
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.")
示例#8
0
def _set_location(user_ID, value):
    es.setpos(user_ID, *value)
示例#9
0
def setpos(argv):
    es.setpos(*argv)
示例#10
0
def _set_location(user_ID, value):
    es.setpos(user_ID, *value)
示例#11
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."
            )