Esempio n. 1
0
def getSiteIndex(centerpos):
    for index in es.createentitylist('func_bomb_target'):
        current_min = vecmath.vector(es.getindexprop(index, 'CBaseEntity.m_Collision.m_vecMins'))
        current_max = vecmath.vector(es.getindexprop(index, 'CBaseEntity.m_Collision.m_vecMaxs'))
        if vecmath.isbetweenRect(centerpos, current_min, current_max):
             return index
    return 0
Esempio n. 2
0
def getSiteIndex(centerpos):
    for index in es.createentitylist('func_bomb_target'):
        current_min = vecmath.vector(
            es.getindexprop(index, 'CBaseEntity.m_Collision.m_vecMins'))
        current_max = vecmath.vector(
            es.getindexprop(index, 'CBaseEntity.m_Collision.m_vecMaxs'))
        if vecmath.isbetweenRect(centerpos, current_min, current_max):
            return index
    return 0
Esempio n. 3
0
def checkLoop():
	""" Iterate through a list of all the players and check their location """
	try:
		for player in es.getUseridList():
			if (player in started) and (int(es.getplayerteam(player)) > 1):
				lowerVertex, upperVertex = mapDicts[str(currentMap)]["endpos"]
				timeTaken = time.time() - players[player][0]
				if vecmath.isbetweenRect(es.getplayerlocation(player), lowerVertex, upperVertex):
					""" Player has finished... """
					""" Add their time to the dictionary which will save """
					""" Tell all users that he finished and append his ID to the finished list """
					steamid = es.getplayersteamid(player)
					sortedList = mk_sortDict(str(currentMap))
					""" Check if the player is in first place """
					if sortedList:
						if (timeTaken < sortedList[0][1]):
							if steamid not in mapDicts[str(currentMap)]:
								mapDicts[str(currentMap)][steamid] = {'time':timeTaken, 'name':es.getplayername(player)}
								(_pos, _len) = mk_sortDictIndex(str(currentMap), es.getplayersteamid(player))
								for userid in es.getUseridList():
									es.tell(userid, "#multi", "#green[Surf Timer] #default- #lightgreen%s has finished in #default%s #lightgreen(#default-%s#lightgreen) with rank #default%s/%s#lightgreen." % (es.getplayername(player), formatTime(timeTaken), formatTime(sortedList[0][1] - timeTaken), _pos, _len))
									es.tell(userid, "#multi", "#green[Surf Timer] #default- #lightgreen%s has broken the world record!" % es.getplayername(player))
							else:
								temp = mapDicts[str(currentMap)][steamid]['time']
								mapDicts[str(currentMap)][steamid]['time']  = timeTaken
								(_pos, _len) = mk_sortDictIndex(str(currentMap), es.getplayersteamid(player))
								for userid in es.getUseridList():
									es.tell(userid, "#multi", "#green[Surf Timer] #default- #lightgreen%s has finished in #default%s #lightgreen(#default-%s#lightgreen) with rank #default%s/%s#lightgreen, improving by #default%s#lightgreen." % (es.getplayername(player), formatTime(timeTaken), formatTime(sortedList[0][1] - timeTaken), _pos, _len, formatTime(temp - timeTaken)))
									es.tell(userid, "#multi", "#green[Surf Timer] #default- #lightgreen%s has broken the world record!" % es.getplayername(player))
							for userid in es.getUseridList():
								es.playsound(userid, "ui/vote_started.wav", 1.0)
								gamethread.delayed(1.5, es.playsound, (userid, "vo/announcer_am_killstreak02.wav", 1.0))
						else:
							if steamid not in mapDicts[str(currentMap)]:
								mapDicts[str(currentMap)][steamid] = {'time':timeTaken, 'name':es.getplayername(player)}
								(_pos, _len) = mk_sortDictIndex(str(currentMap), es.getplayersteamid(player))
								for userid in es.getUseridList():
									es.tell(userid, "#multi", "#green[Surf Timer] #default- #lightgreen%s has finished in #default%s #lightgreen(#default+%s#lightgreen) with rank #default%s/%s#lightgreen." % (es.getplayername(player), formatTime(timeTaken), formatTime(timeTaken - sortedList[0][1]), _pos, _len))
							else:
								if (mapDicts[str(currentMap)][steamid]['time'] > timeTaken):
									temp = mapDicts[str(currentMap)][steamid]['time']
									mapDicts[str(currentMap)][steamid]['time']  = timeTaken
									(_pos, _len) = mk_sortDictIndex(str(currentMap), es.getplayersteamid(player))
									for userid in es.getUseridList():
										es.tell(userid, "#multi", "#green[Surf Timer] #default- #lightgreen%s has finished in #default%s #lightgreen(#default+%s#lightgreen) with rank #default%s/%s#lightgreen, improving by #default%s#lightgreen." % (es.getplayername(player), formatTime(timeTaken), formatTime(timeTaken - sortedList[0][1]), _pos, _len, formatTime(temp - timeTaken)))
								else:
									(_pos, _len) = mk_sortDictIndex(str(currentMap), es.getplayersteamid(player))
									for userid in es.getUseridList():
										es.tell(userid, "#multi", "#green[Surf Timer] #default- #lightgreen%s has finished in #default%s #lightgreen(#default+%s#lightgreen)." % (es.getplayername(player), formatTime(timeTaken), formatTime(timeTaken - sortedList[0][1])))
							for userid in es.getUseridList():
								es.playsound(userid, "ui/scored.wav", 0.5)
					#Else block below contributed by Lange for SurfiT
					else:
						if steamid not in mapDicts[str(currentMap)]:
							mapDicts[str(currentMap)][steamid] = {'time':timeTaken, 'name':es.getplayername(player)}
							(_pos, _len) = mk_sortDictIndex(str(currentMap), es.getplayersteamid(player))
							for userid in es.getUseridList():
								es.tell(userid, "#multi", "#green[Surf Timer] #default- #lightgreen%s has finished in #default%s with rank #default%s/%s#lightgreen." % (es.getplayername(player), formatTime(timeTaken), _pos, _len))
						else:
							if (mapDicts[str(currentMap)][steamid]['time'] > timeTaken):
								temp = mapDicts[str(currentMap)][steamid]['time']
								mapDicts[str(currentMap)][steamid]['time']  = timeTaken
								(_pos, _len) = mk_sortDictIndex(str(currentMap), es.getplayersteamid(player))
								for userid in es.getUseridList():
									es.tell(userid, "#multi", "#green[Surf Timer] #default- #lightgreen%s has finished in #default%s with rank #default%s/%s#lightgreen, improving by #default%s#lightgreen." % (es.getplayername(player), formatTime(timeTaken), _pos, _len, formatTime(temp - timeTaken)))
							else:
								(_pos, _len) = mk_sortDictIndex(str(currentMap), es.getplayersteamid(player))
								for userid in es.getUseridList():
									es.tell(userid, "#multi", "#green[Surf Timer] #default- #lightgreen%s has finished in #default%s#lightgreen." % (es.getplayername(player), formatTime(timeTaken)))
						for userid in es.getUseridList():
							es.playsound(userid, "ui/scored.wav", 0.5)
						
					started.remove(player)
					#End Lange modifications
				else:
					lowerVertex, upperVertex = mapDicts[str(currentMap)]["startpos"]
					if vecmath.isbetweenRect(es.getplayerlocation(player), lowerVertex, upperVertex):
						players[player] = [time.time(), 0]
			elif (int(es.getplayerteam(player)) > 1):
				c_player = playerlib.getPlayer(player)
				if (c_player.attributes["isdead"] == 0):
					lowerVertex, upperVertex = mapDicts[str(currentMap)]["startpos"]
					if vecmath.isbetweenRect(es.getplayerlocation(player), lowerVertex, upperVertex):
						""" Player has started """
						tokens = {}
						tokens['name'] = es.getplayername(player)
						tell(player, "started", tokens)
						started.append(player)
						players[player] = [time.time(), 0]
		gamethread.delayedname(0.1, 'surftime_checkloop', checkLoop)
	except KeyError:
		pass
