Advertisement
DanGT

iLoops

Oct 13th, 2013
730
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.17 KB | None | 0 0
  1. /*
  2.  * --- iLoops ---
  3.  * Por DanDRT(Danilo Galvão)
  4.  * Agradecimentos: Willian e IpsBruno.
  5.  * [iPs]TeaM
  6.  * mixmusicas.com.br ipsbr.net
  7. */
  8.  
  9.  
  10.  
  11. #if defined _iloops_included
  12.     #endinput
  13. #endif
  14. #define _iloops_included
  15. #pragma library iloops
  16.  
  17. #include <iEach>
  18.  
  19. new Each:Players[MAX_PLAYERS];
  20. new Each:Spawned[MAX_PLAYERS];
  21. new Each:VehiclesCreated[MAX_VEHICLES];
  22. new Each:VehiclesSpawned[MAX_VEHICLES];
  23.  
  24. #define ILOOPS_V 1.1
  25.  
  26. /*
  27. * GetPlayersConnected()
  28. * - Serve para obter o exato de jogadores conectados.
  29. */
  30.  
  31. #define GetPlayersConnected() \
  32.                                                         EachCount(Players)
  33.  
  34. /*
  35. * IsPlayerConnected(playerid)
  36. * - Serve para verificar se o jogador está conectado.
  37. */
  38.  
  39. #define IsPlayerConnected(%0) \
  40.                                                         (IsActive(Players, %0) || IsPlayerNPC(%0))
  41.  
  42. /*
  43. * IsPlayerSpawned(playerid)
  44. * - Verifica se o jogador "playerid" está Spawned ou não.
  45. */
  46.  
  47. #define IsPlayerSpawned(%0) \
  48.                                                         IsActive(Spawned, %0)
  49.  
  50. /*
  51. *                       *
  52. * Funções para Veiculos *
  53. *                       *
  54. */
  55.  
  56. /*
  57. * IsValidVehicle(vehicleid)
  58. * - Verifica se o veiculo "vehicleid" foi criado.
  59. */
  60. #define IsValidVehicle(%0) \
  61.                                                         IsActive(VehiclesCreated, %0)
  62.  
  63. /*
  64. * IsVehicleSpawned(vehicleid)
  65. * - Verifica se o veiculo "vehicleid" está Spawned ou não.
  66. */
  67.  
  68. #define IsVehicleSpawned(%0) \
  69.                                                         IsActive(VehiclesSpawned, %0)
  70.  
  71. /*
  72. * GetNumberofCarsCreated()
  73. * - Obtem o Numero de carros criados.
  74. */
  75.  
  76. #define GetNumberofCarsCreated() \
  77.                                                         EachCount(VehiclesCreated)
  78.  
  79. /*
  80. * GetNumberofCarsSpawned()
  81. * - Obtem o Numero de carros Spawneds.
  82. */
  83.  
  84. #define GetNumberofCarsSpawned() \
  85.                                                         EachCount(VehiclesSpawned)
  86.  
  87. /*
  88. *                   *
  89. * Funções Hookeadas *
  90. *                   *
  91. */
  92.  
  93. stock Ips_AddStaticVehicle(modelid, Float: spawn_x, Float: spawn_y, Float: spawn_z, Float: z_angle, color1, color2)
  94. {
  95.     new vehicleid = AddStaticVehicle(modelid, spawn_x, spawn_y, spawn_z, z_angle, color1, color2);
  96.     EachAdd(VehiclesCreated, vehicleid);
  97.     return vehicleid;
  98. }
  99. #if defined _ALS_AddStaticVehicle
  100.     #undef AddStaticVehicle
  101. #else
  102.     #define _ALS_AddStaticVehicle
  103. #endif
  104. #define AddStaticVehicle Ips_AddStaticVehicle
  105.  
  106. stock Ips_CreateVehicle(modelid, Float: spawn_x, Float: spawn_y, Float: spawn_z, Float: z_angle, color1, color2, timespawn)
  107. {
  108.     new vehicleid = AddStaticVehicleEx(modelid, spawn_x, spawn_y, spawn_z, z_angle, color1, color2, timespawn);
  109.     EachAdd(VehiclesCreated, vehicleid);
  110.     return vehicleid;
  111. }
  112. #if defined _ALS_CreateVehicle
  113.     #undef CreateVehicle
  114. #else
  115.     #define _ALS_CreateVehicle
  116. #endif
  117. #define CreateVehicle Ips_CreateVehicle
  118.  
  119. stock Ips_AddStaticVehicleEx(modelid, Float: spawn_x, Float: spawn_y, Float: spawn_z, Float: z_angle, color1, color2, timespawn)
  120. {
  121.     new vehicleid = AddStaticVehicleEx(modelid, spawn_x, spawn_y, spawn_z, z_angle, color1, color2, timespawn);
  122.     EachAdd(VehiclesCreated, vehicleid);
  123.     return vehicleid;
  124. }
  125. #if defined _ALS_AddStaticVehicleEx
  126.     #undef AddStaticVehicleEx
  127. #else
  128.     #define _ALS_AddStaticVehicleEx
  129. #endif
  130. #define AddStaticVehicleEx Ips_AddStaticVehicleEx
  131.  
  132. stock Ips_DestroyVehicle(vehicleid)
  133. {
  134.     return EachRemove(VehiclesCreated, vehicleid), DestroyVehicle(vehicleid);
  135. }
  136. #if defined _ALS_DestroyVehicle
  137.     #undef DestroyVehicle
  138. #else
  139.     #define _ALS_DestroyVehicle
  140. #endif
  141. #define DestroyVehicle Ips_DestroyVehicle
  142.  
  143.                                 /*
  144.                                 *                 *
  145.                                 * OnPlayerConnect *
  146.                                 *                 *
  147.                                 */
  148. public OnPlayerConnect(playerid)
  149. {
  150.     if(!IsPlayerNPC(playerid))
  151.         EachAdd(Players, playerid);
  152.  
  153.     EachRemove(Spawned, playerid);
  154.  
  155.     #if defined Ips_OnPlayerConnect
  156.         return Ips_OnPlayerConnect(playerid);
  157.     #else
  158.         return true;
  159.     #endif
  160. }
  161.  
  162. #if defined _ALS_OnPlayerConnect
  163.     #undef OnPlayerConnect
  164. #else
  165.     #define _ALS_OnPlayerConnect
  166. #endif
  167. #define OnPlayerConnect Ips_OnPlayerConnect
  168. #if defined Ips_OnPlayerConnect
  169.     forward OnPlayerConnect(playerid);
  170. #endif
  171.  
  172.                                 /*
  173.                                 *                    *
  174.                                 * OnPlayerDisconnect *
  175.                                 *                    *
  176.                                 */
  177.  
  178. public OnPlayerDisconnect(playerid, reason)
  179. {
  180.     if(!IsPlayerNPC(playerid))
  181.         EachRemove(Players, playerid);
  182.  
  183.     #if defined Ips_OnPlayerDisconnect
  184.         return Ips_OnPlayerDisconnect(playerid, reason);
  185.     #else
  186.         return true;
  187.     #endif
  188. }
  189.  
  190. #if defined _ALS_OnPlayerDisconnect
  191.     #undef OnPlayerDisconnect
  192. #else
  193.     #define _ALS_OnPlayerDisconnect
  194. #endif
  195. #define OnPlayerDisconnect Ips_OnPlayerDisconnect
  196. #if defined Ips_OnPlayerDisconnect
  197.     forward OnPlayerDisconnect(playerid);
  198. #endif
  199.  
  200.                                 /*
  201.                                 *               *
  202.                                 * OnPlayerSpawn *
  203.                                 *               *
  204.                                 */
  205.  
  206. public OnPlayerSpawn(playerid)
  207. {
  208.     if(!IsPlayerNPC(playerid))
  209.         EachAdd(Spawned, playerid);
  210.  
  211.     #if defined Ips_OnPlayerSpawn
  212.         return Ips_OnPlayerSpawn(playerid);
  213.     #else
  214.         return true;
  215.     #endif
  216. }
  217.  
  218. #if defined _ALS_OnPlayerSpawn
  219.     #undef OnPlayerSpawn
  220. #else
  221.     #define _ALS_OnPlayerSpawn
  222. #endif
  223. #define OnPlayerSpawn Ips_OnPlayerSpawn
  224. #if defined Ips_OnPlayerSpawn
  225.     forward OnPlayerSpawn(playerid);
  226. #endif
  227.  
  228.                                 /*
  229.                                 *                *
  230.                                 * OnVehicleSpawn *
  231.                                 *                *
  232.                                 */
  233.  
  234. public OnVehicleSpawn(vehicleid)
  235. {
  236.     EachAdd(VehiclesSpawned, vehicleid);
  237.  
  238.     #if defined Ips_OnVehicleSpawn
  239.         return Ips_OnVehicleSpawn(vehicleid);
  240.     #else
  241.         return true;
  242.     #endif
  243. }
  244. #if defined _ALS_OnVehicleSpawn
  245.     #undef OnVehicleSpawn
  246. #else
  247.     #define _ALS_OnVehicleSpawn
  248. #endif
  249. #define OnVehicleSpawn Ips_OnVehicleSpawn
  250. #if defined Ips_OnVehicleSpawn
  251.     forward OnVehicleSpawn(vehicleid);
  252. #endif
  253.  
  254.                                 /*
  255.                                 *                *
  256.                                 * OnVehicleDeath *
  257.                                 *                *
  258.                                 */
  259.  
  260. public OnVehicleDeath(vehicleid, killerid)
  261. {
  262.     EachRemove(VehiclesSpawned, vehicleid);
  263.  
  264.     #if defined Ips_OnVehicleDeath
  265.         return Ips_OnVehicleDeath(vehicleid, killerid);
  266.     #else
  267.         return true;
  268.     #endif
  269. }
  270.  
  271. #if defined _ALS_OnVehicleDeath
  272.     #undef OnVehicleDeath
  273. #else
  274.     #define _ALS_OnVehicleDeath
  275. #endif
  276. #define OnVehicleDeath Ips_OnVehicleDeath
  277. #if defined Ips_OnVehicleDeath
  278.     forward OnVehicleDeath(vehicleid, killerid);
  279. #endif
  280.  
  281.                                 /*
  282.                                 *                *
  283.                                 * OnPlayerDeath *
  284.                                 *                *
  285.                                 */
  286.  
  287. public OnPlayerDeath(playerid, killerid, reason)
  288. {
  289.     if(!IsPlayerNPC(playerid))
  290.         EachRemove(Spawned, playerid);
  291.  
  292.     #if defined Ips_OnPlayerDeath
  293.         return Ips_OnPlayerDeath(playerid, killerid, reason);
  294.     #else
  295.         return true;
  296.     #endif
  297. }
  298.  
  299. #if defined _ALS_OnPlayerDeath
  300.     #undef OnPlayerDeath
  301. #else
  302.     #define _ALS_OnPlayerDeath
  303. #endif
  304. #define OnPlayerDeath Ips_OnPlayerDeath
  305. #if defined Ips_OnPlayerDeath
  306.     forward OnPlayerDeath(playerid, killerid, reason);
  307. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement