Object moving automatically
#1

Hello!
I want to make an automatic gate.It should move up and down without any interference.It means going up and down in a particular time ( without cmd or going near it)
Can anyone please show me a code like that? i will give +rep .
Reply
#2

This is based off of the tutorial here: https://sampforum.blast.hk/showthread.php?tid=355843

pawn Код:
public OnGameModeInit()
{
    new Gate;
    Gate = CreateObject(971, 2184.9, -1764.4, 14.5, 0, 0, 0);
   
    SetTimerEx("MoveGate", (10 * 1000), false, "dd", Gate, 0); // Closed
    return 1;
}

forward MoveGate(Gate, Status);
public MoveGate(Gate, Status) {
    if(Status == 0) {
        MoveObject(Gate, 2184.98, -1764.40, 7.6, 2);
   
        SetTimerEx("MoveGate", (10 * 1000), false, "dd", Gate, 1); // Opened
    } else {
        MoveObject(Gate, 2184.9, -1764.4, 14.5, 2);
   
        SetTimerEx("MoveGate", (10 * 1000), false, "dd", Gate, 0); // Closed
    }
    return true;
}
Reply
#3

But it is going to only in 1 direction and not coming back.
Reply
#4

Anyone please help guys.its really urgent
Reply
#5

Well here is a small test:

Firstly you should Create a Gate:
Quote:

public OnGameModeInit()
{
new i = CreateObject(MODEL, POSITION X- Y- Z);
}

Now, we can do a stock, where the function can find the nearest Object, or just hold a Key...
If you use the Key-variant you should use the Variable or typing /pos to get the Position.

Quote:

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (PRESSED(KEY_CROUCH) || IsPlayerInRangeOfPoint(playerid, Position))// press c
{
MoveObject(Position);
SCM(playerid, 0xFFFFFF, "Object 1 Open.");
}
if (PRESSED(KEY_JUMP) || IsPlayerInRangeOfPoint(playerid, Position))// press jump
{
MoveObject(Position);
SCM(playerid, 0xFFFFFF, "Object 2 Close.");
}
return 1;
//edit failed at ||
Reply
#6

I mean without any interference it should go up and down randomly.Please anyone ....
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)