Results 1 to 3 of 3

Thread: Auto Checkpoints for my new K~PortalMap

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Private
    Join Date
    Oct 2012
    Posts
    10
    Thanks
    2
    Thanked 22 Times in 8 Posts
    Hey,

    you have many ways to add cp's. I think you want that the players will spawn at the reached cp? Then I would replace the killtrigger with teleporter, i think it's the best way for the players, because nobody like killtrigger. :P

    But it's your choice what to do, I will show you one way without triggers, only with script.

    Code:
    main()
    {
    	// Add it where ever you need
    	initCheckpoints();
    }
    
    initCheckpoints()
    {
    
    /***********************************************************************
    	Copy "loadCheckpoint" how many you want...
    	
    	The first value is the cp number, first must be 0 (zero).
    	
    	Replace "X, Y, Z" with coordinates of the cp location 
    	where the cp need to work.
    	
    	The 150 value is for the radius, and 100 for the 
    	height where the cp will work.
    ***********************************************************************/
    
    	loadCheckpoint(0,(X, Y, Z),150,100);
    	loadCheckpoint(1,(X, Y, Z),150,100);
    	loadCheckpoint(2,(X, Y, Z),150,100);
    	loadCheckpoint(3,(X, Y, Z),150,100);
    	loadCheckpoint(4,(X, Y, Z),150,100);	
    	
    	// It will check every cp (load it only one time)
    	thread onCheckpoint();
    }
    
    loadCheckpoint(num,coordinates,radius,height)
    {
    	level.cpTrig[num]=spawnstruct();
    	level.cpTrig[num].origin=coordinates;
    	level.cpTrig[num].radius=radius;
    	level.cpTrig[num].height=height;
    }	
    	
    onCheckpoint()
    {
    	if(isDefined(level.cpTrig))
    	{
    		for(i=0;i<level.cpTrig.size;i++)
    		{
    			cp=level.cpTrig[i];
    			cp.origin=(cp.origin[0],cp.origin[1],(cp.origin[2]-16));
    		}
    		count=0;
    
    		while(1)
    		{
    			players=getEntArray("player","classname");
    			count=0;
    			
    			for(i=0;i<players.size;i++)
    			{
    				player=players[i];
    				if(isDefined(player) && isDefined(player.pers["team"]) && player.pers["team"]!="spectator" && player.sessionstate=="playing")
    				{
    					player _checkCp();
    					
    					count++;
    					if(!(count%4))
    					{
    						wait .05;
    						count=0;
    					}
    				}
    			}
    			wait .05;
    		}
    	}
    }
    
    _checkCp()
    {
    	for(i=0;i<level.cpTrig.size;i++)
    	{
    		cp=level.cpTrig[i];
    		diff=cp.origin-self.origin;	
    		if(self.origin[2]>=cp.origin[2] && self.origin[2]<=cp.origin[2]+cp.height)
    		{
    			diff2=(diff[0],diff[1],0);
    			if(length(diff2)<cp.radius+16)
    			{
    				if(self.pers["team"]!="spectator" && self isOnGround() && isAlive(self))
    				{
    					if(!isDefined(self.spawnCp) || (isDefined(self.spawnCp) && self.spawnCp<i))
    					{
    						self.spawnCp=i;
    						self.spawnAng=self getPlayerAngles();
    						self.spawnOrg=self getOrigin();
    						self iPrintLnBold("^2Checkpoint "+(i+1)+"/"+level.cpTrig.size+" reached!");
    					}
    					if(!isDefined(self.playerSpawnCheck))
    						self thread onPlayerSpawn();
    				}
    				return;
    			}
    		}
    	}
    }
    
    onPlayerSpawn()
    {
    	self endon("disconnect");
    	
    	self.playerSpawnCheck=true;
    	while(1)
    	{
    		self waittill("spawned");
    		self thread doPlayerSpawn();
    	}
    }
    
    doPlayerSpawn()
    {
    	if(!isDefined(self.spawnCp) || !isDefined(self.spawnAng) || !isDefined(self.spawnOrg))
    		return;
    	
    	if(self.pers["team"]!="spectator" && isAlive(self))
    	{
    		self setOrigin(self.spawnOrg);
    		self setPlayerAngles((0,self.spawnAng[1],self.spawnAng[2]));
    		self iPrintLnBold("^2Checkpoint loaded!");
    	}
    }
    Last edited by DisSle; 2nd November 2012 at 10:08.

  2. The Following 4 Users Say Thank You to DisSle For This Useful Post:

    2ReaL (11th November 2012),CoRdELL (11th November 2012),kung foo man (2nd November 2012),STAUFFi (2nd November 2012)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •