Guest User

AutoMove.inc

a guest
Sep 17th, 2017
210
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //made by lokii
  2.  
  3. #if defined _AutoMove_included
  4. #endinput
  5. #define _AutoMove_included
  6. #endif
  7.  
  8. /*
  9. native CreateAutoObject(id, modelid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, Float:stream_distance, Float:move_distance, Float:tox, Float:toy, Float:toz, Float:move_speed);
  10. native DestroyAutoObject(id);
  11. native DestroyAllAutoObjects();
  12. */
  13.  
  14. #include <streamer> //credits to incognito
  15. #include <YSI\y_hooks> //credits to y_less
  16.  
  17. #define AutoMoveVersion "1.0"
  18.  
  19. #define MAX_AUTO_OBJECTS 1000
  20.  
  21. enum I_AutoMoveX
  22. {
  23. Float:am_posx,
  24. Float:am_posy,
  25. Float:am_posz,
  26. Float:am_postox,
  27. Float:am_postoy,
  28. Float:am_postoz,
  29. Float:am_speed,
  30. am_areaid,
  31. am_objectid,
  32. bool:am_used,
  33. bool:am_exist,
  34. am_count
  35. }
  36. new I_AutoMove[MAX_AUTO_OBJECTS][I_AutoMoveX];
  37.  
  38. stock CreateAutoObject(id, modelid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, Float:stream_distance, Float:move_distance, Float:tox, Float:toy, Float:toz, Float:move_speed)
  39. {
  40. I_AutoMove[id][am_posx] = x;
  41. I_AutoMove[id][am_posy] = y;
  42. I_AutoMove[id][am_posz] = z;
  43. I_AutoMove[id][am_postox] = tox;
  44. I_AutoMove[id][am_postoy] = toy;
  45. I_AutoMove[id][am_postoz] = toz;
  46. I_AutoMove[id][am_speed] = move_speed;
  47. I_AutoMove[id][am_objectid] = CreateDynamicObject(modelid, x, y, z, rx, ry, rz, 0, -1, -1, stream_distance);
  48. I_AutoMove[id][am_areaid] = CreateDynamicSphere(x, y, z, move_distance);
  49. I_AutoMove[id][am_count] = 0;
  50. I_AutoMove[id][am_exist] = true;
  51. return 1;
  52. }
  53.  
  54. stock DestroyAutoObject(id)
  55. {
  56. DestroyDynamicObject(I_AutoMove[id][am_objectid]);
  57. DestroyDynamicArea(I_AutoMove[id][am_areaid]);
  58. I_AutoMove[id][am_count] = 0;
  59. I_AutoMove[id][am_exist] = false;
  60. return 1;
  61. }
  62.  
  63. stock DestroyAllAutoObjects()
  64. {
  65. for(new lll_i = 0; lll_i < MAX_AUTO_OBJECTS; lll_i ++)
  66. {
  67. if(!I_AutoMove[lll_i][am_exist]) continue;
  68. DestroyAutoObject(lll_i);
  69. }
  70. return 1;
  71. }
  72.  
  73. hook OnPlayerEnterDynamicArea(playerid, areaid)
  74. {
  75. if(playerid != INVALID_PLAYER_ID && !IsPlayerNPC(playerid))
  76. {
  77. for(new j = 0; j < MAX_AUTO_OBJECTS;j++)
  78. if(areaid == I_AutoMove[j][am_areaid])
  79. {
  80. if(!I_AutoMove[j][am_used])
  81. {
  82. I_AutoMove[j][am_count] ++;
  83. if(I_AutoMove[j][am_count] < 2)
  84. {
  85. MoveDynamicObject(I_AutoMove[j][am_objectid], I_AutoMove[j][am_postox], I_AutoMove[j][am_postoy], I_AutoMove[j][am_postoz], I_AutoMove[j][am_speed]);
  86. I_AutoMove[j][am_used] = true;
  87. break;
  88. }
  89. }
  90. }
  91. }
  92. return 1;
  93. }
  94.  
  95. hook OnPlayerLeaveDynamicArea(playerid, areaid)
  96. {
  97. if(playerid != INVALID_PLAYER_ID && !IsPlayerNPC(playerid))
  98. {
  99. for(new j = 0; j < MAX_AUTO_OBJECTS;j++)
  100. if(areaid == I_AutoMove[j][am_areaid])
  101. {
  102. if(I_AutoMove[j][am_used])
  103. {
  104. I_AutoMove[j][am_count] --;
  105. if(I_AutoMove[j][am_count] < 1)
  106. {
  107. MoveDynamicObject(I_AutoMove[j][am_objectid], I_AutoMove[j][am_posx], I_AutoMove[j][am_posy], I_AutoMove[j][am_posz], I_AutoMove[j][am_speed]);
  108. I_AutoMove[j][am_used] = false;
  109. break;
  110. }
  111. }
  112. }
  113. }
  114. return 1;
  115. }
  116.  
  117. #if defined FILTERSCRIPT
  118.  
  119. hook OnFilterScriptExit()
  120. {
  121. DestroyAllAutoObjects();
  122. return 1;
  123. }
  124.  
  125. #else
  126.  
  127. hook OnGameModeExit()
  128. {
  129. DestroyAllAutoObjects();
  130. return 1;
  131. }
  132.  
  133. #endif
  134.  
  135. //EOF.
RAW Paste Data