All pastes #520710 Raw Edit

Unnamed

public lua v1 · immutable
#520710 ·published 2007-05-30 00:39 UTC
rendered paste body
// Include needed filesinclude( 'tables.lua' )// Entity informationENT.Type = "anim"ENT.Base = "base_entity"lastCheckTime = 0shouldCheck = 1// Grab our custom keyvaluefunction ENT:KeyValue(key, value)	if ( key != "cleMap" ) then		self[key] = tonumber(value)	else		self[key] = value	endend // Called when the entity first spawnsfunction ENT:Initialize()	currentMap = game.GetMap()	playersInBox = 0		// Decide what map is next	for a, mapName in pairs( mapOrder ) do		if ( mapName == currentMap ) then			nextMapKey = a + 1		end	end		// Check to see if we have reacehd the end of the game	if mapOrder[nextMapKey] != nil then		nextMap = mapOrder[nextMapKey]	else		nextMap = "d1_canals_01"	end		// Get the details of the changelevel trigger this particular ent is for and then delete it	changeLevelEntities = ents.FindByClass( "trigger_changelevel" )	for cleCount, changeLevelEnt in pairs( changeLevelEntities ) do		if ( cleCount == self.cleNumber ) then			mapTLCMin, mapTLCMax = changeLevelEnt:WorldSpaceAABB()				// Find out of this entity goes to the next one or not			if ( self.cleMap == nextMap ) then				entGoToNext = 1				Msg("=== Spawned go to next\n")			else				entGoToNext = 0				Msg("=== Spawned block\n")			end				// Finally, remove the entitiy			changeLevelEnt:Remove()		end	end		// Decide the size of the trigger	w = mapTLCMax.x - mapTLCMin.x	l = mapTLCMax.y - mapTLCMin.y	h = mapTLCMax.z - mapTLCMin.z		//Vectors	local myTDLMin = Vector(0-(w/2),0-(l/2),0-(h/2))	local myTDLMax = Vector(w/2,l/2,h/2)	  	//Set  box	self.Entity:PhysicsInitBox(myTDLMin, myTDLMax)	  	//Set collision bounds	self.Entity:SetCollisionBounds(myTDLMin, myTDLMax)		// Set right type of collision	if ( entGoToNext == 1 ) then		self.Entity:SetCollisionGroup(19)	else		self.Entity:SetCollisionGroup(4)			end		// We need this i guess	self.Entity:SetTrigger(true)end// Execute this when a player touches the entityfunction ENT:StartTouch(hitEnt)	if ( entGoToNext == 1 ) then		if hitEnt:IsValid() && hitEnt:IsPlayer() then			hitEnt:Freeze(true)			hitEnt:SetCollisionGroup(1)			playersInBox = playersInBox + 1			local playersInServer = table.Count(player.GetAll())						// Let everyone know that someone entered the loading section			for _, pl in pairs(player.GetAll()) do				pl:PrintMessage(HUD_PRINTTALK, hitEnt:Nick().." has entered the loading section ("..playersInBox.."/"..playersInServer..").")			end		end	endend // These are needed to keep console from flipping outfunction ENT:Touch()endfunction ENT:OnTakeDamage()endfunction ENT:PhysicsUpdate()endfunction ENT:PhysicsCollide()endfunction ENT:Use()end// If the player decides to leave the box :(function ENT:EndTouch(hitEnt)	if ( entGoToNext == 1 ) then		if hitEnt:IsValid() && hitEnt:IsPlayer() then			hitEnt:Freeze(false)			hitEnt:SetCollisionGroup(5)			playersInBox = playersInBox - 1		end	endend // Check to see if we have the right number of people in the box every secondfunction ENT:Think()	if ( entGoToNext == 1 ) then		if lastCheckTime + 1 < CurTime() and shouldCheck == 1 then			playersInServer = table.Count(player.GetAll())						// Are we ready to go to the next level?			if playersInServer != 0 and playersInBox >= playersInServer then				shouldCheck = 0								// Let everyone know we are switching				for _, pl in pairs(player.GetAll()) do					pl:PrintMessage(HUD_PRINTTALK, "Switching to "..nextMap.." in 5 seconds.")				end								// Switch the map in 5 seconds				timer.Create("delayload_timer", 5, 1, game.ConsoleCommand, "changegamemode "..nextMap.." hl2-campaign\n")			end						// Update last check time			lastCheckTime = CurTime()		end	endend