[FilterScript] [FS] AutoGates by Thomas_Conroy (multiple gates, single timer)
#2

Tutorial

Adding your own gates:

The script was designed with adding your own gates in mind. To add your own gates, you will need a program like MTA, or an ingame map editor to first get the co-ordinates. You need the co-ordinates of the gate closed, the co-ordinates when it is open, and the co-ordinates at the center of the gate.

1.) Go on MTA, and create a new map.

2.) Use the CreateObject utility to make your Gates (note: You do not have to use gates, you could use fences etc)

3.) Once you've positioned your gate in the closed position, use the Clone tool (ctrl + f9) to make an identical copy over your current one, and then move it into the closed position.

4.) Save the map and leave MTA.

5.) Use an Object Converter to convert the .map file in your MTA folder into PAWN script.

6.) You will be left with script similar to the following:

pawn Код:
CreateObject(976,-1571.597,665.725,6.349,0.0,0.0,-90.000); //Start
CreateObject(976,-1571.597,656.572,6.349,0.0,0.0,-90.000); //Finish
You need to copy the individual values into the following spaces:

pawn Код:
MakeGate(ObjectID, StartX, StarY, StartZ, FinishX, FinishY, FinishZ, CenterX, CenterY, CenterZ, Rotation, GateNumber); //Template
MakeGate(976, -1571.597,665.725,6.349, -1571.597,656.572,6.349, 0.0, 0.0, 0.0, -90.000, GateNumber); //Example
For the GateNumber field, ensure that it is 1 greater than the previous MakeGate. If you deleted the other MakeGate's it will be 0.
At this stage you probably won't have the co-ordinates for the Center, but this is not a problem. Leave them as 0.0 for now as shown above.

7.) Locate the following code: (It is in the "EDIT THESE" box)

pawn Код:
const GateNum = 4; //number of gates present (defines other arrays)
This constant is the number of gates on the server, and if you don't change it your gate will not work. If you are adding a gate, make it one bigger than it's value. (If it's 4, change it to 5) If you have deleted the demo gates and added one of your own it should be 1.

8.) Load the filterscript and locate the gates ingame. (Note: at this stage the gates WILL NOT open)

9.) Stand as close to the center of the gate as you can, and type "/save Center of Gate"

10.) Exit San Andreas and open your "savedpositions" file. At the bottom the co-ordinate you just saved should be there, followed by "//Center of Gate"

11.) Copy the X, Y and Z values from this co-ordinate and paste them in the MakeGate() script where the 0.0 values were.

12.) Compile again, and reload it. The gate should now function properly, opening when you approach it

_________________________________________________

Making the gates Admin Only:

By default these gates will automatically open to anyone that approaches them. If this is not suitable for your server, and you wish for them to only open in the presence of an admin it is possible by following this tutorial.

(Note: Many admin script use their own leveling system, and may have an include that allows admins under their leveling system the ability to do things. Their commands can also be used in the following way.)

1.) Locate the following in the script: (It is around line 75)

pawn Код:
if(OpenGate[tempgate] == 0/* && IsPlayerAdmin(pid) == 1*/) OpenGate[tempgate] = IsPlayerNearGate(pid, tempgate, TOLERANCE);
2.) Take out the "/*" and "*/", which should make it look like this:

pawn Код:
if(OpenGate[tempgate] == 0 && IsPlayerAdmin(pid) == 1) OpenGate[tempgate] = IsPlayerNearGate(pid, tempgate, TOLERANCE);
3.) For those of you using LAdmin, you could do the following:

pawn Код:
#include <IsPlayerLAdmin>
pawn Код:
if(OpenGate[tempgate] == 0 && IsPlayerLAdmin(playerid) ==0) OpenGate[tempgate] = IsPlayerNearGate(pid, tempgate, TOLERANCE);
Post below if you have another admin script you'd like me to add.

_________________________________________________

Editing the Gate Settings:

Several options concerning the way in which the gates operate can be edited using the box at the top of the filterscript shown below:
(Note: This is its default configuration which I tested it with)

pawn Код:
// ######################## EDIT THESE ##########################
#define TOLERANCE 20
#define OPENSPEED 2
#define CLOSESPEED 2
#define TIMERSPEED 1500 //(MILLISeconds, eg 1000 = 1, 2000 = 2, 1500 = 1.5)
const GateNum = 4; //number of gates present (defines other arrays)
// ##############################################################
1.) The "TOLERANCE"

This defines the area in which the gate will be triggered by a players presence. If set to 20, players within a square of 40 x 40 of the center of the gate will cause it to open. You may wish to change this so the gate opens some time before you reach it, meaning you never have to slow down.

2.) The "OPENSPEED" and "CLOSESPEED"

These define the speed at which the gate opens and closes (duh). For a realistic gate I recommend using 2/3, but if you are impatient you may wish to speed them up.

3.) The "TIMERSPEED"

This defines how often the timer will repeat. As a rule of thumb, the faster you trigger the timer (Low TIMERSPEED) the more processing power you will use. If you run a server with many players I recommend keeping this number around 2000/3000, as any less than this may cause a bit of lag. I have only tested this on a server with 10 player-slots and 4 gates, so there may be some problems with busy servers.

4.) "const GateNum"

This is edited when adding a new gate. (See first tutorial)
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)