Results 1 to 9 of 9

Thread: Teleport player on trigger

  1. #1
    Private Invictus's Avatar
    Join Date
    Mar 2013
    Location
    Poland
    Posts
    32
    Thanks
    25
    Thanked 13 Times in 6 Posts

    Lightbulb Teleport player on trigger

    Hi there.

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

    PHP Code:
    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);
        }


  2. #2
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    PHP Code:
    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
    timescale 0.01

  3. #3
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    You should always check that the player:

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

    PHP Code:
    trigers_spawn()
    {    
        
    trig spawn"trigger_radius", (1242,2269,284), 16060 );
        
        while( 
    true )
        {
            
    trig waittill"trigger"player );
            
            if( 
    isPlayerplayer ) && isAliveplayer ) && player.sessionteam != "spectator" && player isTouchingtrig ) )
            {
                
    player iprintlnbold("^2`^7Trigger^2.");
                
    player setorigin1237,1110,250 );
            }
        }


  4. #4
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Quote Originally Posted by Tally View Post
    You should always check that the player:

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

    PHP Code:
    trigers_spawn()
    {    
        
    trig spawn"trigger_radius", (1242,2269,284), 16060 );
        
        while( 
    true )
        {
            
    trig waittill"trigger"player );
            
            if( 
    isPlayerplayer ) && isAliveplayer ) && player.sessionteam != "spectator" && player isTouchingtrig ) )
            {
                
    player iprintlnbold("^2`^7Trigger^2.");
                
    player setorigin1237,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

  5. #5
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by IzNoGoD View Post
    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).
    Last edited by Tally; 23rd March 2013 at 21:18.

  6. #6
    Private First Class Earliboy's Avatar
    Join Date
    Nov 2012
    Location
    Germany
    Posts
    130
    Thanks
    5
    Thanked 88 Times in 61 Posts
    Spectator ISN'T alive, since spectator doesnt got HP,
    if you don't belive, do if(isAlive(self) && self.sesstionteam == "spectator") self iprintlnBold("ALIVE");
    No ... No ... this is not possible .......

  7. #7
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by Earliboy View Post
    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:

    PHP Code:
    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.

  8. #8
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Quote Originally Posted by Tally View Post
    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...

  9. #9
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by IzNoGoD View Post
    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".
    Last edited by Tally; 24th March 2013 at 11:37.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •