How to make an automatic gate! -
JimmyCh - 22.07.2013
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!
Re: How to make an automatic gate! -
Mckarlis - 22.07.2013
Thanks werry helpfull i hope it helps others too
+REP
Re: How to make an automatic gate! -
JimmyCh - 22.07.2013
Thanks for your feedback, hope it helped you!

PS: If you guys need a tutorial about something specific that I can help with, feel free to ask me!
Re: How to make an automatic gate! -
Uberanwar - 18.08.2013
how can i make it only open for specific teams, example a cop?
Re: How to make an automatic gate! -
Isolated - 18.08.2013
under the loop:
pawn Код:
if(IsCop(i)) { // or another function you use
Re: How to make an automatic gate! -
ThePhenix - 18.08.2013
EDIT:
When are you setting the variable "open" back to 0?
Re: How to make an automatic gate! -
JimmyCh - 18.08.2013
This system automatically checks that if you're not InRangeOfPoint, it will not be: open =1;
Anyway thank you for the attention, I added open = 0 at the end of the script.
Re: How to make an automatic gate! -
BanhVo - 18.11.2017
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
Re: How to make an automatic gate! -
cuber - 18.11.2017
Quote:
Originally Posted by BanhVo
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
|
What the actual fuck.