Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Elevator is in use
#1
Code:
#include common_scripts\utility;

#include maps\mp\_airsupport;
#include maps\mp\_utility;

#include maps\mp\gametypes\_hud_util;



init()
{
    thread onPlayerConnect();
    thread onPlayerConnected();
    thread createElevator( ( 0, 0, 0 ), ( 0, 90, 0 ) );
}

onPlayerConnect()
{    
    for(;;)
    {
        level waittill( "connecting", player );

        player thread onPlayerSpawned();
    }
}

onPlayerConnected()
{    
    for(;;)
    {
        level waittill( "connected", player );
    }
}

onPlayerSpawned()
{
    for(;;)
    {

        self waittill( "spawned_player" );
    }
}

createElevator( origin, angle )
{
    level.isMoving = false;
    level.Position = 0;

    Center = spawn( "trigger_radius", origin, 0, 25, 50 );

    level.Elevator[0] = createBlock( origin, angle );
    level.Elevator[1] = createBlock( origin + ( 0, 35, 0 ), angle );

    Center thread monitorDistance( origin );
}

createBlock( origin, angle )
{
    block = spawn( "script_model", origin );
    block setModel( "mp_supplydrop_ally" );
    block.angles = angle;
}

monitorDistance( origin )
{
    while( 1 )
    {
        self waittill( "trigger", player );
        
        if( player useButtonPressed() == true )
        {
            if( level.isMoving == true ) player iPrintlnBold( "Elevator is Already in Use" );
            else if( level.isMoving == false ) self thread moveToPosition( origin, player );
        }
        wait 0.05;
    }
}

moveToPosition( origin, player )
{
    if( level.Position == 1000 ) level.Position = 0;
    else if( level.Position == 0 ) level.Position = 1000;
    for( i = 0; i < level.Elevator.size; i++ ) level.Elevator[i] moveTo( origin + ( 0, 0, level.Position ), 5 );
    wait 0.01;
    player enableinvulnerability();
    level.isMoving = true;
    wait 4.99;
    player disableinvulnerability();
    level.isMoving = false;
}

Whats wrong with this?
Everytime I use this, it just says the Elevator is in Use
Reply

#2
I'm not sure exactly, but it might be in the way you detect if the player is pressing the use button. If they hold it for more than 0.05 seconds, level.isMoving will be set to true in the 'moveToPosition' function, and it will print "Elevator is Already in Use".

Try waiting until someone enters the trigger, and then make a separate thread which detects when the use button is pressed.
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  [Release] Elevator stuff Yamato 7 5,469 01-27-2012, 15:08
Last Post: alvarogt95
  Elevator Party JariZ 0 1,794 10-27-2011, 10:21
Last Post: JariZ

Forum Jump:


Users browsing this thread:
2 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.