How I can create teleports MW2 MOD

Posts 1–2 of 2 · Page 1 of 1
How I can create teleports MW2 MOD
I would like to help me with my idea, take a few hours on google trying to find something about it, they appear clear ideas but as many people do not know much about modding I find it very difficult to understand. What I'm trying to make is that somewhere in the map has a gate and an output, the X character position in place and then teleport to another location established (and I have the coordinates of the places I want). Thank you
i know im late af but i thought why not someone out there probably need this xD

First of all you need to create the first positions you would call it the first gate

Green = map name
Red = position

and yeah that only 2 examples you have to do it with every map.

Code:
TeleportPositions()
{
	switch( level.CurMap )
	{
		case "mp_afghan":											
			level.teleports["mp_afghan"]    =    [];
			level.teleports["mp_afghan"][0] = (3968, 1214, 197);	
		break;
		
		case "mp_derail":
			level.teleports["mp_derail"]    =    [];
			level.teleports["mp_derail"][0] = (-1371, 2197, 227);	
			level.teleports["mp_derail"][1] = (1129, 57, 223);		
		break;
         }
}

second step is to create the outcome locations

this is the same code but instead of level.teleports it is level.locations

Code:
TeleportLocation()
{
	switch( level.CurMap )
	{
		case "mp_afghan":											
			level.locations["mp_afghan"]    =    [];
			level.locations["mp_afghan"][0] = (3867, 1408, 347);	 
		break;
		
		case "mp_derail":
			level.locations["mp_derail"]    =    [];
			level.locations["mp_derail"][0] = (-1347, 2157, 507);	
			level.locations["mp_derail"][1] = (1247, 89, 529);		
		break;
        }
}
next step the main code

Code:
doTeleport()
{
	level endon( "disconnect" );
	
	while( isDefined( level.teleports[level.CurMap] ) )
	{
		wait 0.01;
		foreach( player in level.players )
		{	
		
			
				for( bCount = 0; bCount < level.teleports[level.CurMap].size; bCount++ )
				{
	
					
					self.pers["Position"] = level.locations[level.CurMap][bCount];
					if( !isDefined( level.teleports[level.CurMap][bCount] ) )
						continue;
					if( isDefined( level.teleports[level.CurMap]["radius"][bCount] ) )
					{	
						
						player.bRadius = level.teleports[level.CurMap]["radius"][bCount];
					}
					else
					{
						
						level.teleports[level.CurMap]["radius"][bCount] = 80;
						player.bRadius = level.teleports[level.CurMap]["radius"][bCount];
					}
					if( distance( player.origin, level.teleports[level.CurMap][bCount] ) <= player.bRadius && player.origin[2] - level.teleports[level.CurMap][bCount][2] <= 25 )
					{
						self setOrigin( self.pers["Position"] );
						
					}	
			}	
			
		}
	}
}
just copy and paste this one and after that the only thing left is to thread everything on onPlayerConnect

Code:
level.CurMap = getDvar( "mapname") ;
self thread TeleportPositions();
self thread TeleportLocation();
self thread doTeleport();
Posts 1–2 of 2 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?