Making a teleport in Carentan

Have questions about CoD/UO mapping that aren't covered in the tutorials section? Post here!

Moderator: Core Staff

Post Reply
xeno
CJ Wannabe
CJ Wannabe
Posts: 38
Joined: October 31st, 2007, 12:37 am
Location: United States - GA

Making a teleport in Carentan

Post by xeno » May 25th, 2010, 7:41 pm

Hey, I am trying to make a teleporter in carentan. I tried using the distance command to check for the players origin and if they are within like 5 feet and press f they will be teleported but for some reason it doesn't work. Maybe I got the coordinates wrong... but dunno. I used the command /viewpos while in call of duty to get the coordinates of where my players was standing.

Here is my code:

Code: Select all

s_tele3()//teleporter in carentan
{	
	self endon("boot");

	setcvar("s_tele3", "");
	while(1)
	{
		if(getcvar("s_tele3") != "")
		{
			players = getentarray("player", "classname");
			for(i = 0; i < players.size; i++)
			{
					if (getcvar("mapname") == "mp_carentan")
					{
						iprintln("Map is Carentan");//Check 1
						players[i].useheld = .2;
						if(((distance(players[i].origin,(247, 1111, 68))) < 25))
						{
							iprintlnBold("Check Origin");//Check 2
							if(players[i] useButtonPressed() == true)
           						{
								iprintlnBold("Check Use Key");//Check 3
								if (players[i].useheld == 0.2)
								{
									iprintlnBold("Check Use Key Held");//Check 4
									players[i] setorigin((366, 1254, 684));
									iprintlnBold("Teleported and Check Complete");//Check 5
								}
							}
						}

					}
					else
					{
						iprintlnBold("Wrong map");
					}

			}
			setcvar("s_tele3", "");
		}
		wait 0.05;
	}
}
Image

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Making a teleport in Carentan

Post by Drofder2004 » May 26th, 2010, 12:47 am

Firstly:

instead of looping an if check, you can simply do:

Code: Select all

while(1)
{
   setCvar("s_tele3", "");
   while(getCvar("s_tele3") == "")
      wait 0.5;

   <start code here>
}
Secondly, you are running one loops trying to detect multiple players...
Get your player list and thread them each into a new function.
The new function will contain the code to check for use being pressed.

How far did your "checks" get to?
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

megazor
CJ Worshipper
CJ Worshipper
Posts: 414
Joined: July 22nd, 2009, 3:02 am
Location: Russia, Vladivostok

Re: Making a teleport in Carentan

Post by megazor » May 26th, 2010, 4:06 am

a few notes.
getcvar("mapname") == "mp_carentan"
it wouldn't work if the mapname was mp_CaReNtaN xD use function toLower(sText)

make the code short. if (player useButtonPressed() == true) is the same as if (player useButtonPressed())


call iPrintLnBold() on the player in order not to get confused if there are many players.

Get your player list and thread them each into a new function


why use many functions if it is possible to use only one?

xeno
CJ Wannabe
CJ Wannabe
Posts: 38
Joined: October 31st, 2007, 12:37 am
Location: United States - GA

Re: Making a teleport in Carentan

Post by xeno » May 26th, 2010, 5:53 am

Drofder2004 wrote: How far did your "checks" get to?
It got through the first Check. haha

Code: Select all

iprintln("Map is Carentan");//Check 1
And I couldn't get toLower to work =/ so now I feel stupid.
Image

User avatar
Nightmare
Core Staff
Core Staff
Posts: 2688
Joined: January 12th, 2006, 10:09 pm
Contact:

Re: Making a teleport in Carentan

Post by Nightmare » May 26th, 2010, 6:31 am

Code: Select all

s_tele3()//teleporter in carentan
{   
	self endon("boot");
	if (getcvar("mapname") == "mp_carentan")
	{
		iprintln("Map is Carentan");//Check 1
		while(1)
		{
			players = getentarray("player", "classname");
			for(i = 0; i < players.size; i++)
				players[i] thread teleChecker();
			wait 0.05;
		}
	}
}

teleChecker()
{
	iprintlnBold("Check Origin");//Check 2
	if(distance(self.origin,(247, 1111, 68)) < 25)
	{
		iprintlnBold("You did it.");//Check 4
		self setorigin((366, 1254, 684));	
		iprintlnBold("Teleported and Check Complete");//Check 5
	}
}
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet

-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]

xeno
CJ Wannabe
CJ Wannabe
Posts: 38
Joined: October 31st, 2007, 12:37 am
Location: United States - GA

Re: Making a teleport in Carentan

Post by xeno » May 26th, 2010, 6:50 am

Works. <3
Image

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Making a teleport in Carentan

Post by Drofder2004 » May 27th, 2010, 9:17 pm

Nightmare wrote:

Code: Select all

s_tele3()//teleporter in carentan
{   
	self endon("boot");
	if (getcvar("mapname") == "mp_carentan")
	{
		iprintln("Map is Carentan");//Check 1
		while(1)
		{
			players = getentarray("player", "classname");
			for(i = 0; i < players.size; i++)
				players[i] thread teleChecker();
			wait 0.05;
		}
	}
}

teleChecker()
{
	iprintlnBold("Check Origin");//Check 2
	if(distance(self.origin,(247, 1111, 68)) < 25)
	{
		iprintlnBold("You did it.");//Check 4
		self setorigin((366, 1254, 684));	
		iprintlnBold("Teleported and Check Complete");//Check 5
	}
}
All it needs (if wanted) is the UseButton thing, but otherwise, nicely done!
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Post Reply

Who is online

Users browsing this forum: No registered users and 38 guests