[Tutorial] Making Moving Gates
#1

Thank you for choosing my tutorial for making moving gates. First, let's get a gate! If you don't have a gate custom mapped, you need to figure that out before using this tutorial. You need to have a gate mapped in.

Let's define the variable for the gates globally.

Code:
new SFPDGate1;
new SFPDGate2;
new bool:gStatus;
The SFPD gates are huge, so I have two gates here.

Now let's define some custom mapping to serve as our gates, shall we?

Code:
    SFPDGate1 = CreateDynamicObject(969, -1623.43, 688.50, 6.37,   0.00, 0.00, 180.00);
    SFPDGate2 = CreateDynamicObject(969, -1631.32, 688.49, 6.37,   0.00, 0.00, 180.00);
This uses the new SFPDGate1; to define some custom mapping that I have under OnGameModeInit. This will be very critical for the next command:

Code:
CMD:gate(playerid)
{
    if(IsPlayerInRangeOfPoint(playerid, 20.0, -1631.0911,688.6709,7.1875) && gStatus == false) // Grabs your location, you have to be near the gate to open it. And if the gate is closed
    {          
      MoveDynamicObject(SFPDGate1,  -1639.82, 688.49, 6.37, 2.9); // Moves Gate 1
      MoveDynamicObject(SFPDGate2,  -1639.82, 688.49, 6.37, 2.9); // Moves Gate 2
      gStatus = true;// Tells the script the gate is open
    }
    else if(IsPlayerInRangeOfPoint(playerid, 20.0, -1631.0911,688.6709,7.1875) && gStatus == true) // Grabs your location, you have to be near the gate to close it. And if the gate is open
    {
      MoveDynamicObject(SFPDGate1,   -1623.43, 688.50, 6.37, 2.9); // Moves Gate 1
      MoveDynamicObject(SFPDGate2,   -1631.32, 688.49, 6.37, 2.9); // Moves Gate 2
      gStatus = false; // Tells the script the gate is closed
    }
    return 1;
}
There you go! You now have some movable gates. Obviously you need to make your own system with your own gates, but now you have a general idea on how it works.

Note: If you do not use "CreateDynamicObject" and just use "CreateObject" You need to use "MoveObject" instead of "MoveDynamicObject"
Reply
#2

You should have called it Making Simple Moving Gates since it's only one gate
Reply
#3

Quote:
Originally Posted by [uL]Pottus
View Post
You should have called it Making Simple Moving Gates since it's only one gate
Changed! Thanks for the feedback!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)