tricky teleporter

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

Moderator: Core Staff

TTTT
CJ Wannabe
CJ Wannabe
Posts: 30
Joined: August 16th, 2009, 5:51 am

tricky teleporter

Post by TTTT » February 13th, 2010, 5:37 pm

i know i ask alot, but you guys are the only ones who actually post helpful replys.

Alright heres my question, I have 6 hidden items on my map. after a person have pressed hes use button on all thoose items, he shoulld be teleported to another place thats unreachable otherwise. is this possible and if it is, how do i make it happen?

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

Re: tricky teleporter

Post by Drofder2004 » February 13th, 2010, 10:11 pm

Code: Select all

main()
{
   thread grabconnectedplayers();
   thread trigger1();
   thread trigger2();
   thread trigger3();
   thread trigger4();
   thread trigger5();
   thread trigger6();
}

grabconnectedplayers()
{
   while(1)
   {
      level waittill("connected", player);
      player thread triggers();
   }
}

triggers()
{
   self.triggers = [];
   self.triggers[1] = false;
   self.triggers[2] = false;
   self.triggers[3] = false;
   self.triggers[4] = false;
   self.triggers[5] = false;
   self.triggers[6] = false;

   self thread count();
}

trigger1()
{
   trig = getent("triggername","targetname");
   while(1)
   {
      trig waittill("trigger",user);
      if(!isDefined(user.triggers[1]) || (user.triggers[1]  != true))
      {
         user.triggers[1] = true;
         user.trigcount += 1;
      }
   }
}

trigger2()
{
   trig = getent("triggername","targetname");
   while(1)
   {
      trig waittill("trigger",user);
      if(!isDefined(user.triggers[2]) || (user.triggers[2]  != true))
      {
         user.triggers[2] = true;
         user.trigcount += 1;
      }
   }
}

etc - to 6.

count()
{
   while(self.trigcount != 6)
      wait 0.1;

   //TELEPORT HERE
}

It can be further simplified using entity arrays, but this should work fine.
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

TTTT
CJ Wannabe
CJ Wannabe
Posts: 30
Joined: August 16th, 2009, 5:51 am

Re: tricky teleporter

Post by TTTT » February 14th, 2010, 12:06 am

got another lovley error, can be seen in screenshot. heres my code :


main()
{
thread grabconnectedplayers();
thread trigger1();
thread trigger2();
thread trigger3();
thread trigger4();
thread trigger5();
thread trigger6();
}

grabconnectedplayers()
{
while(1)
{
level waittill("connected", player);
player thread triggers();
}
}

triggers()
{
self.triggers = [];
self.triggers[1] = false;
self.triggers[2] = false;
self.triggers[3] = false;
self.triggers[4] = false;
self.triggers[5] = false;
self.triggers[6] = false;

self thread count();
}

trigger1()
{
trig = getent("ak47","targetname");
while(1)
{
trig waittill("trigger",user);
if(!isDefined(user.triggers[1]) || (user.triggers[1] != true))
{
user.triggers[1] = true;
user.trigcount += 1;
}
}
}

trigger2()
{
trig = getent("miniuzi","targetname");
while(1)
{
trig waittill("trigger",user);
if(!isDefined(user.triggers[2]) || (user.triggers[2] != true))
{
user.triggers[2] = true;
user.trigcount += 1;
}
}
}

trigger3()
{
trig = getent("lmg","targetname");
while(1)
{
trig waittill("trigger",user);
if(!isDefined(user.triggers[3]) || (user.triggers[3] != true))
{
user.triggers[3] = true;
user.trigcount += 1;
}
}
}

trigger4()
{
trig = getent("m1014","targetname");
while(1)
{
trig waittill("trigger",user);
if(!isDefined(user.triggers[4]) || (user.triggers[4] != true))
{
user.triggers[4] = true;
user.trigcount += 1;
}
}
}

trigger5()
{
trig = getent("dragunov","targetname");
while(1)
{
trig waittill("trigger",user);
if(!isDefined(user.triggers[5]) || (user.triggers[5] != true))
{
user.triggers[5] = true;
user.trigcount += 1;
}
}
}

