[FilterScript] jGate - Automatic Gate System
#1

jGate
Automatic Gate System

With this Filterscript you can create a automatic gate with the choices of having them for a vehicle only, onfoot only, or both.

jGate supports up, down, left, right moving, it also supports SETTING rotation.
I did not include a smooth rotation (maybe used for barriers) because it wouldn't be worth the very fast timer per moving object, so keep in mind this uses the Icognito's Streamer's SetDynamicObjectRot, which sets the rot, not movies it slowly.

jGate also supports interiors and virtual worlds.

jGate requires Icognitos streamer plugin installed and running, you can download it at:

https://sampforum.blast.hk/showthread.php?tid=102865

Description

jGate is a stand-alone Filterscript used for creating a automatic gate with many options, all in one line, whilst being rather efficient.

Performance

jGate has its ups and downs.

There's one timer, the callback that the timer uses has one player loop, that has as many itterations as your maxplayers in your server.cfg, for every player, there's a loop that checks all gates, so more gates you have, the more recourses will be used.

maxplayers * amount of gates = total itterations

which would be called every X seconds, so try to keep the timer interval at a slow rate, I used 3 as a example, which is still rather low, 5 looks decents, depending on your average player count.

The code has been optimized for speed and at the same time be as dynamic as possible.

Please keep in mind this script has only been tested with one player, reworking the script logically didn't show up any bugs that would only make it work for one player, if you do find such a bug, tell me.

Bugs

If you have two gates in the same vercinity (rather close, for example, the two gates at SF airport in singleplayer) only one of them will open, this is because there's only one cell in an array for every player, if I would've let both open, the first GateID that was stored in that cell would be erased, hense the gate never closing, I am thinking of reworking this in the future.

Install

Go to the file 'pawno' in your server directory and open it, there open 'pawno.exe' and click 'new'.
Once you've done that, right click and click 'select all' then press delete.
Then you'll need the code, which is in the 'Download' section below, go to the link and copy and paste the code into the pawno document, for instructions on how to insert a gate, read below.
Once you have pasted the code into the pawno document, compile and close.
Add the name of the file to the end of your 'filterscripts' line in your server.cfg.
Then you're finished.

Adding a Gate

Adding a gate with jGate is rather simple.

The script itself is based on arrays, so it's super easy.

Steps:

Open jGate.pwn and find the line 'new gData[][E_GATE_DATA]'

Underneath will be the format used to create a gate.

Where the example gate is (the code starting with '1337') delete it, and use the following format to create your gate:

pawn Код:
{Model, ClosedX, ClosedY, ClosedZ, ClosedRotX, ClosedRotY, ClosedRotZ, OpenX, OpenY, OpenZ, OpenRotX, OpenRotY, OpenRotZ, Interior, World, Drawdistance, Radius, Speed, State (KEEP FALSE), ignorevehicle (0 = driver+onfoot, 1 = onfoot, 2 = driver), GateID (KEEP -1)}
Once finished, double check your coordinates to make sure they're correct and compile, then close.

Please remember, YOU WILL NEED TO GET THE GATE COORDINATES YOURSELF! THIS IS JUST A HANDLER.

Then you're finished, have fun with your new gate!

Remember, you can add more gates, not just one. (Wouldn't that be a buzzkill)

Suggestions

If you have a suggestion that will add more options, please post them !

Download

Pastebin: http://joelewis.pastebin.com/5WDdAAsZ


Changelog

02/08/2010 - Added rotation support

Reply
#2

So cool,good job!
Reply
#3

Huh,nice,I really like it,saves a lot of work for lazy people like me.
And now when people ask how to make automatic gates you can just redirect them to here XD
5/5(new threads are rateable )
Reply
#4

Thanks guys, and that is what sparked me to make this filterscript, me being bored and seeing the Scripting Discussion with 3 threads about automatic gates.
Reply
#5

Great job bro!
Reply
#6

Thank you
Reply
#7

Update:

added support for rotation as requested / suggested by DR4X.
Reply
#8

Hey, nice work.
Reply
#9

Here is my errors, this is only when i try and compile with more than one gate. just one gate it works perfectly, but 2 gives me this error
Код:
C:\Documents and Settings\Owner\Desktop\PWNS\gates.pwn(36) : error 001: expected token: "}", but found "{"
C:\Documents and Settings\Owner\Desktop\PWNS\gates.pwn(37) : error 010: invalid function or declaration
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Here are the cords for my two gates, well the cords & bit of the script.

pawn Код:
new gData[][E_GATE_DATA] =
{
    /*
    Format as follows:

    {Model, ClosedX, ClosedY, ClosedZ, RotX, RotY, RotZ, OpenX, OpenY, OpenZ, Interior, World, Drawdistance, Radius, Speed, State (KEEP FALSE), ignorevehicle (0 = driver+onfoot, 1 = onfoot, 2 = driver), GateID (KEEP -1)}
    */




/* 35 */    {969, 1958.298461,-2190.121826,12.671833,0.000000,0.000000,361.756713, 1961.291015,-2189.990478,16.496740, 0, 0, 100.0, 10.0, 1.0, false, 2, -1} // LSAP GATE
/* 36 */    {976, 1277.453369,-1270.343261,10.386049,0.000000,0.000000,180.162322, 1277.453369,-1270.343261,9.336759, 0, 0, 100.0, 10.0, 1.0, false, 0, -1} // OLPAE CONSTRUCTIONS
};
i dont think im doing anything wrong in the script, unless i need a closing brace, but i have already tried xD

EDIT: I put the lines in that are in the error. I have everything included, ect

Thanks In Advance!
Reply
#10

You need a comma after every end of the array entry.

pawn Код:
new gData[][E_GATE_DATA] =
{
{stuff},
{stuff},
{stuff} // It's important to have no comma for the last entry.
};
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)