Guest User

BestAimFS

a guest
Dec 17th, 2014
425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.90 KB | None | 0 0
  1. /*------------------------------------------------------------------------------
  2.  
  3. 'BestAim' Minigame
  4.  
  5. - You have 30 seconds to hit as many objects as possible. It counts how many objects you hit.
  6.  
  7. ------------------------------------------------------------------------------*/
  8.  
  9. #include <a_samp>
  10. #include <streamer>
  11. #include <zcmd>
  12. #include <dini>
  13.  
  14. #define FILTERSCRIPT
  15. #define COLOR_LIGHTBLUE 0x33CCFFAA
  16. #define COLOR_ORANGE 0xFF9900AA
  17. #define COLOR_GREEN 0x33AA33AA
  18.  
  19. forward StartAimMG(playerid);
  20. forward EndAimMG(playerid);
  21.  
  22. //------------------------------------------------------------------------------
  23.  
  24. public OnFilterScriptInit()
  25. {
  26. CreateDynamicObject(6959, -1022.1649, 2978.9646, 15.23726, 0, 0, 0);
  27. CreateDynamicObject(6959, -1022.1691, 2958.9819, 12.49946, 90, 0, 0);
  28. CreateDynamicObject(6959, -1022.1589, 2998.73, 12.49946, 90, 0, 0);
  29. CreateDynamicObject(6959, -1001.6608, 2978.5088, 12.49946, 90, 0, 270);
  30. CreateDynamicObject(6959, -1042.4482, 2978.9543, 12.49946, 90, 0, 270);
  31. CreateDynamicObject(971, -1019.2831, 2994.3704, 18.76093, 0, 0, 270);
  32. CreateDynamicObject(971, -1019.2791, 2985.5342, 18.76093, 0, 0, 270);
  33. CreateDynamicObject(971, -1019.2825, 2976.6917, 18.76093, 0, 0, 270);
  34. CreateDynamicObject(971, -1014.8792, 2972.2932, 18.76093, 0, 0, 0);
  35. CreateDynamicObject(971, -1006.023, 2972.2817, 18.76093, 0, 0, 0);
  36. CreateDynamicObject(2180, -1018.6847, 2982.6489, 15.20601, 0, 0, 0);
  37. CreateDynamicObject(2180, -1016.7241, 2982.6563, 15.20601, 0, 0, 0);
  38. CreateDynamicObject(2180, -1014.769, 2982.6636, 15.20601, 0, 0, 0);
  39. CreateDynamicObject(2180, -1012.8085, 2982.6641, 15.20601, 0, 0, 0);
  40. CreateDynamicObject(2180, -1010.8498, 2982.6641, 15.20601, 0, 0, 0);
  41. CreateDynamicObject(2180, -1008.8862, 2982.6641, 15.20601, 0, 0, 0);
  42. CreateDynamicObject(2180, -1006.9288, 2982.6641, 15.20601, 0, 0, 0);
  43. CreateDynamicObject(2180, -1004.9717, 2982.6641, 15.20601, 0, 0, 0);
  44. CreateDynamicObject(2180, -1003.0129, 2982.6641, 15.20601, 0, 0, 0);
  45. CreateDynamicObject(3657, -1037.9402, 2975.3809, 15.72422, 0, 0, 0);
  46. CreateDynamicObject(3657, -1034.2484, 2975.3809, 15.72422, 0, 0, 0);
  47. CreateDynamicObject(3657, -1030.5594, 2975.3796, 15.72422, 0, 0, 0);
  48. CreateDynamicObject(3657, -1026.8669, 2975.3787, 15.72422, 0, 0, 0);
  49. CreateDynamicObject(3657, -1037.932, 2976.2275, 15.72422, 0, 0, 180);
  50. CreateDynamicObject(3657, -1034.2452, 2976.2268, 15.72422, 0, 0, 179.995);
  51. CreateDynamicObject(3657, -1030.5593, 2976.2258, 15.72422, 0, 0, 179.995);
  52. CreateDynamicObject(3657, -1026.8698, 2976.2249, 15.72422, 0, 0, 179.995);
  53. CreateDynamicObject(1360, -1024.9982, 2962.6099, 15.97803, 0, 0, 0);
  54. CreateDynamicObject(1360, -1025.0029, 2965.3311, 15.97803, 0, 0, 0);
  55. CreateDynamicObject(1364, -1029.8301, 2960.2063, 15.99013, 0, 0, 180);
  56. CreateDynamicObject(1360, -1034.9595, 2962.752, 15.97803, 0, 0, 0);
  57. CreateDynamicObject(1360, -1034.9412, 2965.4548, 15.97803, 0, 0, 0);
  58. CreateDynamicObject(1361, -1030.0675, 2967.5332, 15.94935, 0, 0, 0);
  59. CreateDynamicObject(2599, -1040.2933, 2975.7778, 15.66972, 0, 0, 0);
  60. CreateDynamicObject(2745, -1024.5011, 2980.425, 16.41463, 0, 0, 0);
  61. CreateDynamicObject(2745, -1040.5854, 2980.1987, 16.41463, 0, 0, 0);
  62. CreateDynamicObject(4731, -1031.0397, 2998.6316, 19.33885, 0, 0, 30.25);
  63. CreateDynamicObject(4238, -1042.3098, 2979.0171, 24.38178, 0, 0, 120.25);
  64. CreateDynamicObject(4731, -1030.9341, 2959.0835, 19.33885, 0, 0, 210.245);
  65. CreateDynamicObject(16151, -1002.7093, 2965.6318, 15.20601, 0, 0, 0.5);
  66. CreateDynamicObject(1726, -1010.1022, 2963.3545, 15.20601, 0, 0, 0);
  67. CreateDynamicObject(1727, -1011.5054, 2961.0471, 15.20601, 0, 0, 90);
  68. CreateDynamicObject(2311, -1009.7652, 2961.4856, 15.20601, 0, 0, 0);
  69. CreateDynamicObject(1726, -1007.9939, 2959.699, 15.20601, 0, 0, 180);
  70. CreateDynamicObject(1726, -1006.4829, 2962.4402, 15.20601, 0, 0, 270);
  71. CreateDynamicObject(2311, -1012.3929, 2968.1448, 15.20601, 0, 0, 0);
  72. CreateDynamicObject(1726, -1012.6633, 2969.7253, 15.20601, 0, 0, 0);
  73. CreateDynamicObject(1726, -1010.6631, 2966.5469, 15.20601, 0, 0, 179.995);
  74. CreateDynamicObject(1726, -1009.3495, 2969.1506, 15.20601, 0, 0, 270);
  75. CreateDynamicObject(1726, -1013.7789, 2967.0437, 15.20601, 0, 0, 90);
  76. return 1;
  77. }
  78.  
  79. new ObjectHitCount[MAX_PLAYERS],
  80. BestAimRun,
  81. BestAimObject,
  82. InBestAim[MAX_PLAYERS],
  83. PlayerText:TObjectHit[MAX_PLAYERS];
  84.  
  85. //------------------------------------------------------------------------------
  86.  
  87. CMD:bestaim(playerid,params[])
  88. {
  89. SetPlayerPos(playerid,-1034.8854,2971.0862,16.2060);
  90. SetPlayerFacingAngle(playerid,270);
  91. SendClientMessage(playerid,COLOR_ORANGE,")_Welcome to the 'BestAim' area. TIP: With c-bug you will be faster_(");
  92. SendClientMessage(playerid,COLOR_ORANGE,"-> Use /startaim if you want to start the minigame.");
  93. return 1;
  94. }
  95.  
  96. CMD:startaim(playerid,params[])
  97. {
  98. if(BestAimRun == 1)return SendClientMessage(playerid,COLOR_GREEN,"SERVER: BestAim Minigame is already running, wait until it ends.");
  99. SetTimerEx("StartAimMG", 3000, false, "i", playerid);
  100. SetPlayerPos(playerid,-1010.1898,2979.0808,16.2060);
  101. ResetPlayerWeapons(playerid);
  102. GivePlayerWeapon(playerid,24,500);
  103. SetPlayerFacingAngle(playerid,0);
  104. TogglePlayerControllable(playerid,0);
  105. ObjectHitCount[playerid] = 0;
  106. GameTextForPlayer(playerid,"~g~Ready, Steady",2000,4);
  107. BestAimRun = 1;
  108. InBestAim[playerid] = 1;
  109. BestAimObject = CreateDynamicObject(3497, -1016.5088, 2999.0059, 15.68677, 0, 0, 0);
  110. TObjectHit[playerid] = CreatePlayerTextDraw(playerid,500,150,"HIT COUNT");
  111. PlayerTextDrawShow(playerid,TObjectHit[playerid]);
  112. return 1;
  113. }
  114.  
  115. //------------------------------------------------------------------------------
  116.  
  117. new Float:RandomObjectPosition[][] =
  118. {
  119. { -1012.5088, 2999.0059, 15.67517},
  120. {-1008.5088, 2999.0059, 15.67517},
  121. {-1004.5088, 2999.0059, 15.68097},
  122. {-1016.5088, 2999.0059, 17.18677},
  123. {-1016.5088, 2999.0059, 18.68677},
  124. {-1012.5088, 2999.0059, 18.67517},
  125. {-1012.5088, 2999.0059, 17.17517},
  126. {-1008.5088, 2999.0059, 18.67517},
  127. {-1008.5088, 2999.0059, 17.17517},
  128. {-1004.5088, 2999.0059, 18.68097},
  129. {-1004.5088, 2999.0059, 17.18097}
  130. };
  131.  
  132. public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
  133. {
  134. new RandPos = random(sizeof(RandomObjectPosition));
  135. if(InBestAim[playerid] == 1)
  136. {
  137. if(hittype == 4)
  138. {
  139. if(hitid == BestAimObject)
  140. {
  141. ++ObjectHitCount[playerid];
  142. new string[128];
  143. format(string,sizeof(string),"Hit Objects: %i",ObjectHitCount[playerid]);
  144. PlayerTextDrawSetString(playerid,TObjectHit[playerid],string);
  145. DestroyDynamicObject(BestAimObject);
  146. BestAimObject = CreateDynamicObject(3497,RandomObjectPosition[RandPos][0],RandomObjectPosition[RandPos][1],RandomObjectPosition[RandPos][2],0,0,0);
  147.  
  148. }
  149. }
  150. }
  151. return 1;
  152. }
  153.  
  154. //------------------------------------------------------------------------------
  155.  
  156. public StartAimMG(playerid)
  157. {
  158. TogglePlayerControllable(playerid,1);
  159. SetTimerEx("EndAimMG", 30000, false, "i", playerid);
  160. GameTextForPlayer(playerid,"~b~GO GO GO",2000,4);
  161. PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
  162. return 1;
  163. }
  164.  
  165. public EndAimMG(playerid)
  166. {
  167. if(ObjectHitCount[playerid] > dini_Int("/BestAim/BestAim.txt","RecordAmount"))
  168. {
  169. new string[128];
  170. SetPlayerPos(playerid,-1025.7495,2992.4087,16.4060);
  171. dini_Set("/BestAim/BestAim.txt","RecordHolder",PlayerName(playerid));
  172. dini_IntSet("/BestAim/BestAim.txt","RecordAmount",ObjectHitCount[playerid]);
  173. format(string,sizeof(string),")_{FF9900}%s {33CCFF}has set a new record at the 'BestAim' Minigame with {FF9900}>> %i << {33CCFF}hits_(",PlayerName(playerid),ObjectHitCount[playerid]);
  174. SendClientMessageToAll(COLOR_LIGHTBLUE,string);
  175. BestAimRun = 0;
  176. InBestAim[playerid] = 0;
  177. DestroyDynamicObject(BestAimObject);
  178. PlayerTextDrawDestroy(playerid,TObjectHit[playerid]);
  179. }
  180. else
  181. {
  182. new string[128],string2[128];
  183. SetPlayerPos(playerid,-1025.7495,2992.4087,16.4060);
  184. format(string,sizeof(string),")_{FF9900}%s{33CCFF} finished the 'BestAim' Minigame with{FF9900} >> %i << {33CCFF}hit objects_(",PlayerName(playerid),ObjectHitCount[playerid]);
  185. SendClientMessageToAll(COLOR_LIGHTBLUE,string);
  186. format(string2,sizeof(string2),")_Recordholder is {FF9900}%s{33CCFF} with {FF9900}%i {33CCFF}hits_(",dini_Get("/BestAim/BestAim.txt","RecordHolder"),dini_Int("/BestAim/BestAim.txt","RecordAmount"));
  187. SendClientMessageToAll(COLOR_LIGHTBLUE,string2);
  188. BestAimRun = 0;
  189. InBestAim[playerid] = 0;
  190. DestroyDynamicObject(BestAimObject);
  191. PlayerTextDrawDestroy(playerid,TObjectHit[playerid]);
  192. }
  193. return 1;
  194. }
  195.  
  196. //------------------------------------------------------------------------------
  197.  
  198. public OnPlayerDisconnect(playerid,reason)
  199. {
  200. ObjectHitCount[playerid] = 0;
  201. InBestAim[playerid] = 0;
  202. return 1;
  203. }
  204.  
  205. //------------------------------------------------------------------------------
  206.  
  207. stock PlayerName(playerid)
  208. {
  209. new name[MAX_PLAYER_NAME];
  210. GetPlayerName(playerid,name,sizeof(name));
  211. return name;
  212. }
Advertisement
Add Comment
Please, Sign In to add comment