trigger6()
{
trig = getent("de","targetname");
while(1)
{
trig waittill("trigger",user);
if(!isDefined(user.triggers[6]) || (user.triggers[6] != true))
{
user.triggers[6] = true;
user.trigcount += 1;
}
}
}

count()
{
while(self.trigcount != 6)
wait 0.1;
thread Transporter();
}

Transporter()
{
while(true)
{
self waittill("trigger",other);
entTarget = getent(self.target, "targetname");
wait(0.10);
other setorigin(entTarget.origin);
other setplayerangles(entTarget.angles);
wait(0.10);
}
}




I really dont know how to combine a teleporter with the code you sent me, its probably my try to mix them together that fucked it up
You do not have the required permissions to view the files attached to this post.
Last edited by TTTT on February 14th, 2010, 4:01 am, edited 1 time in total.

User avatar
Rezil
Core Staff
Core Staff
Posts: 2030
Joined: July 24th, 2006, 11:21 am
Location: Cramped in a small cubicle/making another jump map

Re: tricky teleporter

Post by Rezil » February 14th, 2010, 2:11 am

What screenshot?
Drofder2004: Drofder's rules for reviewing a map
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.

TTTT
CJ Wannabe
CJ Wannabe
Posts: 30
Joined: August 16th, 2009, 5:51 am

Re: tricky teleporter

Post by TTTT » February 14th, 2010, 4:02 am

sorry i forgot to post the image xD well it is on my last reply now

User avatar
Rezil
Core Staff
Core Staff
Posts: 2030
Joined: July 24th, 2006, 11:21 am
Location: Cramped in a small cubicle/making another jump map

Re: tricky teleporter

Post by Rezil » February 14th, 2010, 6:47 am

Hm, not sure about the error but the script wouldn't achieve what he wanted Drof, since he wants the teleport to happen after all six triggers are triggered, so:

Code: Select all

count()
{
while(self.trigcount != 6)
wait 0.1;
thread Transporter();
}
should in fact be:

Code: Select all

count()
{
while(self.trigcount == 6)
wait 0.1;
thread Transporter();
}
Also, try adding self.trigcount = 0; in the triggers() thread.
Drofder2004: Drofder's rules for reviewing a map
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.

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

Re: tricky teleporter

Post by Drofder2004 » February 14th, 2010, 2:35 pm

Code: Select all

triggers()
{
self.triggers = [];
self.triggers[1] = false;
self.triggers[2] = false;
self.triggers[3] = false;
self.triggers[4] = false;
self.triggers[5] = false;
self.triggers[6] = false;
self.trigcount = 6; // Add this line

self thread count();
}
Do NOT change the WHILE LOOP, changing it to "==" (equal to) will cause the while loop to be ignored because the while loop is there to stop the thread continuing without teleporting until the counter equals 6.

Because I did not include the curly brackets { } to enclose the while loop, the loop will ONLY read the first line (wait 0.1;) and will only move passed this line, once the while loop parameters have become false.

Once the player has been teleported once, the thread will end. If you want the player to be able to use all the triggers again, and be able to teleport again, simply add the line:

Code: Select all

self thread triggers();
To the end of your 'teleport' function (or 'count' function).
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

TTTT
CJ Wannabe
CJ Wannabe
Posts: 30
Joined: August 16th, 2009, 5:51 am

Re: tricky teleporter

Post by TTTT » February 14th, 2010, 11:28 pm

yeah well thanks for that but i have no idea how to make a teleporter

User avatar
Soviet
Core Staff
Core Staff
Posts: 7762
Joined: April 23rd, 2005, 9:12 pm

Re: tricky teleporter

Post by Soviet » February 14th, 2010, 11:42 pm


Pedsdude
Site Admin
Site Admin
Posts: 15914
Joined: October 15th, 2004, 7:18 pm
Location: UK

Re: tricky teleporter

Post by Pedsdude » February 15th, 2010, 4:59 am

Code: Select all

user setOrigin(x,y,z);
Image
Image

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

Re: tricky teleporter

Post by Drofder2004 » February 15th, 2010, 2:20 pm

Code: Select all

count()
{
   while(self.trigcount != 6)
      wait 0.1;

   self thread transporter();
}

Code: Select all

transporter()
{
   org = (0,0,0);
   self setorigin(org);
   //self thread triggers();

   //If you want the triggers &  count to be reset so a player can reactivate the teleporter, remove the // above
}
Change the (0,0,0) to the exact position you want (to find it you can use /viewpos ingame or use the radiant coordinates.
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

TTTT
CJ Wannabe
CJ Wannabe
Posts: 30
Joined: August 16th, 2009, 5:51 am

Re: tricky teleporter

Post by TTTT » February 15th, 2010, 4:51 pm

alright, no errors, but with this code nothing happens after i presses all 6 triggers.


main()
{
thread grabconnectedplayers();
thread trigger1();
thread trigger2();
thread trigger3();
thread trigger4();
thread trigger5();
thread trigger6();
}

grabconnectedplayers()
{
while(1)
{
level waittill("connected", player);
player thread triggers();
}
}

triggers()
{
self.triggers = [];
self.triggers[1] = false;
self.triggers[2] = false;
self.triggers[3] = false;
self.triggers[4] = false;
self.triggers[5] = false;
self.triggers[6] = false;
self.trigcount = 6;

self thread count();
}

trigger1()
{
trig = getent("ak47","targetname");
while(1)
{
trig waittill("trigger",user);
if(!isDefined(user.triggers[1]) || (user.triggers[1] != true))
{
user.triggers[1] = true;
user.trigcount += 1;
}
}
}

trigger2()
{
trig = getent("m1014","targetname");
while(1)
{
trig waittill("trigger",user);
if(!isDefined(user.triggers[2]) || (user.triggers[2] != true))
{
user.triggers[2] = true;
user.trigcount += 1;
}
}
}

trigger3()
{
trig = getent("lmg","targetname");
while(1)
{
trig waittill("trigger",user);
if(!isDefined(user.triggers[3]) || (user.triggers[3] != true))
{
user.triggers[3] = true;
user.trigcount += 1;
}
}
}

trigger4()
{
trig = getent("de","targetname");
while(1)
{
trig waittill("trigger",user);
if(!isDefined(user.triggers[4]) || (user.triggers[4] != true))
{
user.triggers[4] = true;
user.trigcount += 1;
}
}
}

trigger5()
{
trig = getent("dragunov","targetname");
while(1)
{
trig waittill("trigger",user);
if(!isDefined(user.triggers[5]) || (user.triggers[5] != true))
{
user.triggers[5] = true;
user.trigcount += 1;
}
}
}

trigger6()
{
trig = getent("miniuzi","targetname");
while(1)
{
trig waittill("trigger",user);
if(!isDefined(user.triggers[6]) || (user.triggers[6] != true))
{
user.triggers[6] = true;
user.trigcount += 1;
}
}
}

count()
{
while(self.trigcount != 6)
wait 0.1;
thread transporter();
}

transporter()
{
org = (0,0,0);
self setorigin(org);
self thread triggers();
}



Is there any radiant work included to make this work expect making 6 trigger_use on all 6 guns with targetname ?

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

Re: tricky teleporter

Post by Drofder2004 » February 15th, 2010, 5:13 pm

Added some print commands. Test the map using this GSC and then let me know which messages appear.

Code: Select all

main()
{
	thread grabconnectedplayers();
	thread trigger1();
	thread trigger2();
	thread trigger3();
	thread trigger4();
	thread trigger5();
	thread trigger6();
}

grabconnectedplayers()
{
	while(1)
	{
		level waittill("connected", player);
		player thread triggers();
	}
}

triggers()
{
self.triggers = [];
self.triggers[1] = false;
self.triggers[2] = false;
self.triggers[3] = false;
self.triggers[4] = false;
self.triggers[5] = false;
self.triggers[6] = false;
self.trigcount = 6;

self thread count();
}

trigger1()
{
	trig = getent("ak47","targetname");
	while(1)
	{
		trig waittill("trigger",user);
		iprintln("Trigger: ^1AK47");
		if(!isDefined(user.triggers[1]) || (user.triggers[1] != true))
		{
			user.triggers[1] = true;
			user.trigcount += 1;
			iprintln("Trigcount = ^2" + user.trigcount);
		}
	}
}

trigger2()
{
	trig = getent("m1014","targetname");
	while(1)
	{
		trig waittill("trigger",user);
		iprintln("Trigger: ^1M1014");
		if(!isDefined(user.triggers[2]) || (user.triggers[2] != true))
		{
			user.triggers[2] = true;
			user.trigcount += 1;
			iprintln("Trigcount = ^2" + user.trigcount);
		}
	}
}

trigger3()
{
	trig = getent("lmg","targetname");
	while(1)
	{
		trig waittill("trigger",user);
		iprintln("Trigger: ^1M1014");
		if(!isDefined(user.triggers[3]) || (user.triggers[3] != true))
		{
			user.triggers[3] = true;
			user.trigcount += 1;
			iprintln("Trigcount = ^2" + user.trigcount);
		}
	}
}

trigger4()
{
	trig = getent("de","targetname");
	while(1)
	{
		trig waittill("trigger",user);
		iprintln("Trigger: ^1DE");
		if(!isDefined(user.triggers[4]) || (user.triggers[4] != true))
		{
			user.triggers[4] = true;
			user.trigcount += 1;
			iprintln("Trigcount = ^2" + user.trigcount);
		}
	}
}

trigger5()
{
	trig = getent("dragunov","targetname");
	while(1)
	{
		trig waittill("trigger",user);
		iprintln("Trigger: ^1Dragunov");
		if(!isDefined(user.triggers[5]) || (user.triggers[5] != true))
		{
			user.triggers[5] = true;
			user.trigcount += 1;
			iprintln("Trigcount = ^2" + user.trigcount);
		}
	}
}

trigger6()
{
	trig = getent("miniuzi","targetname");
	while(1)
	{
		trig waittill("trigger",user);
		iprintln("Trigger: ^1Miniuzi");
		if(!isDefined(user.triggers[6]) || (user.triggers[6] != true))
		{
			
			user.triggers[6] = true;
			user.trigcount += 1;
			iprintln("Trigcount = ^2" + user.trigcount);
		}
	}
}

count()
{
	while(self.trigcount != 6)
		wait 0.1;
		
	self thread transporter();
}

transporter()
{
	iprintln("Transporter: ^2Start");
	org = (0,0,0);
	self setorigin(org);
	self thread triggers();
}
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

TTTT
CJ Wannabe
CJ Wannabe
Posts: 30
Joined: August 16th, 2009, 5:51 am

Re: tricky teleporter

Post by TTTT » February 15th, 2010, 7:30 pm

at the botteom left corner messages come up each time i presses a gun, but the triggercount starts from 6. becouse when i started the map and pressed use on the first gun it said "trigger: ak47, triggercount 7" the triggercount goes up to 12 after i pressed all guns.

TTTT
CJ Wannabe
CJ Wannabe
Posts: 30
Joined: August 16th, 2009, 5:51 am

Re: tricky teleporter

Post by TTTT » February 15th, 2010, 7:33 pm

i got it to work :DD insted of
triggers()
{
self.triggers = [];
self.triggers[1] = false;
self.triggers[2] = false;
self.triggers[3] = false;
self.triggers[4] = false;
self.triggers[5] = false;
self.triggers[6] = false;
self.trigcount = 6;

self thread count();
}

i did

triggers()
{
self.triggers = [];
self.triggers[1] = false;
self.triggers[2] = false;
self.triggers[3] = false;
self.triggers[4] = false;
self.triggers[5] = false;
self.triggers[6] = false;
self.trigcount = 0;

self thread count();
}

and now it works :) thx man

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest