Make elevator
#1

Hi how do make a elevator in every 2 seconds up and down?

PS: no command to move...to move single

(975, 2118.854980, 2407.718750, 61.134506, 355.9893, 2.00 ); // Up

(975, 2064.446045, 2438.436279, 11.495003, 2.00); // Down
Reply
#2

you mean it should wait when up/down for 2 seconds, then you will need to check how long it will take, edit the waitingtime
pawn Code:
#include <a_samp>

new ELEVATOR;
new OpenGate[MAX_PLAYERS];
forward CheckEl();
forward Wait(time);

public OnGameModeInit()
{
ELEVATOR = CreateObject( 975 , 2118.854980, 2407.718750, 61.134506 , 0.000000 , 0.000000 , 0.000000 );
SetTimer("CheckEl", 500, true);
}

public CheckEl() //LSPD gate
{
  for(new i = 0; i < GetMaxPlayers(); i++)
  {
        if(!IsPlayerConnected(i)) continue;
    if(OpenGate[i] == 0)
        {
      MoveObject(ELEVATOR,2118.854980, 2407.718750, 61.134506,3.5);//up
            Wait(5000);
            OpenGate[i] = 1;
    }
    if(OpenGate[i] == 1)
    {
      MoveObject(ELEVATOR, 2064.446045, 2438.436279, 11.495003,3.5);//down
      Wait(5000);
      OpenGate[i] = 0;
    }
  }
}

public Wait(time)
{
    new stamp = tickcount();
    while (tickcount() - stamp < time)
    {
    }
    return 1;
}
that should do the trick, haven't tried it tough
note: you may need to adjust waiting time, as I'm not going to check that for you, currently it's going down again after moving for 5seconds
and vice versa.
also: a speed of 2.0 is REALLY slow, 3.5 is still very slow, but if you want you can edit it
2nd note: you have a variable to much at the up position, probably a rotation? the createobject doesn't have any rotations now, you may need to fix that, as I didn't know the rotation.

Have fun with it
Reply
#3

You don't know that this Wait function pauses the whole samp server, right? NEVER use it.
Reply
#4

i will try jonasty thank you
Reply
#5

Quote:
Originally Posted by paytas
You don't know that this Wait function pauses the whole samp server, right? NEVER use it.
thanks for letting me know
Quead: you'll have to change the wait function into a timer, otherwise commands will only be executed after the waits
(so every 5 seconds)
people will think it's a very laggy server thanks to that
so you better don't use it this way, you'll have to change it into a timer
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)