22.07.2013, 13:24
(
Последний раз редактировалось JimmyCh; 18.08.2013 в 13:56.
)
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:
Now under OnGameModeInIt, we need to create the original object and the position of it,
so we will be implementing the following:
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.
Hope I made it clear guys, if not, tell me what you didn't understand so I can help you with it!
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
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); //
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;
}