Guest User

Awa_Gates.inc

a guest
Apr 15th, 2010
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.69 KB | None | 0 0
  1. /*
  2. *
  3. *   Awa-Gates by {Awaran};
  4. *
  5. *       @author: {Awaran};
  6. *       @version: 0.2
  7. *       @date: 13 Jan. 2010 (first release)
  8. *       @update: 15 April. 2010 (update of v0.2)
  9. *
  10. *   (c) Awaran - 2010 - 2011
  11. *
  12. *   FILE RELEASED 'AS IS' (NO WARRANTIES)
  13. *
  14. *   This file is intended for use on SA:MP 0.3a server versions.
  15. *
  16. */
  17.  
  18. #define GATE_LIMIT 480
  19. new gatetmp;
  20. new GateOb[GATE_LIMIT];
  21.  
  22. #define GATE_STATUS_CLOSED 0
  23. #define GATE_STATUS_OPEN 1
  24. #define IS_NEAR_RANGE 9.00
  25.  
  26. forward OnPlayerRequestGateOperation(playerid, gateid);
  27.  
  28. enum GateConfig
  29. {
  30.     Valid,
  31.     Float:close_X,
  32.     Float:close_Y,
  33.     Float:close_Z,
  34.     Float:open_X,
  35.     Float:open_Y,
  36.     Float:open_Z,
  37.     Status,
  38. }
  39.  
  40. new Gate[GATE_LIMIT][GateConfig];
  41.  
  42. stock CreateGate(modelid, Float:close_x, Float:close_y, Float:close_z, Float:open_x, Float:open_y, Float:open_z, Float:rX, Float:rY, Float:rZ)
  43. {
  44.     new gg = gatetmp;
  45.     gatetmp++;
  46.     GateOb[gg] = CreateObject(modelid, close_x, close_y, close_z, rX, rY, rZ);
  47.     Gate[gg][Valid] = 1;
  48.     Gate[gg][close_X] = close_x;
  49.     Gate[gg][close_Y] = close_y;
  50.     Gate[gg][close_Z] = close_z;
  51.     Gate[gg][open_X] = open_x;
  52.     Gate[gg][open_Y] = open_y;
  53.     Gate[gg][open_Z] = open_z;
  54.     Gate[gg][Status] = GATE_STATUS_CLOSED;
  55.     return gg;
  56. }
  57.  
  58. stock FunctionGate(playerid, gateid, Float:speed)
  59. {
  60.     if (OnPlayerRequestGateOperation(playerid, gateid))
  61.     {
  62.         if(Gate[gateid][Status] == GATE_STATUS_CLOSED)
  63.         {
  64.             OpenGate(GateOb[gateid], speed);
  65.             Gate[gateid][Status] = GATE_STATUS_OPEN;
  66.         }
  67.         else if(Gate[gateid][Status] == GATE_STATUS_OPEN)
  68.         {
  69.             CloseGate(GateOb[gateid], speed);
  70.             Gate[gateid][Status] = GATE_STATUS_CLOSED;
  71.         }
  72.     }
  73. }
  74.  
  75. stock OpenGate(gateid, Float:speed)
  76. {
  77.     MoveObject(GateOb[gateid], Gate[gateid][open_X], Gate[gateid][open_Y], Gate[gateid][open_Z], speed);
  78. }
  79.  
  80. stock CloseGate(gateid, Float:speed)
  81. {
  82.     MoveObject(GateOb[gateid],Gate[gateid][close_X], Gate[gateid][close_Y], Gate[gateid][close_Z], speed);
  83. }
  84.  
  85. stock IsNearGate(playerid) // returns -1 if no gate is near || returns the id of the gate the player is closest to
  86. {
  87.     for(new gateid = 0; gateid < GetMaxGates(); gateid++)
  88.     {
  89.         if(IsPlayerInRangeOfPoint(playerid, IS_NEAR_RANGE, Gate[gateid][close_X], Gate[gateid][close_Y], Gate[gateid][close_Z]))
  90.         {
  91.             return gateid;
  92.         }
  93.     }
  94.     return -1;
  95. }
  96.  
  97. stock GetMaxGates()
  98. {
  99.     return gatetmp;
  100. }
  101.  
  102. /*
  103. native CreateGate(modelid, Float:close_x, Float:close_y, Float:close_z, Float:open_x, Float:open_y, Float:open_z, Float:rX, Float:rY, Float:rZ);
  104. native FunctionGate(gateid, Float:speed);
  105. native OpenGate(gateid, Float:speed); // not recommended for use
  106. native CloseGate(gateid, Float:speed);// not recommended for use
  107. native IsNearGate(playerid);
  108. native GetMaxGates();
  109. */
Advertisement
Add Comment
Please, Sign In to add comment