Look at this:

The concept is to move an entity up/down to the given position (gc_elestop[], ._destination), when activated (._moving=on) with it's speed (._speed).

Code:

// elevator_entity
entity* ent_elevator;

// Stop-positions (z-positions)
var gc_elestop[5] = 0, 200, 400, 600, 800;

// Speedfactor
var gc_ele_speed = 10;

define _moving, flag1;
define _speed, skill1;
define _destination, skill20;
define _direction, skill21;
//uses: _moving, flag1;
//uses: _speed, skill1;
action elevator{
// set the handle
ent_elevator=me;

while(1){
// wait for activating...
while(my._moving==off){wait(1);}

// direction (up or down?)
my._direction=1-2*(my.z>gc_elestop[my._destination]); // go up if not my.z>my._destination (over the dest.point)

// move elevator (in the direction until the stoppoint is reached)
while((my._direction==1 && my.z<gc_elestop[my._destination]) || (my._direction==-1 && my.z>gc_elestop[my._destination])){
my.z+=time*gc_ele_speed*my._direction;
wait(1);
}

// at Stop-position
my.z=gc_elestop[my._destination]; // set the exact point
my._moving=off; // stop moving

wait(1);
}
}

//-------------------------------------------------------------------------------------------------------------------------------
function ele_goto_1{while(ent_elevator._moving==on){wait(1);} ent_elevator._destination=0; ent_elevator._moving=on;} // wait till stop and move on
function ele_goto_2{while(ent_elevator._moving==on){wait(1);} ent_elevator._destination=1; ent_elevator._moving=on;} // wait till stop and move on
function ele_goto_3{while(ent_elevator._moving==on){wait(1);} ent_elevator._destination=2; ent_elevator._moving=on;} // wait till stop and move on
function ele_goto_4{while(ent_elevator._moving==on){wait(1);} ent_elevator._destination=3; ent_elevator._moving=on;} // wait till stop and move on
function ele_goto_5{while(ent_elevator._moving==on){wait(1);} ent_elevator._destination=4; ent_elevator._moving=on;} // wait till stop and move on


// Keys for levels
on_1 = ele_goto_1;
on_2 = ele_goto_2;
on_3 = ele_goto_3;
on_4 = ele_goto_4;
on_5 = ele_goto_5;