Esempio n. 4
0
def checkLoop():
    """ Iterate through a list of all the players and check their location """
    try:
        for player in es.getUseridList():
            if (player in started) and (int(es.getplayerteam(player)) > 1):
                lowerVertex, upperVertex = mapDicts[str(currentMap)]["endpos"]
                timeTaken = time.time() - players[player][0]
                if vecmath.isbetweenRect(es.getplayerlocation(player),
                                         lowerVertex, upperVertex):
                    """ Player has finished... """
                    """ Add their time to the dictionary which will save """
                    """ Tell all users that he finished and append his ID to the finished list """
                    steamid = es.getplayersteamid(player)
                    sortedList = mk_sortDict(str(currentMap))
                    """ Check if the player is in first place """
                    if sortedList:
                        if (timeTaken < sortedList[0][1]):
                            if steamid not in mapDicts[str(currentMap)]:
                                mapDicts[str(currentMap)][steamid] = {
                                    'time': timeTaken,
                                    'name': es.getplayername(player)
                                }
                                (_pos, _len) = mk_sortDictIndex(
                                    str(currentMap),
                                    es.getplayersteamid(player))
                                for userid in es.getUseridList():
                                    es.tell(
                                        userid, "#multi",
                                        "#green[Surf Timer] #default- #lightgreen%s has finished in #default%s #lightgreen(#default-%s#lightgreen) with rank #default%s/%s#lightgreen."
                                        % (es.getplayername(player),
                                           formatTime(timeTaken),
                                           formatTime(sortedList[0][1] -
                                                      timeTaken), _pos, _len))
                                    es.tell(
                                        userid, "#multi",
                                        "#green[Surf Timer] #default- #lightgreen%s has broken the world record!"
                                        % es.getplayername(player))
                            else:
                                temp = mapDicts[str(
                                    currentMap)][steamid]['time']
                                mapDicts[str(
                                    currentMap)][steamid]['time'] = timeTaken
                                (_pos, _len) = mk_sortDictIndex(
                                    str(currentMap),
                                    es.getplayersteamid(player))
                                for userid in es.getUseridList():
                                    es.tell(
                                        userid, "#multi",
                                        "#green[Surf Timer] #default- #lightgreen%s has finished in #default%s #lightgreen(#default-%s#lightgreen) with rank #default%s/%s#lightgreen, improving by #default%s#lightgreen."
                                        % (es.getplayername(player),
                                           formatTime(timeTaken),
                                           formatTime(sortedList[0][1] -
                                                      timeTaken), _pos, _len,
                                           formatTime(temp - timeTaken)))
                                    es.tell(
                                        userid, "#multi",
                                        "#green[Surf Timer] #default- #lightgreen%s has broken the world record!"
                                        % es.getplayername(player))
                            for userid in es.getUseridList():
                                es.playsound(userid, "ui/vote_started.wav",
                                             1.0)
                                gamethread.delayed(
                                    1.5, es.playsound,
                                    (userid,
                                     "vo/announcer_am_killstreak02.wav", 1.0))
                        else:
                            if steamid not in mapDicts[str(currentMap)]:
                                mapDicts[str(currentMap)][steamid] = {
                                    'time': timeTaken,
                                    'name': es.getplayername(player)
                                }
                                (_pos, _len) = mk_sortDictIndex(
                                    str(currentMap),
                                    es.getplayersteamid(player))
                                for userid in es.getUseridList():
                                    es.tell(
                                        userid, "#multi",
                                        "#green[Surf Timer] #default- #lightgreen%s has finished in #default%s #lightgreen(#default+%s#lightgreen) with rank #default%s/%s#lightgreen."
                                        % (es.getplayername(player),
                                           formatTime(timeTaken),
                                           formatTime(timeTaken -
                                                      sortedList[0][1]), _pos,
                                           _len))
                            else:
                                if (mapDicts[str(currentMap)][steamid]['time']
                                        > timeTaken):
                                    temp = mapDicts[str(
                                        currentMap)][steamid]['time']
                                    mapDicts[str(currentMap)][steamid][
                                        'time'] = timeTaken
                                    (_pos, _len) = mk_sortDictIndex(
                                        str(currentMap),
                                        es.getplayersteamid(player))
                                    for userid in es.getUseridList():
                                        es.tell(
                                            userid, "#multi",
                                            "#green[Surf Timer] #default- #lightgreen%s has finished in #default%s #lightgreen(#default+%s#lightgreen) with rank #default%s/%s#lightgreen, improving by #default%s#lightgreen."
                                            % (es.getplayername(player),
                                               formatTime(timeTaken),
                                               formatTime(timeTaken -
                                                          sortedList[0][1]),
                                               _pos, _len,
                                               formatTime(temp - timeTaken)))
                                else:
                                    (_pos, _len) = mk_sortDictIndex(
                                        str(currentMap),
                                        es.getplayersteamid(player))
                                    for userid in es.getUseridList():
                                        es.tell(
                                            userid, "#multi",
                                            "#green[Surf Timer] #default- #lightgreen%s has finished in #default%s #lightgreen(#default+%s#lightgreen)."
                                            % (es.getplayername(player),
                                               formatTime(timeTaken),
                                               formatTime(timeTaken -
                                                          sortedList[0][1])))
                            for userid in es.getUseridList():
                                es.playsound(userid, "ui/scored.wav", 0.5)
                    #Else block below contributed by Lange for SurfiT
                    else:
                        if steamid not in mapDicts[str(currentMap)]:
                            mapDicts[str(currentMap)][steamid] = {
                                'time': timeTaken,
                                'name': es.getplayername(player)
                            }
                            (_pos, _len) = mk_sortDictIndex(
                                str(currentMap), es.getplayersteamid(player))
                            for userid in es.getUseridList():
                                es.tell(
                                    userid, "#multi",
                                    "#green[Surf Timer] #default- #lightgreen%s has finished in #default%s with rank #default%s/%s#lightgreen."
                                    % (es.getplayername(player),
                                       formatTime(timeTaken), _pos, _len))
                        else:
                            if (mapDicts[str(currentMap)][steamid]['time'] >
                                    timeTaken):
                                temp = mapDicts[str(
                                    currentMap)][steamid]['time']
                                mapDicts[str(
                                    currentMap)][steamid]['time'] = timeTaken
                                (_pos, _len) = mk_sortDictIndex(
                                    str(currentMap),
                                    es.getplayersteamid(player))
                                for userid in es.getUseridList():
                                    es.tell(
                                        userid, "#multi",
                                        "#green[Surf Timer] #default- #lightgreen%s has finished in #default%s with rank #default%s/%s#lightgreen, improving by #default%s#lightgreen."
                                        % (es.getplayername(player),
                                           formatTime(timeTaken), _pos, _len,
                                           formatTime(temp - timeTaken)))
                            else:
                                (_pos, _len) = mk_sortDictIndex(
                                    str(currentMap),
                                    es.getplayersteamid(player))
                                for userid in es.getUseridList():
                                    es.tell(
                                        userid, "#multi",
                                        "#green[Surf Timer] #default- #lightgreen%s has finished in #default%s#lightgreen."
                                        % (es.getplayername(player),
                                           formatTime(timeTaken)))
                        for userid in es.getUseridList():
                            es.playsound(userid, "ui/scored.wav", 0.5)

                    started.remove(player)
                    #End Lange modifications
                else:
                    lowerVertex, upperVertex = mapDicts[str(
                        currentMap)]["startpos"]
                    if vecmath.isbetweenRect(es.getplayerlocation(player),
                                             lowerVertex, upperVertex):
                        players[player] = [time.time(), 0]
            elif (int(es.getplayerteam(player)) > 1):
                c_player = playerlib.getPlayer(player)
                if (c_player.attributes["isdead"] == 0):
                    lowerVertex, upperVertex = mapDicts[str(
                        currentMap)]["startpos"]
                    if vecmath.isbetweenRect(es.getplayerlocation(player),
                                             lowerVertex, upperVertex):
                        """ Player has started """
                        tokens = {}
                        tokens['name'] = es.getplayername(player)
                        tell(player, "started", tokens)
                        started.append(player)
                        players[player] = [time.time(), 0]
        gamethread.delayedname(0.1, 'surftime_checkloop', checkLoop)
    except KeyError:
        pass