Help with a MoveObject thing...
#1

Ok, so I have a bank vault which I made. It has 6 small pillars inside and a turning wheel on the front, beside it there's also a keypad. When I do that, if I'm in range of the keypad the 6 pillars would move one by one. How would I do that?

And after that how can I make it for the wheel to turn 2 times, and then the door would open.
Reply
#2

I assume the wheel on the vault door is not an object by itself, but rather a part of the vault door, so you can't move it separately.

Get the coordinates of the Keypad then use the function
IsPlayerInRangeOfPoint
then start up the MoveObject's

Then, when IsPlayerInRangeOfPoint returns 0,
use MoveObject's to move the objects back to their original place
Reply
#3

Well you would need to check the player's distance from the keypad (IsPlayerInRangeOfPoint) and move the objects if he is range of the keypad. You would need to use timers if you want them to move one by one, might be a bit confusing. You would need to change the rotation of the wheel with a timer also....
Reply
#4

The wheel isnt a part of the door. I just found it. I want the objects to move one by one.
Reply
#5

Well here is an example on how to check the player's position and how to move the objects one by one (Will not compile):

pawn Код:
new bankObjects[6]; //6 Pillars
new bankCheck[MAX_PLAYERS]; //Timer

public OnFilterScriptInit()
{
    bankObjects[0] = CreateObject...
    bankObjects[1] = CreateObject...
    bankObjects[2] = CreateObject...
    bankObjects[3] = CreateObject...
    bankObjects[4] = CreateObject...
    bankObjects[5] = CreateObject...
    bankObjects[6] = CreateObject...
    return 1;
}

public OnPlayerConnect(playerid)
{
    //This will run the function BankCheck every 2 seconds
    bankCheck[playerid] = SetTimerEx("BankCheck", 2000, 1, "i", playerid);
    return 1;
}

public OnPlayerDisconnect(playerid)
{
    KillTimer(bankCheck[playerid]);
    return 1;
}

public BankCheck(playerid)
{
    //Is player near the keyboard, add your own coords
    if(IsPlayerInRangeOfPoint(playerid, 3, 0.0, 0.0, 0.0)
    {
            //Move the first pillar...
        MoveObject(bankObjects[0]...);
    }
    else
    {
        //Move all the objects back to their normal position
    }
    return 1;
}

public OnObjectMoved(objectid)
{
    //This will move the objects one after another
    if(objectid == bankObjects[0])
    {
        MoveObject(bankObjects[1]...);
    }
    else if(objectid == bankObjects[1])
    {
        MoveObject(bankObjects[2]...);
    }
    else if(objectid == bankObjects[2])
    {
        MoveObject(bankObjects[3]...);
    }
    else if(objectid == bankObjects[3])
    {
        MoveObject(bankObjects[4]...);
    }
    else if(objectid == bankObjects[4])
    {
        MoveObject(bankObjects[5]...);
    }
    else if(objectid == bankObjects[5])
    {
        MoveObject(bankObjects[6]...);
    }
    return 1;
}
Reply
#6

Thank you!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)