1
0

tests.inc 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. /*
  2. Legal:
  3. Version: MPL 1.1
  4. The contents of this file are subject to the Mozilla Public License Version
  5. 1.1 the "License"; you may not use this file except in compliance with
  6. the License. You may obtain a copy of the License at
  7. http://www.mozilla.org/MPL/
  8. Software distributed under the License is distributed on an "AS IS" basis,
  9. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  10. for the specific language governing rights and limitations under the
  11. License.
  12. The Original Code is the YSI framework.
  13. The Initial Developer of the Original Code is Alex "Y_Less" Cole.
  14. Portions created by the Initial Developer are Copyright C 2011
  15. the Initial Developer. All Rights Reserved.
  16. Contributors:
  17. Y_Less
  18. koolk
  19. JoeBullet/Google63
  20. g_aSlice/Slice
  21. Misiur
  22. samphunter
  23. tianmeta
  24. maddinat0r
  25. spacemud
  26. Crayder
  27. Dayvison
  28. Ahmad45123
  29. Zeex
  30. irinel1996
  31. Yiin-
  32. Chaprnks
  33. Konstantinos
  34. Masterchen09
  35. Southclaws
  36. PatchwerkQWER
  37. m0k1
  38. paulommu
  39. udan111
  40. Thanks:
  41. JoeBullet/Google63 - Handy arbitrary ASM jump code using SCTRL.
  42. ZeeX - Very productive conversations.
  43. koolk - IsPlayerinAreaEx code.
  44. TheAlpha - Danish translation.
  45. breadfish - German translation.
  46. Fireburn - Dutch translation.
  47. yom - French translation.
  48. 50p - Polish translation.
  49. Zamaroht - Spanish translation.
  50. Los - Portuguese translation.
  51. Dracoblue, sintax, mabako, Xtreme, other coders - Producing other modes for
  52. me to strive to better.
  53. Pixels^ - Running XScripters where the idea was born.
  54. Matite - Pestering me to release it and using it.
  55. Very special thanks to:
  56. Thiadmer - PAWN, whose limits continue to amaze me!
  57. Kye/Kalcor - SA:MP.
  58. SA:MP Team past, present and future - SA:MP.
  59. Optional plugins:
  60. Gamer_Z - GPS.
  61. Incognito - Streamer.
  62. Me - sscanf2, fixes2, Whirlpool.
  63. */
  64. static
  65. gZone;
  66. // Test pulsing 1.
  67. PTestInit:GangZonePulse1(playerid)
  68. {
  69. // Create the zone.
  70. gZone = GangZoneCreate(-100.0, -100.0, 100.0, 100.0);
  71. GangZoneShowForPlayer(playerid, gZone, 0xFF0000AA);
  72. SetPlayerPos(playerid, 0.0, 0.0, 5.0);
  73. }
  74. PTest:GangZonePulse1(playerid)
  75. {
  76. GangZonePulseForPlayer(playerid, gZone, 0xFF0000AA, 0x00FF00AA, 2000);
  77. ASK("Is the zone pulsing from Red to Green?");
  78. }
  79. PTestClose:GangZonePulse1(playerid)
  80. {
  81. GangZoneStopPulse(playerid, gZone);
  82. GangZoneDestroy(gZone);
  83. }
  84. // Test pulsing 2.
  85. PTestInit:GangZonePulse2(playerid)
  86. {
  87. // Create the zone.
  88. gZone = GangZoneCreate(-100.0, -100.0, 100.0, 100.0);
  89. GangZoneShowForPlayer(playerid, gZone, 0xFF0000AA);
  90. SetPlayerPos(playerid, 0.0, 0.0, 5.0);
  91. }
  92. PTest:GangZonePulse2(playerid)
  93. {
  94. GangZonePulseForPlayer(playerid, gZone, 0xFF0000AA, 0x00FF00AA, 333);
  95. ASK("Is the zone pulsing from Red to Green fast?");
  96. }
  97. PTestClose:GangZonePulse2(playerid)
  98. {
  99. GangZoneStopPulse(playerid, gZone);
  100. GangZoneDestroy(gZone);
  101. }
  102. // Test pulsing 3.
  103. PTestInit:GangZonePulse3(playerid)
  104. {
  105. // Create the zone.
  106. gZone = GangZoneCreate(-100.0, -100.0, 100.0, 100.0);
  107. GangZoneShowForPlayer(playerid, gZone, 0xFF0000AA);
  108. SetPlayerPos(playerid, 0.0, 0.0, 5.0);
  109. }
  110. PTest:GangZonePulse3(playerid)
  111. {
  112. GangZonePulseForPlayer(playerid, gZone, 0xFF0000AA, 0x00FF00AA, 1000, 0, 0);
  113. ASK("Is the zone jumping back to Red?");
  114. }
  115. PTestClose:GangZonePulse3(playerid)
  116. {
  117. GangZoneStopPulse(playerid, gZone);
  118. GangZoneDestroy(gZone);
  119. }
  120. // Test pulsing 4.
  121. PTestInit:GangZonePulse4(playerid)
  122. {
  123. // Create the zone.
  124. gZone = GangZoneCreate(-100.0, -100.0, 100.0, 100.0);
  125. GangZoneShowForPlayer(playerid, gZone, 0xFF0000AA);
  126. SetPlayerPos(playerid, 0.0, 0.0, 5.0);
  127. }
  128. PTest:GangZonePulse4(playerid)
  129. {
  130. GangZonePulseForPlayer(playerid, gZone, 0xFF0000AA, 0x00FF00AA, 500, 3000, 500, 0);
  131. ASK("Is the zone stopping on Green?");
  132. }
  133. PTestClose:GangZonePulse4(playerid)
  134. {
  135. GangZoneStopPulse(playerid, gZone);
  136. GangZoneDestroy(gZone);
  137. }
  138. // Test pulsing 7.
  139. PTestInit:GangZonePulse7(playerid)
  140. {
  141. // Create the zone.
  142. gZone = GangZoneCreate(-100.0, -100.0, 100.0, 100.0);
  143. GangZoneShowForPlayer(playerid, gZone, 0xFF0000AA);
  144. SetPlayerPos(playerid, 0.0, 0.0, 5.0);
  145. }
  146. PTest:GangZonePulse7(playerid)
  147. {
  148. // Regression bug, doing this used to cause a pause at the start - first bug
  149. // found and fixed by these unit tests.
  150. GangZonePulseForPlayer(playerid, gZone, 0xFF0000AA, 0x00FF00AA, 500, 3000, 500, 0);
  151. ASK("Was there no pause at the start?");
  152. }
  153. PTestClose:GangZonePulse7(playerid)
  154. {
  155. GangZoneStopPulse(playerid, gZone);
  156. GangZoneDestroy(gZone);
  157. }
  158. // Test pulsing 5.
  159. PTestInit:GangZonePulse5(playerid)
  160. {
  161. // Create the zone.
  162. gZone = GangZoneCreate(-100.0, -100.0, 100.0, 100.0);
  163. GangZoneShowForPlayer(playerid, gZone, 0xFF0000AA);
  164. SetPlayerPos(playerid, 0.0, 0.0, 5.0);
  165. }
  166. PTest:GangZonePulse5(playerid)
  167. {
  168. GangZonePulseForPlayer(playerid, gZone, 0xFF0000AA, 0x00FF00AA, 500, 0, 500, 3000);
  169. ASK("Is the zone stopping on Red?");
  170. }
  171. PTestClose:GangZonePulse5(playerid)
  172. {
  173. GangZoneStopPulse(playerid, gZone);
  174. GangZoneDestroy(gZone);
  175. }
  176. // Test pulsing 6.
  177. PTestInit:GangZonePulse6(playerid)
  178. {
  179. // Create the zone.
  180. gZone = GangZoneCreate(-100.0, -100.0, 100.0, 100.0);
  181. GangZoneShowForPlayer(playerid, gZone, 0xFF0000AA);
  182. SetPlayerPos(playerid, 0.0, 0.0, 5.0);
  183. }
  184. PTest:GangZonePulse6(playerid)
  185. {
  186. GangZonePulseForPlayer(playerid, gZone, 0xFF0000AA, 0x00FF00AA, 2000, _, 500, _);
  187. ASK("Is Green -> Red faster?");
  188. }
  189. PTestClose:GangZonePulse6(playerid)
  190. {
  191. GangZoneStopPulse(playerid, gZone);
  192. GangZoneDestroy(gZone);
  193. }
  194. // Test stopping 1.
  195. PTestInit:GangZoneStopPulse1(playerid)
  196. {
  197. // Create the zone.
  198. gZone = GangZoneCreate(-100.0, -100.0, 100.0, 100.0);
  199. GangZoneShowForPlayer(playerid, gZone, 0xFF0000AA);
  200. SetPlayerPos(playerid, 0.0, 0.0, 5.0);
  201. }
  202. PTest:GangZoneStopPulse1(playerid)
  203. {
  204. GangZonePulseForPlayer(playerid, gZone, 0xFF0000AA, 0x00FF00AA, 2000);
  205. GangZoneStopPulse(playerid, gZone);
  206. ASK("Is the zone NOT pulsing?");
  207. }
  208. PTestClose:GangZoneStopPulse1(playerid)
  209. {
  210. GangZoneDestroy(gZone);
  211. }
  212. // Test stopping 2.
  213. PTestInit:GangZoneStopPulse2(playerid)
  214. {
  215. // Create the zone.
  216. gZone = GangZoneCreate(-100.0, -100.0, 100.0, 100.0);
  217. GangZoneShowForPlayer(playerid, gZone, 0xFF0000AA);
  218. SetPlayerPos(playerid, 0.0, 0.0, 5.0);
  219. }
  220. PTest:GangZoneStopPulse2(playerid)
  221. {
  222. GangZonePulseForPlayer(playerid, gZone, 0xFF0000AA, 0x00FF00AA, 1000);
  223. SetTimerEx("GangZoneStopPulse2", 4000, 0, "i", playerid);
  224. ASK("Does the pulsing stop after four seconds?");
  225. }
  226. forward GangZoneStopPulse2(playerid);
  227. public GangZoneStopPulse2(playerid)
  228. {
  229. GangZoneStopPulse(playerid, gZone);
  230. }
  231. PTestClose:GangZoneStopPulse2(playerid)
  232. {
  233. GangZoneDestroy(gZone);
  234. }