[Tutorial] How to make a moving gate on command
#1

Hey this is my first post and first tutorial, hope you like it.
The gate you are gonna make will open on command and only if you use the command close to the gate.
Im using PAWNO and using a blank script for this tutorial.

Things you need before making your gate:
Coords:
You can get a coord by using MTA Map editor, placing your gate and saving the map.
Then convert the map using a map converter(i use this)

There are more ways to get your coords but i think this one is fairly easy to use.

Explaining coords:
Код:
movingdoor1	=	CreateObject(3093, 2354.3403320313, -650.77142333984, 127.85127258301, 0, 0, 269.5);

movingdoor1	=	CreateObject(object id, x coord, y coord, z coord, x rotation axis, y rotation axis, z rotation axis);
Step 1:
Get the coords for your gate in closed position and in open position.

Step 2:
Under #include <a_samp>
you should type: new yourgatename;
So it should look like this:
Код:
#include <a_samp>
new movingdoor1;
In my case im making a door but it will work the same for a gate.

Step 3:
Add the coords from the closed gate to your public OnGameModeInit()
It should look like this:
Код:
public OnGameModeInit()
{
	// Don't use these lines if it's a filterscript
	SetGameModeText("Blank Script");
	AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
	movingdoor1	=	CreateObject(3093, 2354.3403320313, -650.77142333984, 127.85127258301, 0, 0, 269.5);

	return 1;
}
Step 4:
Ok this is where your gonna script the gate to move when you use the by-you-designed command
Go down to public OnPlayerCommandText(playerid, cmdtext[])
Now you should type this under public OnPlayerCommandText(playerid, cmdtext[]):
Код:
{
	if (!strcmp("/close", cmdtext))
	{
		if(IsPlayerInRangeOfPoint(playerid, 7.0, 2353.693359375, -650.77709960938, 127.85127258301))
		{
	  MoveObject(movingdoor1, 2354.3403320313, -650.77142333984, 127.85127258301, 1);
		SendClientMessage(playerid, 0xEF994300, "The gate has closed.");
		 }
 		return 1;
	}

	if (!strcmp("/open", cmdtext))
	{
	  if(IsPlayerInRangeOfPoint(playerid, 7.0, 2353.693359375, -650.77709960938, 127.85127258301))
 	{
 		MoveObject(movingdoor1, 2353.693359375, -650.77709960938, 127.85127258301, 1);
    SendClientMessage(playerid, 0xEF994300, "The gate has opened.");
		}
		return 1;
	}
IsPlayerInRangeOfPoint is a function that you can use to set a radius a player has to be in before he can use the command.
MoveObject moves the object
SendClientMessage gives the player that used the command a message

_________________________________________________

Thats my small tutorial on making a moving gate on command.
If you have any questions, ask them in here.

Made by me, Please do not RIP
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)