[Include] NGATE v2.1 - Create gates, barriers and elevators with only 1 line of code!
#1


About Me:
Hello dear SA-MP community My name's Nickk888, i'm a German/Polish PAWN Scripter for about 6 years now, I own a ******* channel about SA-MP Scripting in Polish language and I create scripts for the public for free. Excuse my English skill, I'm no native English speaker, so please keep this in mind I'll try my best ^_^

About Include:
NGATE(Nickk's Gate Include) is a Include that makes it possible to "generate" fully functional gates, barriers and even elevators! Only using 1 line of code! You can set the direction of movement, the speed of movement, how you want it to trigger, everything! You can even set permissions on your gate or barrier that only for example fraction members are able to use the gate or barrier! On V2.1 you can also set "cascade triggers", means that when you trigger a gate, other gates that are connected to each other will also trigger, that makes it useful for double side gates etc.

Features:
  • Freaking one line of code!
  • Self hooking Include, just include it!
  • Many options to "program" your gate, barrier or elevator!
  • Compatible with ZCMD.
  • Fully optimized include, using PoolSize for gates!(V2.0 & V2.1)
  • No Timers! Trigger using Dynamic Areas!, which makes it super optimized!(V2.5 >)
  • Less CPU usage! Due to Dynamic Areas check!(V2.5 >)
  • No looping operations while checking!(V2.5 >)
  • Pre-defined or Custom gate move to position!(V3.0 >)
  • Pre-defined or Custom barrier rotation!(V3.0 >)
Changelog:
Version 3.0:
Code:
- Switched from "for(new" loops to YSI's "foreach" loops for better performance.
- Changed some variables name to eliminate potential duplicates.
- Added "moveSpeed" parameter for barriers.
- Barriers rotation is now fully custom. You can still use the definitions or put your own rotation value(0-360 degrees).
- Added "MOVE_CUSTOM" definition for gates.
- Added "movetoX", "movetoY", "movetoZ" parameter for custom 'move-to' position.
- Increased max gates from 250 to 1000.
- Increased max groups from 50 to 500.
- Bug Fixed: Barrier or Gate was stuck if player exited while on gate area.
- Bug Fixed: Barrier or Gate was still in group array when destroyed.
- Other small bug fixes which are not very relevant to put into this list.
Version 2.5 Optimization Update:
Code:
- Changed Timer Trigger to Dynamic Area Trigger(No Radius check).
- Deleted "moveTime" parameter.
- Deleted "NGatesCheck" function.
- All Timers deleted.
- Deleted definition "NGATE_UPDATEINTERVAL".
- Added mode "MODE_MANUAL_AUTO".
- Deleted GatesPoolSize.
Version 2.1:
Code:
- Added Groups.
- Added Cascade triggering.
Version 2.0:
Code:
- First Release
Functions:
Code:
NGateCreate(modelID, Float: objectX, Float: objectY, Float: objectZ, Float: objectRotX=0.0, Float: objectRotY=0.0, Float: objectRotZ=0.0, moveDirection = MOVE_DOWN, Float: movetoX = 0.0, Float: movetoY = 0.0, Float: movetoZ = 0.0, moveMode = MODE_ALL_AUTO, Float:moveSpeed = 3.0, Float:moveRadius = 6.0, accessID[]={ -1 }, Float: detectRadius=13.0, detectKey=KEY_CROUCH, CmdToOpen[]="", CmdToClose[]="", Float: cDetectX=0.0, Float: cDetectY=0.0, Float: cDetectZ=0.0, accessIDsize = sizeof accessID)
NBarrierCreate(Float: objectX, Float: objectY, Float: objectZ, Float:objectZRot, moveMode = MODE_ALL_AUTO, Float:RotSpeed = 1.0, accessID[]={ -1 }, Float: detectRadius=13.0,  detectKey=KEY_CROUCH, CmdToOpen[]="", CmdToClose[]="", Float: cDetectX=0.0, Float: cDetectY=0.0, Float: cDetectZ=0.0, accessIDsize = sizeof accessID)
NGateDestroy(gateid);
NGateSetAccessID(playerid, id);
NGateOpen(gateid);
NGateClose(gateid);
NGateIsGateOpen(gateid);
NGateCreateGroup();
NGateAddToGroup(gateid, groupid);
NGateReturnObjectID(gateid);
How to use it(Examples):
To Create a simple gate:
Code:
NGateCreate(MODELID, X, Y, Z, XR, YR, ZR, DIRECTION);
or
NGateCreate(MODELID, X, Y, Z, XR, YR, ZR, MOVE_CUSTOM, MOVETOX, MOVETOY, MOVETOZ);
To Create a simple barrier:
Code:
NBarrierCreate(X, Y, Z, DIRECTION_ROTATION);
Those functions are from my example script:
Code:
//Gates
NGateCreate(969, 1503.50, -2498.4253, 12.7261, 0.0, 0.0, 90.0, MOVE_DOWN);
NGateCreate(969, 1533.50, -2498.4253, 12.7261, 0.0, 0.0, 90.0, MOVE_CUSTOM, 0.0, 0.0, 0.0, MODE_VEHICLE_KEYINPUT, 3.0, 8.0);
NGateCreate(969, 1563.50, -2498.4253, 12.7261, 0.0, 0.0, 90.0, MOVE_UP, 0.0, 0.0, 0.0, MODE_ALL_COMMANDINPUT, 3.0, 8.0, {-1}, 10.0, -1, "/open");
NGateCreate(969, 1593.50, -2498.4253, 12.7261, 0.0, 0.0, 90.0, MOVE_SOUTH, 0.0, 0.0, 0.0, MODE_WALK_COMMANDINPUT, 3.0, 8.0, {20}, 10.0 , -1, "/open", "/close");
gateid1 = NGateCreate(969, 1623.50, -2498.4253, 12.7261, 0.0, 0.0, 90.0, MOVE_NORD, 0.0, 0.0, 0.0, MODE_MANUAL, 3.0, 8.0);
new groupid = NGateCreateGroup();
new tmp_gateid1 = NGateCreate(988, 1653.5431, -2491.3015, 13.5800, 0.0, 0.0, -90.0, MOVE_NORD, 0.0, 0.0, 0.0, MODE_ALL_AUTO, 0.5, 4.0);
new tmp_gateid2 = NGateCreate(988, 1653.5431, -2496.7822, 13.5800, 0.0, 0.0, -90.0, MOVE_SOUTH, 0.0, 0.0, 0.0, MODE_ALL_AUTO, 0.5, 4.0);
NGateAddToGroup(tmp_gateid1, groupid);
NGateAddToGroup(tmp_gateid2, groupid);
gateid2 = NGateCreate(980, 1687.8888, -2494.1372, 12.5575, 90.0, 0.0, 0.0, MOVE_UP, 0.0, 0.0, 0.0, MODE_MANUAL, 3.0, 26.0);
NGateCreate(980, 1693.6348, -2494.5649, 41.1800, 0.0, 0.0, 90.0, MOVE_NORD, 0.0, 0.0, 0.0, MODE_VEHICLE_AUTO, 1.0, 12.0);

//Barriers
NBarrierCreate(1759.87183, -2512.34668, 39.30200, 45.0);
NBarrierCreate(1759.87183, -2542.34668, 39.30200, BARRIER_ROT_OST, MODE_VEHICLE_COMMANDINPUT, 1.0, {10, 15, 64}, 10.0, -1, "/open");
NBarrierCreate(1759.87183, -2572.34668, 39.30200, BARRIER_ROT_OST, MODE_VEHICLE_KEYINPUT);
barierid1 = NBarrierCreate(1759.87183, -2602.34668, 39.30200, BARRIER_ROT_OST, MODE_MANUAL_AUTO, 1.0, {-1}, 10.0);
Defines:
Code:
#define NGATE_MAX_GATES 1000
#define NGATE_MAX_GROUPS 500

#define MOVE_DOWN 0
#define MOVE_UP 1
#define MOVE_NORD 2
#define MOVE_OST 3
#define MOVE_SOUTH 4
#define MOVE_WEST 5
#define MOVE_CUSTOM 6

#define MODE_MANUAL 0
#define MODE_MANUAL_AUTO 1
#define MODE_ALL_AUTO 2
#define MODE_WALK_AUTO 3
#define MODE_VEHICLE_AUTO 4
#define MODE_ALL_KEYINPUT 5
#define MODE_WALK_KEYINPUT 6
#define MODE_VEHICLE_KEYINPUT 7
#define MODE_ALL_COMMANDINPUT 8
#define MODE_WALK_COMMANDINPUT 9
#define MODE_VEHICLE_COMMANDINPUT 10

#define BARRIER_ROT_NORD 90.0
#define BARRIER_ROT_OST 0.0
#define BARRIER_ROT_SOUTH -90.0
#define BARRIER_ROT_WEST 180.0
Video:
https://www.youtube.com/watch?v=2PwTTDlonSs

Requirement:
You need Incognitos Streamer Plugin for it to work! Click HERE to download.
You also need the YSI library. Click HERE to download. This library is also included within the NGate package.
There is a possibility that your PAWN compilator will crash while compiling, therefore you should get ZEEX's Pawn Patch. Click HERE to download.

Download:
https://t2m.io/GAz5gMep

Credits:
a_samp: SAMP Team
Streamer: Incognito
Y_Hooks and Y_Iterate: Y_Less
Reply
#2

Nice work
Reply
#3

Amazing, keep that up mate, I had the same idea for the longest time now, +rep.
Reply
#4

why do you use timers to open gate? instead of opening them instantly also you could use dynamic areas
Reply
#5

awesome
Reply
#6

Quote:
Originally Posted by Lokii
View Post
why do you use timers to open gate? instead of opening them instantly also you could use dynamic areas
Thank you for the suggestion! I totally forgot about Dynamic areas I've changed the whole checking system from timers to Dynamic Areas. It's now available in the download link!
Reply
#7

Oh shit, this is very nice bro!
Reply
#8

Glad to see your making use of the YSI library. Since it uses groups, you should use y_groups for that also
Reply
#9

NGate has been updated to version 3.0!
Code:
- Switched from "for(new" loops to YSI's "foreach" loops for better performance.
- Changed some variables name to eliminate potential duplicates.
- Added "moveSpeed" parameter for barriers.
- Barriers rotation is now fully custom. You can still use the definitions or put your own rotation value(0-360 degrees).
- Added "MOVE_CUSTOM" definition for gates.
- Added "movetoX", "movetoY", "movetoZ" parameter for custom 'move-to' position.
- Increased max gates from 250 to 1000.
- Increased max groups from 50 to 500.
- Bug Fixed: Barrier or Gate was stuck if player exited while on gate area.
- Bug Fixed: Barrier or Gate was still in group array when destroyed.
- Other small bug fixes which are not very relevant to put into this list.
Have fun!
Reply
#10

link no work
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)