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

AutoGates by Thomas_Conroy

Introduction:

Having browsed the Filterscripts and Includes forum and seeing hundreds of gate scripts, I decided something must be done. They all contain far too many command and/or timers for my liking. I thought about it for a while, and then designed this Filterscript which can handle as many gates as you could wish for with just a single timer.

Description:

The script allows you to make gates in places where there were previously no gates. Upon approaching the gates they automatically open, and when you are out of their range again they automatically close. The Gate Open/Close speed, Range and timer frequency can all be adjusted, and by following the tutorial (to come) below you can even add your own gates. This Filterscript comes with a total of 4 automatic gates built in, at some of the police compounds in the three main cities.

Commands:

Command-less, it is all triggered by your players position in relation to the gate.

Download:

Version 1: 101 lines
Host: Pastebin

Screenshots:


Usage:

Feel free to modify the script as you wish. Please leave the credit in place, as I spent several hours creating this script.


Thanks:

Thanks to Zoidberg, for allowing me to use her Photobucket space, and posing for screenshots!
Thanks to Zoidberg, Deixel and Dchidell for testing it with me. :P
Thanks to those who designed sa-mp and those who contribute with their knowledge on the forums.

Please enjoy using this script, and if you wish to praise/criticize me please post. I may update the script in the future, so if you have any ideas please post them. This is my first release so if there are any problems please post.

Thank you, Thomas_Conroy
(For those that do not know me, Thomas_Conroy is my sa-mp name.)
Reply
#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
#3

Nice!
I already saw that shark and a hen on some servers,where can I find them? Because I can't find them...
Reply
#4

Quote:
Originally Posted by soueu
Nice!
I already saw that shark and a hen on some servers,where can I find them? Because I can't find them...
http://forum.sa-mp.com/index.php?topic=89755.0

sea suits... turtle is the best HAIL TO TURTLE! xD
Reply
#5

Nice, thx!
Reply
#6

Quote:
Originally Posted by soueu
Nice, thx!
The funny thing is I made that script as well >.> A little bit of advertising going on there!
Reply
#7

xD, yes I know, sry I just didn't find the shark script...
Reply
#8

Quote:
Originally Posted by soueu
xD, yes I know, sry I just didn't find the shark script...
Mmmm, SeaSuits was originally going to be called SharkSuit but then I realised there were other Sea creatures..

SeaSuits contains Shark, Dolphin and Turtle atm, but I have a starfish planned.. and if I find anything.. I was trying a Cow but that didn't go as planned.
Reply
#9

Nice.
Reply
#10

Quote:
Originally Posted by soueu
Nice.
Thanks again I guess >.>
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)