SA-MP Forums Archive
Object moving automatically - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Object moving automatically (/showthread.php?tid=356857)



Object moving automatically - Crazyboobs - 05.07.2012

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 .


Re: Object moving automatically - TheLazySloth - 05.07.2012

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;
}



Re: Object moving automatically - Crazyboobs - 05.07.2012

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


Re: Object moving automatically - Crazyboobs - 05.07.2012

Anyone please help guys.its really urgent


AW: Object moving automatically - Forbidden - 05.07.2012

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 ||


Re: Object moving automatically - Crazyboobs - 05.07.2012

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