Advertisement
Guest User

Untitled

a guest
Mar 18th, 2011
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.92 KB | None | 0 0
  1. /*
  2. ____ _ __
  3. / _/___ _________ _____ (_) /___ __
  4. / // __ \/ ___/ __ `/ __ \/ / __/ / / /
  5. _/ // / / (__ ) /_/ / / / / / /_/ /_/ /
  6. /___/_/ /_/____/\__,_/_/ /_/_/\__/\__, /
  7. /____/
  8. ____ _ _ __ __
  9. / _/___ _ __(_)____(_) /_ / /__
  10. / // __ \ | / / / ___/ / __ \/ / _ \
  11. _/ // / / / |/ / (__ ) / /_/ / / __/
  12. /___/_/ /_/|___/_/____/_/_.___/_/\___/
  13.  
  14. ________ __ ____ _ __
  15. / ____/ /_ ___ _____/ /__/ __ \____ (_)___ / /______
  16. / / / __ \/ _ \/ ___/ //_/ /_/ / __ \/ / __ \/ __/ ___/
  17. / /___/ / / / __/ /__/ ,< / ____/ /_/ / / / / / /_(__ )
  18. \____/_/ /_/\___/\___/_/|_/_/ \____/_/_/ /_/\__/____/
  19.  
  20. - Description
  21.  
  22. It allows you to create invisible checkpoints for check when the player enter
  23. on invisible checkpoint with a vehicle or not.
  24.  
  25. - Author
  26.  
  27. Allan Jader (CyNiC)
  28. Babul: colaborated with the function: CreatePickupsInCircle
  29. http://forum.sa-mp.com/showpost.php?p=694885&postcount=5
  30.  
  31.  
  32. - Note
  33.  
  34. You can change how much you want the include, leaving the credit to creator.
  35.  
  36. */
  37. #include <a_samp>
  38.  
  39. #define MAX_AREAS 50
  40. #define REAPPLY_CPS_TIMER 5000
  41.  
  42. enum cpinfo
  43. {
  44. cpid,
  45. bool: created,
  46. area,
  47. bool: areaexist,
  48. type,
  49. Float:cpPosX,
  50. Float:cpPosY,
  51. Float:cpPosZ,
  52. }
  53.  
  54. new invisiblecps[MAX_AREAS * 10][cpinfo];
  55.  
  56. new bool: playerblock[MAX_PLAYERS];
  57.  
  58. static highestcp;
  59.  
  60. forward OnVehicleEnterICheckpoint(playerid, vehicleid, checkpointid);
  61. forward OnPlayerEnterICheckpoint(playerid, checkpointid);
  62. forward EnterCheckpoint(playerid, checkpointid, cptype);
  63.  
  64. stock CreateIPlayerCheckpoint(Float:X, Float:Y, Float:Z, Float:size) return CreatePickupsInCircle(1, X, Y, Z,-1,size);
  65. stock CreateIVehicleCheckpoint(Float:X, Float:Y, Float:Z, Float:size) return CreatePickupsInCircle(14, X, Y, Z,-1,size);
  66.  
  67. InvisibleCheckpoints(playerid, pickupid)
  68. {
  69. if(playerblock[playerid]) return 1;
  70. for(new i = 0; i < sizeof highestcp; ++i) if(pickupid == invisiblecps[i][cpid]) return SetTimerEx("EnterCheckpoint", true, false, "ddd", playerid, i, invisiblecps[i][type]);
  71. return 1;
  72. }
  73.  
  74. public EnterCheckpoint(playerid, checkpointid, cptype)
  75. {
  76. if(cptype == 14)
  77. {
  78. OnVehicleEnterICheckpoint(playerid, GetPlayerVehicleID(playerid), invisiblecps[checkpointid][area]);
  79. playerblock[playerid] = true;
  80. SetTimerEx("unblockplayer", REAPPLY_CPS_TIMER, false, "d", playerid);
  81. ReloadArea(invisiblecps[checkpointid][area]);
  82. return 1;
  83. }
  84. OnPlayerEnterICheckpoint(playerid, invisiblecps[checkpointid][area]);
  85. playerblock[playerid] = true;
  86. SetTimerEx("unblockplayer", REAPPLY_CPS_TIMER, false, "d", playerid);
  87. ReloadArea(invisiblecps[checkpointid][area]);
  88. return true;
  89. }
  90.  
  91. public OnPlayerEnterICheckpoint(playerid, checkpointid)
  92. {
  93. return 1;
  94. }
  95.  
  96. public OnVehicleEnterICheckpoint(playerid, vehicleid, checkpointid)
  97. {
  98. return 1;
  99. }
  100.  
  101. stock DestroyCheckpoint(checkpointid)
  102. {
  103. for(new i = 0; i < 360; ++i)
  104. {
  105. if(invisiblecps[i][area] == checkpointid)
  106. {
  107. invisiblecps[i][areaexist] = false;
  108. invisiblecps[i][created] = false;
  109. DestroyPickup(invisiblecps[i][cpid]);
  110. if(checkpointid == highestcp) highestcp--;
  111. }
  112. }
  113. return 1;
  114. }
  115.  
  116. forward unblockplayer(playerid);
  117. public unblockplayer(playerid)
  118. {
  119. playerblock[playerid] = false;
  120. return 1;
  121. }
  122.  
  123. ReloadArea(areaid)
  124. {
  125. for(new i = 0; i < sizeof invisiblecps; ++i)
  126. {
  127. if(invisiblecps[i][area] == areaid)
  128. {
  129. DestroyPickup(invisiblecps[i][cpid]);
  130. invisiblecps[i][cpid] = CreatePickup(1007, 14, invisiblecps[i][cpPosX], invisiblecps[i][cpPosY], invisiblecps[i][cpPosZ]);
  131. }
  132. }
  133. return 1;
  134. }
  135.  
  136. stock CreatePickupsInCircle(ptype,Float:CX,Float:CY,Float:CZ,vw, Float:radius) //By Sacky
  137. {
  138. new Float: percent = floatdiv(floatdiv(360,radius), 4.0), area2, a;
  139. radius = floatdiv(radius,3.0);
  140. for(a = 0; a < sizeof invisiblecps; ++a)
  141. {
  142. if(!invisiblecps[a][areaexist])
  143. {
  144. if(a == 0)
  145. {
  146. area2 = invisiblecps[0][area] + 1;
  147. goto jump1;
  148. }
  149. area2 = invisiblecps[(a-1)][area] + 1;
  150. break;
  151. }
  152. }
  153. jump1:
  154. new Float: i, p;
  155. for(i = 0.0; i<360.0; i+=percent)
  156. {
  157. new Float:X, Float:Y, Float:Z;
  158. X = CX+(radius*floatsin(i,degrees));
  159. Y = CY+(radius*floatcos(i,degrees));
  160. Z = CZ;
  161. for(p = 0; p < sizeof invisiblecps; ++p)
  162. {
  163. if(!invisiblecps[p][created])
  164. {
  165. invisiblecps[p][created] = true;
  166. invisiblecps[p][cpid] = CreatePickup(1007,ptype,X,Y,Z,vw);
  167. invisiblecps[p][cpPosX] = X;
  168. invisiblecps[p][cpPosY] = Y;
  169. invisiblecps[p][cpPosZ] = Z;
  170. invisiblecps[p][area] = area2;
  171. invisiblecps[p][type] = ptype;
  172. invisiblecps[p][areaexist] = true;
  173. highestcp++;
  174. break;
  175. }
  176. }
  177. }
  178. return area2;
  179. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement