Page 1 of 2

Teleporters Help

Posted: February 21st, 2006, 2:56 am
by Nightmare
Hey, I was wondering if any of you guys had any knowledge on how to make teleporters that could send you from on place to another by walking into a trigger. Thanks

Posted: February 21st, 2006, 1:57 pm
by Pedsdude
I know it's possible, and I have it in pp_solar (thanks to Plazma's work), but I personally don't know how to do it :P

Posted: February 21st, 2006, 3:50 pm
by Luke
Found some info @ modsonline, haven't tested it yet but you could try it:
In the editor, go to your departure point, draw out a decent size brush and texture it trigger, right click in 2d view, go down and make it trigger_multiple.
with the trigger still selected press n and enter these values
Key = target Value = gohere
Key = targetname Value = enter
Press n again to close the entity box
(Thats it for the trigger, press esc.)

Navigate your way in the editor to where you want to be teleported to.
Right click in the 2d view and create a script_origin (a red cube should appear)
With that still selected, press n and enter these values
Key = targetname Value = gohere
Press n again to close the entity box
You can rotate the red cube until the arrow faces the direction you wish to be facing when teleported.

With the script_origin still selected go back to the trigger and select them both, now hold down the Ctrl key and hit the k key to connect them. Press esc.

If you have things correct you should now see a red line connecting trigger and red cube.

(I think thats it for the mapping bit)

Compile,

Make a .gsc containing this script (just call it teleport)
.....................................................................................

main()
{

entTransporter = getentarray("enter","targetname");
if(isdefined(entTransporter))
{
for(lp=0;lp entTransporter[lp] 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);
}
}

Posted: February 21st, 2006, 6:49 pm
by Drofder2004
Map and Pk3

Edit...

Changed my mind. I was impressed by the technique that was used in lukes post, it made coding a little easier (although mapping slightly harder).

Ok, so make your teleport triggers and give them a targetname of enter.k
Now Make the place where you want each teleporter to go to by using a script_model. (right click, script<model)
and give that a targetname of whatever you want.

Now go back to the teleporters and give them a new key and value.
Key:target
Value:<enter the targetname of the script_model you want to teleport to>

Now simply use this script..

Code: Select all

main()
{
entTransporter = getentarray("enter","targetname");

if(isdefined(entTransporter))
{
for(i=0;i<entTransporter.size;i++)
entTransporter[i] thread Transporter();
}
}

Transporter()
{
while(1)
{
self waittill("trigger",user);
entTarget = getent(self.target, "targetname");

wait .1;
user setorigin(entTarget.origin);
wait .1;
}
} 
You can have as many teleporters as you like without having to touch the code. I have 8 teleports on my map ;)

Have Fun.

Posted: February 21st, 2006, 9:07 pm
by Guest
can you juse teleporters in mp or only in sp

Posted: February 21st, 2006, 9:28 pm
by Drofder2004
Anonymous wrote:can you juse teleporters in mp or only in sp
My map is an MP map so, yes MP and SP.

Posted: February 21st, 2006, 9:39 pm
by Rince
omg drof =O msn 2 night teleporters for denmark :-)~

Posted: February 21st, 2006, 10:43 pm
by Pedsdude
lol rince :)

Posted: February 21st, 2006, 11:12 pm
by Drofder2004
Rince wrote:omg drof =O msn 2 night teleporters for denmark :-)~
Depends what time my brother comes off PC.

Posted: February 22nd, 2006, 12:21 am
by Nightmare
Drofder, thank you sooo much man! It works! Luke, I tried your way but it didnt work for me, thanks anyway!

Posted: February 22nd, 2006, 1:09 am
by Luke
Nightmare wrote:Drofder, thank you sooo much man! It works! Luke, I tried your way but it didnt work for me, thanks anyway!
Good :) what i posted was just what i found on modsonline.com, don't get the wrong idea that i know what i'm talking about :P

Posted: February 22nd, 2006, 1:19 pm
by Drofder2004
Luke wrote:
Nightmare wrote:Drofder, thank you sooo much man! It works! Luke, I tried your way but it didnt work for me, thanks anyway!
Good :) what i posted was just what i found on modsonline.com, don't get the wrong idea that i know what i'm talking about :P
Your way does work Luke if the code was corrected ;)

Code: Select all

{
for(lp=0;lp entTransporter[lp] thread Transporter();
}
That is meant to be a for loop, but it skips out the essentials in the loop. Its meant to look like this...

Code: Select all

{
for(i=0;i<entTransporter.size;i++)
entTransporter[i] thread Transporter();
}

Posted: February 22nd, 2006, 4:43 pm
by leveller
This is what i use for my own maps,

make a triggermultiple :

Code: Select all

Key = targetname Value = transporter_01
For the scripting i use this

Code: Select all

main()
{
thread Transporter_01();
}

Transporter_01()
{
	while(1)
	{
		players = getentarray("player", "classname");

		for(i=0;i<players.size;i++)
		{
			finishtrig = getent ("transporter_01","targetname");
			finishtrig waittill ("trigger",user);

		user setOrigin( (-152, 736,1000) );

		}
	wait .5;
	}
}
i use the :

Code: Select all

user setOrigin( (-152, 736,1000) );
in the script, so i can set it to an other position without having to recompile the map again.

Posted: February 22nd, 2006, 4:56 pm
by Drofder2004
leveller wrote: i use the :

Code: Select all

user setOrigin( (-152, 736,1000) );
in the script, so i can set it to an other position without having to recompile the map again.
I dont think you need the for loop with the while loop as the loop will find the "user" of the trigger anyway.

As I said in another post, using a for loop with players is bad in a map file because if a player join after that loop has been run, they will not be part of the loop (and anything inside the loop will not work).

The way you posted was the roughly the same as what I posted before I edited, (except without the for loop). I prefer the way that I have posted simply because it can support hundreds of teleporters without a single modification to the code, just means a bit more mapping.

:)

Posted: February 22nd, 2006, 5:13 pm
by leveller
its been a while sinds i made the script,

but i remember that i use to have the script without the loop, and for some reason, (i would have to try it again)
i didnt like the way the script ran, and it worked better to my liking with the loop in it.

Could be it had someting to do with sending individual messages to the user who used the transporter.

I'll come back on, after i tried it again.