PDA

View Full Version : Teleport player on trigger



Invictus
23rd March 2013, 19:34
Hi there.

I wrote the script.
When a player touches the triggers will be teleported.
Below is the script.



trigers_spawn()
{
player = self;
trig = spawn("trigger_radius", (1242,2269,284),1,60,60);

while(true)
{
trig waittill("trigger", player);
player iprintlnbold("^2`^7Trigger^2.");
self setorigin(1237,1110,250);
}
}

kung foo man
23rd March 2013, 20:34
trigers_spawn()
{
player = self;
trig = spawn("trigger_radius", (1242,2269,284),1,60,60);

while(true)
{
trig waittill("trigger", player);
player iprintlnbold("^2`^7Trigger^2.");
player setorigin(1237,1110,250); // changed this line only
}
}


Try it that way, should work

Tally
23rd March 2013, 20:42
You should always check that the player:

1. is alive;
2. isn't a spectator;
3. is touching the trigger.


trigers_spawn()
{
trig = spawn( "trigger_radius", (1242,2269,284), 1, 60, 60 );

while( true )
{
trig waittill( "trigger", player );

if( isPlayer( player ) && isAlive( player ) && player.sessionteam != "spectator" && player isTouching( trig ) )
{
player iprintlnbold("^2`^7Trigger^2.");
player setorigin( 1237,1110,250 );
}
}
}

IzNoGoD
23rd March 2013, 20:46
You should always check that the player:

1. is alive;
2. isn't a spectator;
3. is touching the trigger.


trigers_spawn()
{
trig = spawn( "trigger_radius", (1242,2269,284), 1, 60, 60 );

while( true )
{
trig waittill( "trigger", player );

if( isPlayer( player ) && isAlive( player ) && player.sessionteam != "spectator" && player isTouching( trig ) )
{
player iprintlnbold("^2`^7Trigger^2.");
player setorigin( 1237,1110,250 );
}
}
}

1. true
2. If alive (or checking sessionstate == "playing"), then spectator check should not be necessary
3. trigger_radius will always be touched upon activating it

Tally
23rd March 2013, 22:12
1. true
2. If alive (or checking sessionstate == "playing"), then spectator check should not be necessary
3. trigger_radius will always be touched upon activating it

2. Spectator's are "alive", since their sessionstate is not "dead". If an entity is not "dead" then they are classed as "alive":


IsAlive( <entity> )

1 : <entity> An entity object that might be alive or dead


Hence, there is a need to check their sessionteam to not do damage and not trigger triggers since all "alive" entities can do both.

3. Checking if a player is actually touching a trigger radius prevents the trigger being triggered through walls (if the trigger is near a wall and the radius is big enough to intersect a wall).

Earliboy
23rd March 2013, 22:50
Spectator ISN'T alive, since spectator doesnt got HP,
if you don't belive, do if(isAlive(self) && self.sesstionteam == "spectator") self iprintlnBold("ALIVE");

Tally
23rd March 2013, 22:59
Spectator ISN'T alive, since spectator doesnt got HP,
if you don't belive, do if(isAlive(self) && self.sesstionteam == "spectator") self iprintlnBold("ALIVE");

And you know better than the developers do you? They saw the need to do 3 checks in CTF gametype:


if(isPlayer(other) && isAlive(other) && (other.pers["team"] != "spectator"))

Why would they need to check the team if all that was needed was the alive check?

Alive and dead are absolute states: if you aren't dead, you are alive. And spectators are not dead - the sessionstate of "dead" is not placed on any entity other than "dead" players. Hence the developers - i.e. those that actually wrote the engine - saw the need to return no damage against a sessionteam check and not a simple "alive" check (check out the callback player damge function). Same for all death threads (check out the callback player killed function). The engine will run such things on all but "dead" entities - including spectators.

IzNoGoD
24th March 2013, 02:06
2. Spectator's are "alive", since their sessionstate is not "dead". If an entity is not "dead" then they are classed as "alive":



Hence, there is a need to check their sessionteam to not do damage and not trigger triggers since all "alive" entities can do both.

3. Checking if a player is actually touching a trigger radius prevents the trigger being triggered through walls (if the trigger is near a wall and the radius is big enough to intersect a wall).

Thats why i was talking about checking sessionstate for "playing" instead of checking for alive && !spectator. (unsure what sessionstate for intermission is, but def not "playing")

I have no experience on the triggers through walls part, so it might indeed be necessary, but i cannot wrap my head around how you can trigger a trigger_radius without actually touching it or how istouching() could magically prevent you from triggering it through walls...

Tally
24th March 2013, 11:47
Thats why i was talking about checking sessionstate for "playing" instead of checking for alive && !spectator. (unsure what sessionstate for intermission is, but def not "playing")

I have no experience on the triggers through walls part, so it might indeed be necessary, but i cannot wrap my head around how you can trigger a trigger_radius without actually touching it or how istouching() could magically prevent you from triggering it through walls...

I see. So, let me get this straight - a failure in your imagination determines truth or falsity? As you said, you lack experience with triggers. Gain more experience, and you might be able to "get your head around it".