Guest User

mGate 2.1 by MP2

a guest
Jun 29th, 2013
1,027
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 18.63 KB | None | 0 0
  1. /*
  2. mGates 2.1 - by Mike
  3. Easily create automatic or command-based gates with ONE function!
  4.  
  5. FUNCTIONS:
  6. CreateAutomaticGate (CreateAutoGate)
  7. - Create a gate that opens and closes automatically, when a player comes close
  8.  
  9. CreateSemiAutoGate
  10. - Create a gate that must be manually opened by the script (for example; when a
  11. player honks their horn or types a command) that automatically closes when they
  12. get far enough away
  13.  
  14. CreateManualGate (CreateGate)
  15. - Create a gate that must be 100% controlled by the script
  16.  
  17. */
  18.  
  19. /*
  20. ### 'INSTALLATION' ###
  21.  
  22. Place this .inc file in your \pawno\include folder.
  23. You will also need foreach and y_hooks, which can be downloaded here:
  24.  
  25. foreach:                    http://forum.sa-mp.com/showthread.php?t=92679
  26. y_hooks is part of YSI:     http://forum.sa-mp.com/showthread.php?p=1696956
  27.  
  28. Put all the .inc files in \pawno\include.
  29.  
  30. If you get an error on compile saying 'can not read from file' then you did this
  31. step wrong.
  32. If you are 100% certain the files are in your \pawno\include folder, you may
  33. have multiple instances of pawno. If so, you may want to delete the bad one.
  34. Search your PC.
  35.  
  36. ### USAGE ###
  37.  
  38. Instructions will be here
  39.  
  40.  
  41.  
  42. ### CHANGELOG ###
  43.     2.1 (July 2013):
  44.     - Gates now only trigger if the player is level with the gate (Z height checks)
  45.    
  46.     2.0 (May 2013):
  47.     - Added semi-auto and manual gates.
  48.     - Added 'playsound' parameter to gate creation functions to let mGates
  49.     automatically handle the playing of sound effects when a gate opens/closes.
  50.     (Defaults to false)
  51.     - Small fixes and improvements.
  52.     - Better naming of variables and functions.
  53.    
  54.    
  55.     1.0 (7th of July 2012):
  56.     - Initial release
  57.  
  58. ### CREDITS ###
  59.  
  60. Mike - Creation
  61. Y_Less - foreach and y_hooks
  62.  
  63. ===============================================================================
  64.  
  65. There is only one function - CreateAutomaticGate (or alternatively, CreateAutoGate):
  66.  
  67. CreateAutoGate(modelid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, Float:x2, Float:y2, Float:z2, Float:rx2, Float:ry2, Float:rz2, Float:trigx, Float:trigy, Float:trigz, Float:trig_range, Float:movespeed, bool:auto_open=true, bool:auto_close=true, bool:condition=false, bool:playsound=true);
  68.  
  69.     Parameters:
  70.     modelid - The object model to use for the gate
  71.     x y z - The position of the CLOSED gate
  72.     rx ry rz - The rotation of the CLOSED gate
  73.     x2 y2 z2 - The position of the OPEN gate
  74.     rx2 ry2 rz2 - The rotation of the OPEN gate
  75.     Set ALL to -1000 to NOT change rotation
  76.     trigx trigy trigz - The trigger point. Players in range of this point will
  77.                         cause the gate to open (or close if nobody in range)
  78.     trig_range - The range from the trigger point (trigx trigy trigz) at which
  79.                  players will cause the gate to open (or close if not in range)
  80.     movespeed - The movement speed for the object. The differs drastically for
  81.                 rotating and sliding gates. See tutorial below
  82.     condition - If condition is set to true, you must return true in the the
  83.                 OnOnPlayerRequestGate callback for the player to pass,
  84.                 there you can check if the player meets a certain condition,
  85.                 for example you may only want cops to be able to trigger the
  86.                 gate to open. If set to false the gate will open for anyone.
  87.                 Do note however, someone that is NOT a cop could still get in
  88.                 after a cop triggers it to open.
  89.  
  90.     Returns:
  91.     The ID of the gate that was created (NOTE: NOT the object ID!)
  92.     -1 if the gate wasn't created (limit reached)
  93.  
  94. ===============================================================================
  95.  
  96. To force a gate to open:
  97.  
  98. OpenGate(gateid);
  99.  
  100.     Parameters:
  101.     gateid - The ID of the gate. Returned by CreateAutomaticGate().
  102.  
  103.     Returns:
  104.     -1 - Gate doesn't exist
  105.     0- Gate already open(ing)
  106.     1 - Gate opening - success
  107.  
  108. ===============================================================================
  109.  
  110. To force a gate to close:
  111.  
  112. CloseGate(gateid);
  113.  
  114.     Parameters:
  115.     gateid - The ID of the gate. Returned by CreateAutomaticGate().
  116.  
  117.     Returns:
  118.     -1 - Gate doesn't exist
  119.     0- Gate already close(ing)
  120.     1 - Gate closing - success
  121.  
  122. ===============================================================================
  123.  
  124. To check the state of a gate (open/closed/opening/closing):
  125.  
  126. GateStatus(gateid);
  127.  
  128.     Parameters:
  129.     gateid - The ID of the gate. Returned by CreateAutomaticGate().
  130.  
  131.     Returns:
  132.     -1 - Gate doesn't exist
  133.     GATE_STATUS_CLOSED 0 - Gate is fully closed
  134.     GATE_STATUS_OPENING 1 - Gate is opening, not yet fully open
  135.     GATE_STATUS_OPEN 2 - Gate is fully open
  136.     GATE_STATUS_CLOSING 3 - Gate is closing, not yet fully closed
  137.  
  138. ===============================================================================
  139.  
  140. To remove/delete/destroy a gate:
  141.  
  142. DestroyGate(gateid);
  143. or
  144. DeleteGate(gateid);
  145. or
  146. RemoveGate(gateid);
  147.  
  148.     Parameters:
  149.     gateid -
  150.     The ID of the gate to destroy/delete. Returned by CreateAutomaticGate().
  151.  
  152.     Returns:
  153.     -1 - Invalid gate ID
  154.     0 - Gate doesn't exist
  155.     1 - Gate was destroyed successfully
  156.  
  157. ===============================================================================
  158.  
  159. */
  160.  
  161. /*     SETUP / CONFIG      */
  162.  
  163. // Number of gates that can be created by the script.
  164. #define MAX_GATES 100
  165.  
  166. // The interval at which the gates are checked for players in range (in MS)
  167. #define TRIGGER_INTERVAL 800 // Radius check in miliseconds (1000 = 1 second)
  168.  
  169. /*  END OF SETUP / CONFIG  */
  170.  
  171.  
  172.  
  173. // SCRIPT STARTS.
  174. // FEEL FREE TO BROWSE THE CODE TO LEARN
  175. // IT IS WELL COMMENTED FOR THIS EXACT PURPOSE.
  176.  
  177. #include <foreach>
  178. #include <YSI\y_hooks>
  179.  
  180. #include streamer
  181. #if defined CreateDynamicObject
  182. #define USE_INCOGNITO
  183. #endif
  184.  
  185. /* FAKE NATIVES */
  186. /*
  187. native CreateAutomaticGate(modelid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, Float:x2, Float:y2, Float:z2, Float:rx2, Float:ry2, Float:rz2, Float:trigx, Float:trigy, Float:trigz, Float:trig_range, Float:movespeed, bool:condition=false);
  188.  
  189. native CreateAutoGate(modelid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, Float:x2, Float:y2, Float:z2, Float:rx2, Float:ry2, Float:rz2, Float:trigx, Float:trigy, Float:trigz, Float:trig_range, Float:movespeed, bool:condition=false);
  190.  
  191. native OpenGate(gateid);
  192. native CloseGate(gateid);
  193. native GateStatus(gateid);
  194. native IsValidGateID(gateid);
  195. native DeleteGate(gateid);
  196. native DestroyGate(gateid);
  197. native RemoveGate(gateid);
  198.  
  199. */
  200.  
  201. forward OnGateStateChange(gateid, newstate, Float:gatex, Float:gatey, Float:gatez);
  202. // OnGateStateChange is called when a gate's open/closed state changes.
  203. //  GATE_STATUS_CLOSED 0 - Gate is fully closed
  204. //  GATE_STATUS_OPENING 1 - Gate is opening, not yet fully open
  205. //  GATE_STATUS_OPEN 2 - Gate is fully open
  206. //  GATE_STATUS_CLOSING 3 - Gate is closing, not yet fully closed
  207.  
  208. forward OnPlayerRequestGate(playerid, gateid);
  209. // OnPlayerRequestGate is called when a gate is triggered if 'condition' was set to true in CreateAutomaticGate.
  210. // Returning 0 in this callback will prevent the gate from opening, so you can check for stuff
  211. // For example you may only want cops to access a gate.
  212.  
  213. forward OnPlayerTriggerGate(playerid, gateid);
  214.  
  215.  
  216.  
  217. // Gate States
  218. #define GATE_STATUS_CLOSED 0
  219. #define GATE_STATUS_OPENING 1
  220. #define GATE_STATUS_OPEN 2
  221. #define GATE_STATUS_CLOSING 3
  222.  
  223. // Gate Types
  224. #define MGATE_TYPE_FULL_AUTO 0
  225. #define MGATE_TYPE_
  226. #define MGATE_TYPE_
  227. #define MGATE_TYPE_FU
  228.  
  229. enum E_MGATE_DATA
  230. {
  231.     mgate_type, // Type of gate (defined above)
  232.     mgate_objectid, // The internal objectid for the gate
  233.     mgate_model, // The object model of the gate
  234.     Float:mgate_closed_pos[6], // The gate's pos and rot when closed
  235.     Float:mgate_open_pos[6], // The gate's pos and rot when
  236.     Float:mgate_trigger[3], // The trigger point
  237.     Float:mgate_trigger_radius, // The radius from the trigger point at which the gate is triggered to open
  238.     Float:mgate_movespeed, // The movement speed for the object
  239.     bool:mgate_condition, // if 1 the gate will not open unless 'return 1;' is used in the OnPlayerRequestGate() callback
  240.     mgate_status
  241. }
  242.  
  243. new g_GateData[MAX_GATES][E_MGATE_DATA];
  244.  
  245. new Iterator:mGates<MAX_GATES>;
  246.  
  247. // The ID for the timer. Killed if filterscript is unloaded (if a FS)
  248. new mgate_trigger_TIMERID;
  249.  
  250.  
  251.  
  252. /*   ## FUNCTIONS ##   */
  253.  
  254. #define CreateAutoGate CreateAutomaticGate
  255.  
  256. stock CreateAutomaticGate(modelid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, Float:x2, Float:y2, Float:z2, Float:rx2, Float:ry2, Float:rz2, Float:trigx, Float:trigy, Float:trigz, Float:trig_range, Float:movespeed, bool:condition=false)
  257. {
  258.     if(Iter_Count(mGates) == MAX_GATES) // Gate limit (MAX_GATES) reached
  259.     {
  260.         // Alert the scripter
  261.         printf("\
  262.         [mGates] ERROR: Gate limit (#MAX_GATES) reached. Could not create additional gate.\n\
  263.         Increase MAX_GATES define in mGates.inc to increase limit.\
  264.         ");
  265.        
  266.         // Return -1 so action could be taken in the script
  267.         // (0 would be a valid gate ID, so -1 must be used)
  268.         return -1;
  269.     }
  270.  
  271.     new i = Iter_Free(mGates); // Get the free ID in the iterator
  272.  
  273.  
  274.     // Create the object
  275.     #if defined USE_INCOGNITO
  276.         g_GateData[i][mgate_objectid] = CreateDynamicObject(modelid, x, y, z, rx, ry, rz);
  277.     #else
  278.         g_GateData[i][mgate_objectid] = CreateObject(modelid, x, y, z, rx, ry, rz, 300.0);
  279.     #endif
  280.    
  281.     // Save all the data
  282.    
  283.     //NModel
  284.     g_GateData[i][mgate_model] = modelid;
  285.    
  286.     // Closed Position
  287.     g_GateData[i][mgate_closed_pos][0] = x;
  288.     g_GateData[i][mgate_closed_pos][1] = y;
  289.     g_GateData[i][mgate_closed_pos][2] = z;
  290.    
  291.     // Closed Rotation
  292.     g_GateData[i][mgate_closed_pos][3] = rx;
  293.     g_GateData[i][mgate_closed_pos][4] = ry;
  294.     g_GateData[i][mgate_closed_pos][5] = rz;
  295.    
  296.     // Open Position
  297.     g_GateData[i][mgate_open_pos][0] = x2;
  298.     g_GateData[i][mgate_open_pos][1] = y2;
  299.     g_GateData[i][mgate_open_pos][2] = z2;
  300.    
  301.     // Open Rotation
  302.     g_GateData[i][mgate_open_pos][3] = rx2;
  303.     g_GateData[i][mgate_open_pos][4] = ry2;
  304.     g_GateData[i][mgate_open_pos][5] = rz2;
  305.    
  306.     // Trigger Point
  307.     g_GateData[i][mgate_trigger][0] = trigx;
  308.     g_GateData[i][mgate_trigger][1] = trigy;
  309.     g_GateData[i][mgate_trigger][2] = trigz;
  310.    
  311.     // Trigger Radius
  312.     g_GateData[i][mgate_trigger_radius] = trig_range;
  313.    
  314.     // Move Speed
  315.     g_GateData[i][mgate_movespeed] = movespeed;
  316.    
  317.     // Condition?
  318.     g_GateData[i][mgate_condition] = condition;
  319.    
  320.     // Starting status - closed of course
  321.     g_GateData[i][mgate_status] = GATE_STATUS_CLOSED;
  322.    
  323.     // Add the gate to the iterator
  324.     Iter_Add(mGates, i);
  325.    
  326.     // The function will return the gate ID
  327.     // (not object ID, the internal gate ID to be used in other functions
  328.     // and callbacks throughout the script)
  329.     return i;
  330. }
  331.  
  332. #define IsValidGateID(%0) (%0 >= 0 && %0 < MAX_GATES)
  333. /*
  334. Macro Substitution:
  335. #define IsValidGateID(69) (69 >= 0 && 69 < MAX_GATES)
  336.  
  337. Breakdown:
  338. If 69 is more than or equal to 0, and less than MAX_GATES
  339. If 69 is between 0 and MAX_GATES
  340. if %0 is between 0 and MAX_GATES
  341. */
  342.  
  343. stock OpenGate(gateid)
  344. {
  345.     if(!IsValidGateID(gateid)) return 0;
  346.     if(Itter_Contains(mGates, gateid) == 0) return 0; // Doesn't exist
  347.  
  348.     if(g_GateData[gateid][mgate_status] == GATE_STATUS_OPEN || g_GateData[gateid][mgate_status] == GATE_STATUS_OPENING) return 0; // Already open
  349.  
  350.     // Move the object to the open position
  351.     #if defined USE_INCOGNITO
  352.         MoveDynamicObject(
  353.         g_GateData[gateid][mgate_objectid], // Model
  354.         g_GateData[gateid][mgate_open_pos][0], g_GateData[gateid][mgate_open_pos][1], g_GateData[gateid][mgate_open_pos][2], // X, Y, Z
  355.         g_GateData[gateid][mgate_movespeed], // Speed
  356.         g_GateData[gateid][mgate_open_pos][3], g_GateData[gateid][mgate_open_pos][4], g_GateData[gateid][mgate_open_pos][5] // RX, RY, RZ
  357.         );
  358.     #else
  359.         MoveObject(
  360.         g_GateData[gateid][mgate_objectid], // Model
  361.         g_GateData[gateid][mgate_open_pos][0], g_GateData[gateid][mgate_open_pos][1], g_GateData[gateid][mgate_open_pos][2], // X, Y, Z
  362.         g_GateData[gateid][mgate_movespeed], // Speed
  363.         g_GateData[gateid][mgate_open_pos][3], g_GateData[gateid][mgate_open_pos][4], g_GateData[gateid][mgate_open_pos][5] // RX, RY, RZ
  364.         );
  365.     #endif
  366.    
  367.     // Set the status to 'opening'
  368.     g_GateData[gateid][mgate_status] = GATE_STATUS_OPENING;
  369.  
  370.     // Trigger OnGateStateChange
  371.     CallLocalFunction("OnGateStateChange", "iifff", gateid, GATE_STATUS_OPENING, g_GateData[gateid][mgate_closed_pos][0], g_GateData[gateid][mgate_closed_pos][1], g_GateData[gateid][mgate_closed_pos][2]);
  372.     return 1;
  373. }
  374.  
  375. stock CloseGate(gateid)
  376. {
  377.     if(!IsValidGateID(gateid)) return 0;
  378.     if(Itter_Contains(mGates, gateid) == 0) return 0; // Doesn't exist
  379.  
  380.     if(g_GateData[gateid][mgate_status] == GATE_STATUS_CLOSED || g_GateData[gateid][mgate_status] == GATE_STATUS_CLOSING) return 0; // Already closed
  381.  
  382.     // Move the object to the closed position
  383.     #if defined USE_INCOGNITO
  384.         MoveDynamicObject(
  385.         g_GateData[gateid][mgate_objectid],
  386.         g_GateData[gateid][mgate_closed_pos][0], g_GateData[gateid][mgate_closed_pos][1], g_GateData[gateid][mgate_closed_pos][2], // X, Y, Z
  387.         g_GateData[gateid][mgate_movespeed], // Speed
  388.         g_GateData[gateid][mgate_closed_pos][3], g_GateData[gateid][mgate_closed_pos][4], g_GateData[gateid][mgate_closed_pos][5] // RX, RY, RZ
  389.         );
  390.     #else
  391.         MoveObject(
  392.         g_GateData[gateid][mgate_objectid],
  393.         g_GateData[gateid][mgate_closed_pos][0], g_GateData[gateid][mgate_closed_pos][1], g_GateData[gateid][mgate_closed_pos][2], // X, Y, Z
  394.         g_GateData[gateid][mgate_movespeed], // Speed
  395.         g_GateData[gateid][mgate_closed_pos][3], g_GateData[gateid][mgate_closed_pos][4], g_GateData[gateid][mgate_closed_pos][5] // RX, RY, RZ
  396.         );
  397.     #endif
  398.  
  399.     // Set the status to 'closing'
  400.     g_GateData[gateid][mgate_status] = GATE_STATUS_CLOSING;
  401.  
  402.         // Trigger OnGateStateChange
  403.     CallLocalFunction("OnGateStateChange", "iifff", gateid, GATE_STATUS_CLOSING, g_GateData[gateid][mgate_open_pos][0], g_GateData[gateid][mgate_open_pos][1], g_GateData[gateid][mgate_open_pos][2]);
  404.     return 1;
  405. }
  406.  
  407. #define DeleteGate DestroyGate // alternative function name (alias)
  408. #define RemoveGate DestroyGate // alternative function name (alias)
  409. stock DestroyGate(gateid)
  410. {
  411.     if(!IsValidGateID(gateid)) return 0;
  412.     if(Itter_Contains(mGates, gateid) == 0) return 0; // Doesn't exist
  413.  
  414.     #if defined USE_INCOGNITO
  415.         DestroyDynamicObject(g_GateData[gateid][mgate_objectid]);
  416.     #else
  417.         DestroyObject(g_GateData[gateid][mgate_objectid]);
  418.     #endif
  419.    
  420.     Iter_Remove(mGates, gateid);
  421.     return 1;
  422. }
  423.  
  424. stock GateStatus(gateid)
  425. {
  426.     if(!IsValidGateID(gateid)) return -1;
  427.     if(Itter_Contains(mGates, gateid) == 0) return -1; // Doesn't exist
  428.     // -1 must be used as 0 is a valid return value (GATE_STATUS_CLOSED)
  429.    
  430.     return g_GateData[igateidgate_status];
  431. }
  432.  
  433. /*   ## TIMER ##   */
  434.  
  435. forward TIMER_mGateChecks();
  436. public TIMER_mGateChecks()
  437. {
  438.     new count;
  439.    
  440.     // Loop through all gates (iterator)
  441.     foreach(new i : mGates)
  442.     {
  443.         if(g_GateData[i][mgate_status] == GATE_STATUS_CLOSED || g_GateData[i][mgate_status] == GATE_STATUS_CLOSING) // Gate is closed/closing, check if any players are near and open if so
  444.         {
  445.             // Loop through players
  446.             foreach(new playerid : Player)
  447.             {
  448.                 if(mGate_CheckProx(playerid, i)) // if in range of the gate
  449.                 {
  450.                     if(g_GateData[i][mgate_condition] == true) // Must pass condition!
  451.                     {
  452.                         if(CallLocalFunction("OnPlayerRequestGate", "ii", playerid, i) == 1)
  453.                         {
  454.                             OpenGate(i); // Open the gate
  455.                             CallLocalFunction("OnPlayerTriggerGate", "ii", playerid, i);
  456.                             break; // Break out of loop, we know at least one player is in the trigger radius, no need to continue to check for more
  457.                         }
  458.                     }
  459.                     else // No condition required
  460.                     {
  461.                         OpenGate(i); // Open the gate
  462.                         CallLocalFunction("OnPlayerTriggerGate", "ii", playerid, i);
  463.                         break; // Break out of loop, we know at least one player is in the trigger radius, no need to continue to check for more
  464.                     }
  465.                 }
  466.             }
  467.         }
  468.         else if(g_GateData[i][mgate_status] == GATE_STATUS_OPEN) // Gate is fully open, check if there are no players near trigger zone and close if so
  469.         {
  470.             foreach(new playerid : Player)
  471.             {
  472.                 if(mGate_CheckProx(playerid, i)) // if in range of the gate
  473.                 {
  474.                     if(g_GateData[i][mgate_condition] == true) // Must pass condition!
  475.                     {
  476.                         if(CallLocalFunction("OnPlayerRequestGate", "ii", playerid, i) == 1)
  477.                         {
  478.                             count = 1;
  479.                             break; // Break out of loop, we know at least one player is in the trigger radius, no need to continue to check for more
  480.                         }
  481.                     }
  482.                     else
  483.                     {
  484.                         count = 1;
  485.                         break; // Break out of loop, we know at least one player is in the trigger radius, no need to continue to check for more
  486.                     }
  487.                 }
  488.             }
  489.             if(!count) CloseGate(i);
  490.         }
  491.     }
  492.     return 1;
  493. }
  494.  
  495.  
  496.  
  497. /*   ## HOOKS ##   */
  498.  
  499. hook OnGameModeInit()
  500. {
  501.     // Start main timer
  502.     mgate_trigger_TIMERID = SetTimer("TIMER_mGateChecks", TRIGGER_INTERVAL, true);
  503.     return 1;
  504. }
  505.  
  506. hook OnFilterScriptInit()
  507. {
  508.     // Start main timer
  509.     mgate_trigger_TIMERID = SetTimer("TIMER_mGateChecks", TRIGGER_INTERVAL, true);
  510.     return 1;
  511. }
  512.  
  513. hook OnFilterScriptExit()
  514. {
  515.     // Kill main timer
  516.     KillTimer(mgate_trigger_TIMERID);
  517.     return 1;
  518. }
  519.  
  520. // Timer doesn't need to be killed ongamemodeexit
  521.  
  522. #if defined USE_INCOGNITO
  523. public OnDynamicObjectMoved(objectid)
  524. #else
  525. hook OnObjectMoved(objectid)
  526. #endif
  527. {
  528.     // Check if it was a gate that moved
  529.     foreach(new i : mGates)
  530.     {
  531.         if(g_GateData[i][mgate_model] != 0 && g_GateData[i][mgate_objectid] == objectid) // We found our gate.
  532.         {
  533.             if(g_GateData[i][mgate_status] == GATE_STATUS_CLOSING)
  534.             {
  535.                 g_GateData[i][mgate_status] = GATE_STATUS_CLOSED;
  536.                 CallLocalFunction("OnGateStateChange", "iifff", i, GATE_STATUS_CLOSED, g_GateData[i][mgate_closed_pos][0], g_GateData[i][mgate_closed_pos][1], g_GateData[i][mgate_closed_pos][2]);
  537.             }
  538.             else
  539.             {
  540.                 g_GateData[i][mgate_status] = GATE_STATUS_OPEN;
  541.                 CallLocalFunction("OnGateStateChange", "iifff", i, GATE_STATUS_OPEN, g_GateData[i][mgate_open_pos][0], g_GateData[i][mgate_open_pos][1], g_GateData[i][mgate_open_pos][2]);
  542.             }
  543.         }
  544.     }
  545.     #if defined USE_INCOGNITO
  546.         #if defined MGATE_OnDynamicObjectMoved
  547.             return MGATE_OnDynamicObjectMoved(objectid);
  548.         #else
  549.             return 1;
  550.         #endif
  551.     #else
  552.         return 1;
  553.     #endif
  554. }
  555. #if defined USE_INCOGNITO
  556.     #if defined MGATE_OnDynamicObjectMoved
  557.         forward MGATE_OnDynamicObjectMoved(objectid);
  558.     #endif
  559.     #if defined _ALS_OnDynamicObjectMoved
  560.         #undef OnDynamicObjectMoved
  561.     #else
  562.         #define _ALS_OnDynamicObjectMoved
  563.     #endif
  564.     #define OnDynamicObjectMoved MGATE_OnDynamicObjectMoved
  565. #endif
  566.  
  567. static mGate_CheckProx(playerid, i) // i = gate ID
  568. {
  569.     new Float:x, Float:y, Float:z;
  570.     GetPlayerPos(playerid, x, y, z);
  571.     return (IsPlayerInRangeOfPoint(playerid, g_GateData[i][mgate_trigger_radius], g_GateData[i][mgate_trigger][0], g_GateData[i][mgate_trigger][1], g_GateData[i][mgate_trigger][2]) && (z-2 < g_GateData[i][mgate_trigger][2] < z+2));
  572. }
Advertisement
Add Comment
Please, Sign In to add comment