Advertisement
Lordz

ShootingImproved

Jan 19th, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.85 KB | None | 0 0
  1. // Shooting Training - Idea By Avi Raj
  2. // Mapping and Scripting By Avi Raj
  3. // Thanks for using it.
  4.  
  5. #include <a_samp>
  6. #include <zcmd>
  7.  
  8. new InGame[MAX_PLAYERS];
  9.  
  10. new PlayerObjectHP[MAX_PLAYERS][MAX_OBJECTS];
  11. new bool:PlayerObjectDamage[MAX_PLAYERS][MAX_OBJECTS];
  12.  
  13. new p_OBJECTS[MAX_PLAYERS][16];
  14.  
  15. new p_DestroyedCounts[MAX_PLAYERS],
  16. p_GameTicks[MAX_PLAYERS];
  17.  
  18. #define DIALOG_SKILLS 1
  19.  
  20. public OnPlayerConnect(playerid)
  21. {
  22. InGame[playerid] = 0;
  23. p_GameTicks[playerid] = 0;
  24. p_DestroyedCounts[playerid] = 0;
  25. return 1;
  26. }
  27.  
  28. public OnPlayerSpawn(playerid)
  29. {
  30. p_DestroyedCounts[playerid] = 0;
  31. p_GameTicks[playerid] = 0;
  32. InGame[playerid] = 0;
  33. CreatePlayerObject(playerid,12918, 39.37264, 1952.38953, 15.43090, 0.00000, 0.00000, 0.00000);
  34. CreatePlayerObject(playerid,983, 44.16277, 1936.70996, 17.32400, 0.00000, 0.00000, 90.00000);
  35. CreatePlayerObject(playerid,983, 36.22247, 1936.71204, 17.32400, 0.00000, 0.00000, 90.00000);
  36. CreatePlayerObject(playerid,983, 42.60558, 1936.70715, 17.32400, 0.00000, 0.00000, 90.00000);
  37. CreatePlayerObject(playerid,983, 36.21048, 1933.56628, 17.32400, 0.00000, 0.00000, 90.00000);
  38. CreatePlayerObject(playerid,983, 42.62512, 1933.58105, 17.32400, 0.00000, 0.00000, 90.00000);
  39. CreatePlayerObject(playerid,983, 44.19323, 1933.59900, 17.32400, 0.00000, 0.00000, 90.00000);
  40. CreatePlayerObject(playerid,983, 44.19320, 1933.59900, 18.52400, 0.00000, 0.00000, 90.00000);
  41. CreatePlayerObject(playerid,983, 36.21050, 1933.56628, 18.52400, 0.00000, 0.00000, 90.00000);
  42. CreatePlayerObject(playerid,983, 42.62510, 1933.58105, 18.52400, 0.00000, 0.00000, 90.00000);
  43. CreatePlayerObject(playerid,983, 36.19595, 1934.16809, 19.06000, 0.00000, 90.00000, 90.00000);
  44. CreatePlayerObject(playerid,983, 36.16003, 1935.38806, 19.06000, 0.00000, 90.00000, 90.00000);
  45. CreatePlayerObject(playerid,983, 36.18409, 1936.60950, 19.06000, 0.00000, 90.00000, 90.00000);
  46. CreatePlayerObject(playerid,983, 42.53846, 1934.18225, 19.06000, 0.00000, 90.00000, 90.00000);
  47. CreatePlayerObject(playerid,983, 44.17745, 1934.19397, 19.06000, 0.00000, 90.00000, 90.00000);
  48. CreatePlayerObject(playerid,983, 42.58401, 1935.42004, 19.06000, 0.00000, 90.00000, 90.00000);
  49. CreatePlayerObject(playerid,983, 44.17020, 1935.41870, 19.06000, 0.00000, 90.00000, 90.00000);
  50. CreatePlayerObject(playerid,983, 42.55861, 1936.62244, 19.06000, 0.00000, 90.00000, 90.00000);
  51. CreatePlayerObject(playerid,983, 44.14478, 1936.62158, 19.06000, 0.00000, 90.00000, 90.00000);
  52. CreatePlayerObject(playerid,983, 36.17381, 1952.75635, 17.32400, 0.00000, 0.00000, 90.00000);
  53. CreatePlayerObject(playerid,983, 42.55510, 1952.73096, 17.32400, 0.00000, 0.00000, 90.00000);
  54. CreatePlayerObject(playerid,983, 44.14042, 1952.72888, 17.32400, 0.00000, 0.00000, 90.00000);
  55. CreatePlayerObject(playerid,983, 32.98570, 1949.59143, 17.32400, 0.00000, 0.00000, 0.00000);
  56. CreatePlayerObject(playerid,983, 32.99252, 1943.18262, 17.32400, 0.00000, 0.00000, 0.00000);
  57. CreatePlayerObject(playerid,983, 33.00263, 1936.79358, 17.32400, 0.00000, 0.00000, 0.00000);
  58. CreatePlayerObject(playerid,983, 47.35019, 1936.75378, 17.32400, 0.00000, 0.00000, 0.00000);
  59. CreatePlayerObject(playerid,983, 47.38920, 1943.13135, 17.32400, 0.00000, 0.00000, 0.00000);
  60. CreatePlayerObject(playerid,983, 47.36412, 1949.49487, 17.32400, 0.00000, 0.00000, 0.00000);
  61. p_OBJECTS[playerid][0] = CreatePlayerObject(playerid,1786, 34.59750, 1948.22119, 17.73660, 0.00000, 0.00000, 0.00000);
  62. p_OBJECTS[playerid][1] = CreatePlayerObject(playerid,1786, 36.76123, 1949.06116, 17.73660, 0.00000, 0.00000, 0.00000);
  63. p_OBJECTS[playerid][2] = CreatePlayerObject(playerid,1786, 40.29044, 1950.06531, 17.73660, 0.00000, 0.00000, 0.00000);
  64. p_OBJECTS[playerid][3] = CreatePlayerObject(playerid,1786, 42.33493, 1949.07739, 17.73660, 0.00000, 0.00000, 0.00000);
  65. p_OBJECTS[playerid][4] = CreatePlayerObject(playerid,1786, 44.31467, 1950.03711, 17.73660, 0.00000, 0.00000, 0.00000);
  66. p_OBJECTS[playerid][5] = CreatePlayerObject(playerid,1786, 46.28563, 1948.97021, 17.73660, 0.00000, 0.00000, 0.00000);
  67. p_OBJECTS[playerid][6] = CreatePlayerObject(playerid,1786, 46.43850, 1947.93774, 16.93660, 0.00000, 0.00000, -40.00000);
  68. p_OBJECTS[playerid][7] = CreatePlayerObject(playerid,1786, 34.22170, 1946.69580, 16.93660, 0.00000, 0.00000, 47.00000);
  69. p_OBJECTS[playerid][8] = CreatePlayerObject(playerid,1786, 40.28210, 1950.14075, 16.73660, 0.00000, 0.00000, 0.00000);
  70. p_OBJECTS[playerid][9] = CreatePlayerObject(playerid,1786, 38.77774, 1949.08057, 16.86600, 0.00000, 0.00000, 0.00000);
  71. p_OBJECTS[playerid][10] = CreatePlayerObject(playerid,1786, 40.74410, 1951.16272, 18.73660, 0.00000, 0.00000, 0.00000);
  72. p_OBJECTS[playerid][11] = CreatePlayerObject(playerid,1786, 38.72364, 1950.07544, 18.73660, 0.00000, 0.00000, 0.00000);
  73. p_OBJECTS[playerid][12] = CreatePlayerObject(playerid,1786, 34.42710, 1951.10791, 18.73660, 0.00000, 0.00000, 0.00000);
  74. p_OBJECTS[playerid][13] = CreatePlayerObject(playerid,1786, 36.43932, 1950.42993, 18.73660, 0.00000, 0.00000, 0.00000);
  75. p_OBJECTS[playerid][14] = CreatePlayerObject(playerid,1786, 44.41322, 1951.03076, 18.73660, 0.00000, 0.00000, 0.00000);
  76. p_OBJECTS[playerid][15] = CreatePlayerObject(playerid,1786, 42.22642, 1949.95215, 18.73660, 0.00000, 0.00000, 0.00000);
  77. for(new i; i< 16; i++) {
  78. PlayerObjectDamage[playerid][p_OBJECTS[playerid][i]] = true;
  79. }
  80. for(new i; i< MAX_OBJECTS; i++) {
  81. if(!IsValidPlayerObject(playerid, i)) continue;
  82. PlayerObjectHP[playerid][i] = 30;
  83. }
  84. return 1;
  85. }
  86.  
  87. public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
  88. {
  89. if(hittype == BULLET_HIT_TYPE_PLAYER_OBJECT) {
  90. if(IsValidPlayerObject(playerid, hitid)) {
  91. if(PlayerObjectDamage[playerid][hitid] == true) {
  92.  
  93. PlayerObjectHP[playerid][hitid] -= random(10) + 1;
  94. if(PlayerObjectHP[playerid][hitid] <= 0) { //If the HP goes to 0 or goes lesser than 0;
  95. DestroyPlayerObject(playerid, hitid); //We're destroying the PLAYER's OBJECT then, not a global one.
  96. PlayerPlaySound(playerid, 1132, 0.0, 0.0, 0.0);
  97. p_DestroyedCounts[playerid]++;
  98. new str[60];
  99. format(str, sizeof(str), "~Y~OBJECT~R~ DESTROYED!~N~~G~REMAINING ONES ~W~:~R~ %d", 16-p_DestroyedCounts[playerid]);
  100. GameTextForPlayer(playerid, str, 1800, 3);
  101. }
  102. }
  103. }
  104. }
  105. return 1;
  106. }
  107.  
  108. public OnPlayerDisconnect(playerid, reason)
  109. {
  110. InGame[playerid] = 0;
  111. //We'll loop through every objects at first.
  112. for(new i; i< MAX_OBJECTS; i++) {
  113. //Then, we'll see if it's a player object or not.
  114. if(!IsValidPlayerObject(playerid, i)) continue; //If it's not a valid player object, it will skip that loop value.
  115. DestroyPlayerObject(playerid, i); //In case if there's any player objects, it will be destroying them.
  116. }
  117. return 1;
  118. }
  119.  
  120. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  121. {
  122. if(dialogid == 1)
  123. {
  124. if(response)
  125. {
  126. switch(listitem)
  127. {
  128. case 0:
  129. {
  130. GivePlayerWeapon(playerid, WEAPON_MP5, 1000);
  131. SendClientMessage(playerid, 0xFFFFAA00,"Easy Level Selected - Game Started! NOTE : There may be objects which are kept hidden.");
  132. InGame[playerid] = 1;
  133. p_GameTicks[playerid] = GetTickCount();
  134. }
  135. case 1:
  136. {
  137. SendClientMessage(playerid, 0xFFFFAA00,"Easy Level Selected - Game Started! NOTE : There may be objects which are kept hidden.");
  138. GivePlayerWeapon(playerid, WEAPON_DEAGLE, 1000);
  139. InGame[playerid] = 1;
  140. p_GameTicks[playerid] = GetTickCount();
  141. }
  142. case 2:
  143. {
  144. SendClientMessage(playerid, 0xFFFFAA00,"Easy Level Selected - Game Started! NOTE : There may be objects which are kept hidden.");
  145. GivePlayerWeapon(playerid, WEAPON_RIFLE, 1000);
  146. InGame[playerid] = 1;
  147. p_GameTicks[playerid] = GetTickCount();
  148. }
  149. }
  150. }
  151. return 1;
  152. }
  153. return 0;
  154. }
  155.  
  156. CMD:game(playerid, params[])
  157. {
  158. SendClientMessage(playerid, 0xFFFFAA00,"Welcome to Shooting Minigame - By Avi Raj");
  159. ResetPlayerWeapons(playerid);
  160. ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST,"Select Level","Easy\nMedium\nDifficult","SELECT","");
  161. SetPlayerPos(playerid, 40.1007,1935.5529,17.6406);
  162. SetPlayerFacingAngle(playerid,1.5626);
  163. return 1;
  164. }
  165.  
  166.  
  167. public OnPlayerUpdate(playerid)
  168. {
  169. if(p_DestroyedCounts[playerid] >= 16)
  170. {
  171. new str[128];
  172. format(str, sizeof(str), "You've successfully completed the shooting minigame in %d seconds!", (GetTickCount() - p_GameTicks[playerid]) / 1000);
  173. SendClientMessage(playerid, 0xFF0000, str);
  174. InGame[playerid] = 0;
  175. SpawnPlayer(playerid);
  176. }
  177. return 1;
  178. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement