Teleporters Help
Moderator: Core Staff
Teleporters Help
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
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);
}
}
-
- Core Staff
- Posts: 13315
- Joined: April 13th, 2005, 8:22 pm
- Location: UK, London
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..
You can have as many teleporters as you like without having to touch the code. I have 8 teleports on my map 
Have Fun.
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;
}
}

Have Fun.

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
-
- Core Staff
- Posts: 13315
- Joined: April 13th, 2005, 8:22 pm
- Location: UK, London
-
- Core Staff
- Posts: 13315
- Joined: April 13th, 2005, 8:22 pm
- Location: UK, London
-
- Core Staff
- Posts: 13315
- Joined: April 13th, 2005, 8:22 pm
- Location: UK, London
Your way does work Luke if the code was correctedLuke wrote:GoodNightmare wrote:Drofder, thank you sooo much man! It works! Luke, I tried your way but it didnt work for me, thanks anyway!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

Code: Select all
{
for(lp=0;lp entTransporter[lp] thread Transporter();
}
Code: Select all
{
for(i=0;i<entTransporter.size;i++)
entTransporter[i] thread Transporter();
}

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
This is what i use for my own maps,
make a triggermultiple :
For the scripting i use this
i use the :
in the script, so i can set it to an other position without having to recompile the map again.
make a triggermultiple :
Code: Select all
Key = targetname Value = transporter_01
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;
}
}
Code: Select all
user setOrigin( (-152, 736,1000) );
-
- Core Staff
- Posts: 13315
- Joined: April 13th, 2005, 8:22 pm
- Location: UK, London
I dont think you need the for loop with the while loop as the loop will find the "user" of the trigger anyway.leveller wrote: i use the :in the script, so i can set it to an other position without having to recompile the map again.Code: Select all
user setOrigin( (-152, 736,1000) );
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.


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
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.
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.
Who is online
Users browsing this forum: No registered users and 2 guests