[Tutorial] How to make an automatic gate!
#8

Quote:
Originally Posted by JimmyCh
Посмотреть сообщение
Hello guys, I got bored so I said, "Why not make a simple tutorial?"
And what made me think about these gates, is that how much time it took me to know how to make them, because the tutorials I found weren't the best for this.
So let's get started!

At first, you add the Object name on the top:
pawn Код:
new Gate; // I will be calling it Gate
Now under OnGameModeInIt, we need to create the original object and the position of it,
so we will be implementing the following:
pawn Код:
Gate = CreateObject(modelid, Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ)
// now for the modelid, I suggest 2933, 975, 971, etc, you can find many actually.
// Alright, don't forget to fill the CreateObject with what you need of course, you can do so with MTA or an editor to get the needed coordinates you are gonna use.
//The draw distance is not needed here, so u can put the X,Y,Z, rotationX, rotationY, rotationZ.

//we are gonna put a timer at what time the gate will open when ur near it.
SetTimer("TestGate", 1000, 1); //
Okay, so we're half done now.
What we need now is to see if the player is near this object, it will open it.
pawn Код:
forward TestGate();
public TestGate() // we made a public call for the timer, which we called "TestGate"
{
    new open;
    for(new i=GetMaxPlayers(); i > -1; i--) // we're making a loop here
    {
        if(IsPlayerConnected(i) && IsPlayerInRangeOfPoint(i, 10.0, Float:X, Float:Y, Float:Z))// we are checking if he's online and he's near the gate itself, at a range of 10 meters(You can change it of course)
// do not forget to change the X,Y,Z to what you want, mostly use the same coordinates as the gate's.
        {
            open = 1;
            MoveObject(Gate, NewX, NewY, NewZ, 2.0); // we checked that if he's near the gate, at 10 meters away as a max, it moves Object "Gate" to it's new position at a speed of 2.
// do not forget to change the coordinates to the new gate's coordinates, where it will move to.
            break;
        }
    }
    if(!open) // now we're checking that if it's not open and he's away from the gate, we're gonna close it back to it's old coordinates
        MoveObject(Gate, Float:X, Float:Y, Float:Z, 2.0); // do not forget to change the coordinates here too, to the original position of the gate.
       open = 0;
}
Hope I made it clear guys, if not, tell me what you didn't understand so I can help you with it!
Can you help me? New to this gate is not understood all about it. The bottom is your download. You watch and help yourself.
Dowload: https://pastebin.com/B942CRiE
Reply


Messages In This Thread
How to make an automatic gate! - by JimmyCh - 22.07.2013, 13:24
Re: How to make an automatic gate! - by Mckarlis - 22.07.2013, 13:25
Re: How to make an automatic gate! - by JimmyCh - 22.07.2013, 14:02
Re: How to make an automatic gate! - by Uberanwar - 18.08.2013, 03:59
Re: How to make an automatic gate! - by Isolated - 18.08.2013, 04:07
Re: How to make an automatic gate! - by ThePhenix - 18.08.2013, 04:32
Re: How to make an automatic gate! - by JimmyCh - 18.08.2013, 13:54
Re: How to make an automatic gate! - by BanhVo - 18.11.2017, 10:24
Re: How to make an automatic gate! - by cuber - 18.11.2017, 10:35

Forum Jump:


Users browsing this thread: 1 Guest(s)