Advertisement
Guest User

SpiderPork

a guest
Mar 22nd, 2009
2,187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.28 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define FILTERSCRIPT
  4.  
  5. #define YELLOW 0xFFFF00FF
  6. #define RED 0xFF0000FF
  7. #define WHITE 0xFFFFFFFF
  8. #define ORANGE 0xF97804FF
  9. #define BLUE 0x0000FFFF
  10.  
  11. #if defined FILTERSCRIPT
  12.  
  13. new Float:HockeySpawns[10][4] =
  14. {
  15. {1370.3741, 2130.7910, 11.0156},
  16. {1355.2581, 2129.7195, 11.0156},
  17. {1336.2168, 2129.4036, 11.0156},
  18. {1346.3798, 2144.0493, 11.0156},
  19. {1363.4307, 2144.9565, 11.0156},
  20. {1363.3607, 2150.4619, 11.0156},
  21. {1344.9474, 2151.8689, 11.0156},
  22. {1337.5403, 2170.5913, 11.0234},
  23. {1352.0214, 2170.1721, 11.0156},
  24. {1371.2192, 2171.7070, 11.0234}
  25. };
  26.  
  27. //------------------------------------------------------------------------------
  28. //--------------------------------Hockey Defines--------------------------------
  29. //------------------------------------------------------------------------------
  30.  
  31. new PlaysHockey[MAX_PLAYERS];
  32. new HasPuck[MAX_PLAYERS];
  33.  
  34. new Puck;
  35.  
  36. //------------------------------------------------------------------------------
  37. //------------------------------IsObjectInArea----------------------------------
  38. //------------------------------------------------------------------------------
  39.  
  40. stock IsObjectInArea(objectid, Float:max_x, Float:min_x, Float:max_y, Float:min_y)
  41. {
  42. new Float:X, Float:Y, Float:Z;
  43. GetObjectPos(objectid, X, Y, Z);
  44. if(X <= max_x && X >= min_x && Y <= max_y && Y >= min_y) return 1;
  45. return 0;
  46. }
  47.  
  48. //------------------------------------------------------------------------------
  49. //--------------------------GetDistanceBetweenPlayers---------------------------
  50. //------------------------------------------------------------------------------
  51.  
  52. stock GetDistanceBetweenPlayers(playerid, playerid2)
  53. {
  54. new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
  55. new Float:tmpdis;
  56. GetPlayerPos(playerid, x1, y1, z1);
  57. GetPlayerPos(playerid2, x2, y2, z2);
  58. tmpdis =
  59.  
  60. floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs
  61.  
  62. (floatsub(z2,z1)),2));
  63. return floatround(tmpdis);
  64. }
  65.  
  66. //------------------------------------------------------------------------------
  67. //----------------------------GetXYInFrontOfPlayer------------------------------
  68. //------------------------------------------------------------------------------
  69.  
  70. stock Float:GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
  71. {
  72. new Float:a;
  73. GetPlayerPos(playerid, x, y, a);
  74. if (IsPlayerInAnyVehicle(playerid))
  75. GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
  76. else
  77. GetPlayerFacingAngle(playerid, a);
  78. x += (distance * floatsin(-a, degrees));
  79. y += (distance * floatcos(-a, degrees));
  80. return a;
  81. }
  82.  
  83. //------------------------------------------------------------------------------
  84. //--------------------------------PlayerToPoint---------------------------------
  85. //------------------------------------------------------------------------------
  86.  
  87. forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
  88. public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
  89. {
  90. new Float:oldposx, Float:oldposy, Float:oldposz;
  91. new Float:tempposx, Float:tempposy, Float:tempposz;
  92. GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  93. tempposx = (oldposx -x);
  94. tempposy = (oldposy -y);
  95. tempposz = (oldposz -z);
  96. if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  97. {
  98. return 1;
  99. }
  100. return 0;
  101. }
  102.  
  103. //------------------------------------------------------------------------------
  104. //--------------------------------ObjectToPoint---------------------------------
  105. //------------------------------------------------------------------------------
  106.  
  107. forward ObjectToPoint(Float:radi, objectid, Float:x, Float:y, Float:z);
  108. public ObjectToPoint(Float:radi, objectid, Float:x, Float:y, Float:z)
  109. {
  110. new Float:oldposx, Float:oldposy, Float:oldposz;
  111. new Float:tempposx, Float:tempposy, Float:tempposz;
  112. GetObjectPos(objectid, oldposx, oldposy, oldposz);
  113. tempposx = (oldposx -x);
  114. tempposy = (oldposy -y);
  115. tempposz = (oldposz -z);
  116. if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  117. {
  118. return 1;
  119. }
  120. return 0;
  121. }
  122.  
  123. public OnFilterScriptInit()
  124. {
  125. print("\n--------------------------------------");
  126. print(" -$- Hockey Filterscript -$- ");
  127. print(" -| by |- ");
  128. print(" -$- SpiderPork -$- ");
  129. print(" LOADED ");
  130. print("--------------------------------------\n");
  131. Puck = CreateObject(1319, 1353.296509, 2149.911621, 9.537497, 0, 0, 0); // The puck
  132. SetTimer("IsInArea", 1000, 1);
  133. CreateObject(3453, 1401.088989, 2105.528076, 16.736935, 0.0000, 0.0000, 0.0000);
  134. CreateObject(3452, 1371.763550, 2099.182129, 16.751028, 0.0000, 0.0000, 0.0000);
  135. CreateObject(3452, 1342.358398, 2099.221680, 16.765057, 0.0000, 0.0000, 0.0000);
  136. CreateObject(3453, 1312.165405, 2104.721436, 16.790056, 0.0000, 0.0000, 270.0000);
  137. CreateObject(3452, 1305.804199, 2134.033691, 16.797857, 0.0000, 0.0000, 270.0000);
  138. CreateObject(3452, 1305.818848, 2163.626221, 16.797857, 0.0000, 0.0000, 270.0000);
  139. CreateObject(3453, 1311.314209, 2201.489258, 16.797861, 0.0000, 0.0000, 180.0000);
  140. CreateObject(3452, 1305.795776, 2190.516357, 16.834555, 0.0000, 0.0000, 270.0000);
  141. CreateObject(4604, 1314.277222, 2124.585205, -18.819553, 91.1003, 0.0000, 90.0000);
  142. CreateObject(4604, 1389.221436, 2107.730713, -18.784601, 91.1003, 0.0000, 180.0000);
  143. CreateObject(983, 1352.813477, 2113.017578, 10.699176, 0.0000, 0.0000, 270.0000);
  144. CreateObject(983, 1352.812622, 2113.029541, 11.974175, 0.0000, 0.0000, 270.0000);
  145. CreateObject(983, 1349.593140, 2113.612305, 9.424180, 91.1003, 0.0000, 180.0000);
  146. CreateObject(983, 1349.604858, 2114.856934, 9.399184, 91.1003, 0.0000, 180.0000);
  147. CreateObject(983, 1356.029663, 2113.634033, 9.424177, 91.1003, 0.0000, 180.0000);
  148. CreateObject(983, 1356.014282, 2114.889893, 9.399177, 91.1003, 0.0000, 180.0000);
  149. CreateObject(983, 1352.806763, 2113.684326, 12.624177, 0.0000, 269.7592, 270.0000);
  150. CreateObject(983, 1352.648926, 2189.771240, 10.706992, 0.0000, 0.0000, 270.0000);
  151. CreateObject(983, 1352.646362, 2189.770264, 11.956988, 0.0000, 0.0000, 270.0000);
  152. CreateObject(983, 1355.813599, 2189.051514, 9.382001, 89.3814, 0.0000, 0.0000);
  153. CreateObject(983, 1355.812744, 2187.832275, 9.381993, 90.2409, 0.0000, 0.0000);
  154. CreateObject(983, 1349.442017, 2189.087891, 9.357001, 90.2409, 0.0000, 0.0000);
  155. CreateObject(983, 1349.440186, 2187.826660, 9.356994, 89.3814, 0.0000, 0.0000);
  156. CreateObject(983, 1352.645996, 2189.153320, 12.531980, 0.0000, 270.6186, 270.0000);
  157. CreateObject(983, 1352.651245, 2187.899658, 12.506980, 0.0000, 270.6186, 270.0000);
  158. CreateObject(983, 1352.808350, 2114.929443, 12.624185, 0.0000, 269.7591, 270.0000);
  159. CreateObject(3917, 1376.498901, 2133.413818, 3.568188, 0.0000, 0.0000, 270.0000);
  160. CreateObject(3917, 1363.439453, 2133.407715, 3.568184, 0.0000, 0.0000, 270.0000);
  161. CreateObject(3917, 1350.394165, 2133.401611, 3.568187, 0.0000, 0.0000, 270.0000);
  162. CreateObject(3917, 1337.359619, 2133.409424, 3.568185, 0.0000, 0.0000, 270.0000);
  163. CreateObject(3917, 1324.290527, 2133.428223, 3.568192, 0.0000, 0.0000, 270.0000);
  164. CreateObject(3917, 1311.237915, 2133.441895, 3.568180, 0.0000, 0.0000, 270.0000);
  165. CreateObject(3917, 1298.169556, 2133.442383, 3.575999, 0.0000, 0.0000, 270.0000);
  166. CreateObject(3915, 1306.331055, 2139.025146, 10.214546, 0.0000, 0.0000, 180.0000);
  167. CreateObject(3915, 1305.669189, 2180.461182, 10.251822, 0.0000, 0.0000, 180.0000);
  168. CreateObject(3915, 1301.370728, 2142.775146, 10.246323, 0.0000, 0.0000, 180.0000);
  169. CreateObject(3915, 1356.260620, 2208.066650, 10.217566, 0.0000, 0.0000, 90.0000);
  170. CreateObject(3915, 1397.616821, 2208.144775, 10.234627, 0.0000, 0.0000, 90.0000);
  171. CreateObject(18553, 1360.226685, 2192.344727, 11.315384, 0.0000, 0.0000, 270.0000);
  172. CreateObject(18553, 1363.993042, 2192.386230, 11.817675, 0.0000, 0.0000, 269.1406);
  173. CreateObject(18553, 1367.853638, 2192.401123, 11.817675, 0.0000, 0.0000, 269.1406);
  174. CreateObject(18553, 1371.749512, 2192.417236, 11.315384, 0.0000, 0.0000, 269.1406);
  175. CreateObject(18553, 1375.637451, 2192.418701, 11.817675, 0.0000, 0.0000, 269.1406);
  176. CreateObject(18553, 1377.774292, 2192.407715, 11.315384, 0.0000, 0.0000, 269.1406);
  177. CreateObject(18553, 1390.935547, 2177.283936, 11.315384, 0.0000, 0.0000, 180.0000);
  178. CreateObject(18553, 1390.992310, 2173.429688, 11.799865, 0.0000, 0.0000, 180.0000);
  179. CreateObject(18553, 1391.050781, 2169.548096, 11.817675, 0.0000, 0.0000, 180.0000);
  180. CreateObject(18553, 1391.061035, 2165.691406, 11.315384, 0.0000, 0.0000, 178.2812);
  181. CreateObject(18553, 1391.010010, 2161.809570, 11.817675, 0.0000, 0.0000, 178.2812);
  182. CreateObject(18553, 1390.958252, 2159.749512, 11.315384, 0.0000, 0.0000, 178.2812);
  183. CreateObject(3915, 1406.385986, 2155.359863, 10.238678, 0.0000, 0.0000, 0.0000);
  184. CreateObject(3915, 1406.347778, 2125.243652, 10.215340, 0.0000, 0.0000, 0.0000);
  185. CreateObject(3917, 1353.004150, 2143.817383, 3.568182, 0.0000, 0.0000, 270.0000);
  186. CreateObject(3917, 1339.965210, 2143.811279, 3.568185, 0.0000, 0.0000, 270.0000);
  187. CreateObject(3917, 1326.960571, 2143.790771, 3.568186, 0.0000, 0.0000, 270.0000);
  188. CreateObject(3917, 1330.618530, 2154.208008, 3.568189, 0.0000, 0.0000, 270.0000);
  189. CreateObject(3917, 1352.989502, 2154.223633, 3.568186, 0.0000, 0.0000, 270.0000);
  190. CreateObject(3917, 1343.205688, 2154.219971, 3.568185, 0.0000, 0.0000, 270.0000);
  191. CreateObject(3915, 1405.131226, 2159.961914, 10.259634, 0.0000, 0.0000, 0.0000);
  192. CreateObject(3915, 1306.640747, 2158.529053, 10.251812, 0.0000, 0.0000, 180.0000);
  193. CreateObject(3915, 1355.376221, 2207.078613, 10.226799, 0.0000, 0.0000, 90.0000);
  194. CreateObject(3917, 1351.689209, 2164.618164, 3.568186, 0.0000, 0.0000, 270.0000);
  195. CreateObject(3917, 1374.472046, 2160.467285, 3.568184, 0.0000, 0.0000, 180.0000);
  196. CreateObject(3917, 1364.061523, 2160.480469, 3.568187, 0.0000, 0.0000, 180.0000);
  197. CreateObject(3917, 1380.708862, 2134.976074, 3.568181, 0.0000, 0.0000, 90.0001);
  198. CreateObject(3917, 1360.087280, 2137.629395, 3.568186, 0.0000, 0.0000, 90.0001);
  199. CreateObject(3917, 1360.101074, 2148.047119, 3.568183, 0.0000, 0.0000, 90.0001);
  200. CreateObject(3917, 1374.768066, 2173.506104, 3.568182, 0.0000, 0.0000, 180.0000);
  201. CreateObject(3917, 1351.980103, 2185.395508, 3.575994, 0.0000, 0.0000, 270.0000);
  202. CreateObject(3917, 1351.665894, 2189.833740, 3.575998, 0.0000, 0.0000, 270.0000);
  203. CreateObject(3917, 1338.864624, 2189.740234, 3.593189, 0.0000, 0.0000, 270.0000);
  204. CreateObject(3917, 1328.149536, 2194.850586, 3.576000, 0.0000, 0.0000, 270.0000);
  205. return 1;
  206. }
  207.  
  208. public OnFilterScriptExit()
  209. {
  210. print("\n--------------------------------------");
  211. print(" -$- Hockey Filterscript -$- ");
  212. print(" -| by |- ");
  213. print(" -$- SpiderPork -$- ");
  214. print(" UNLOADED ");
  215. print("--------------------------------------\n");
  216. return 1;
  217. }
  218.  
  219. #else
  220.  
  221. main()
  222. {
  223. print("\n--------------------------------------");
  224. print(" -$- Hockey Filterscript -$- ");
  225. print(" -| by |- ");
  226. print(" -$- SpiderPork -$- ");
  227. print(" LOADED ");
  228. print("--------------------------------------\n");
  229. }
  230.  
  231. #endif
  232.  
  233.  
  234. public OnPlayerConnect(playerid)
  235. {
  236. ApplyAnimation(playerid, "SKATE", "null", 0.0, 0, 0, 0, 0, 0); // Pre-loads the skate anim.
  237. return 1;
  238. }
  239.  
  240. public OnPlayerCommandText(playerid, cmdtext[])
  241. {
  242. if (strcmp("/rpuck", cmdtext, true, 10) == 0) // Respawns the puck.
  243. {
  244. DestroyObject(Puck);
  245. Puck = CreateObject(1319, 1353.296509, 2149.911621, 9.537497, 0, 0, 0);
  246. SendClientMessageToAll(RED, "~ The puck went out of the hockey zone and has been respawned!"); // They threw the puck outta the hockey zone and has been respawned!
  247. return 1;
  248. }
  249.  
  250. if (strcmp("/hhelp", cmdtext, true, 10) == 0) // Hockey help
  251. {
  252. SendClientMessage(playerid, RED, "----------------------------------------------");
  253. SendClientMessage(playerid, YELLOW, "SpiderPork's Hockey Filterscript");
  254. SendClientMessage(playerid, YELLOW, "|- Help -|");
  255. SendClientMessage(playerid, RED, "----------------------------------------------");
  256. SendClientMessage(playerid, WHITE, "This filterscript has been made by SpiderPork.");
  257. SendClientMessage(playerid, WHITE, "To hit the puck, go near it and press the fire button to shoot it.");
  258. SendClientMessage(playerid, WHITE, "To shoot it harder, hold the fire button while near the puck.");
  259. SendClientMessage(playerid, WHITE, "To lead the puck, press sprint while near it.");
  260. SendClientMessage(playerid, WHITE, "If the puck gets outta the zone, type /rpuck to respawn it.");
  261. SendClientMessage(playerid, RED, "----------------------------------------------");
  262. return 1;
  263. }
  264.  
  265. if (strcmp("/hskate", cmdtext, true, 10) == 0) // The skate anim if it stops.
  266. {
  267. if(PlaysHockey[playerid] == 1)
  268. {
  269. ApplyAnimation(playerid, "SKATE", "skate_sprint", 4.1, 1, 1, 1, 1, 1);
  270. }
  271. else if(PlaysHockey[playerid] == 0)
  272. {
  273. SendClientMessage(playerid, RED, "You have to be in a hockey match to use this skate animation. Type /hockey!");
  274. }
  275. return 1;
  276. }
  277.  
  278. if (strcmp("/hockey", cmdtext, true, 10) == 0) // To join the hockey.
  279. {
  280. new rand = random(sizeof(HockeySpawns));
  281. SetPlayerPos(playerid, HockeySpawns[rand][0], HockeySpawns[rand][1], HockeySpawns[rand][2]);
  282. ApplyAnimation(playerid, "SKATE", "skate_sprint", 4.1, 1, 1, 1, 1, 1);
  283. GivePlayerWeapon(playerid, 2, 1);
  284. SendClientMessage(playerid, YELLOW, "You have joined the hockey match!");
  285. PlaysHockey[playerid] = 1;
  286. return 1;
  287. }
  288.  
  289. if (strcmp("/leavehockey", cmdtext, true, 10) == 0) // To leave the hockey.
  290. {
  291. new name[MAX_PLAYER_NAME];
  292. new string[128];
  293.  
  294. if(PlaysHockey[playerid] == 0)
  295. {
  296. SendClientMessage(playerid, RED, "You're not even participating in a match, dummy!"); // The dude failed.
  297. GetPlayerName(playerid, name, sizeof(name));
  298. printf("%s failed", name);
  299. }
  300. else if(PlaysHockey[playerid] == 1)
  301. {
  302. SpawnPlayer(playerid);
  303. SendClientMessage(playerid, YELLOW, "You have left the hockey match!"); // The player has successfully left the hockey match.
  304. format(string, sizeof(string), "~ %s has left the hockey match.", name);
  305. PlaysHockey[playerid] = 0;
  306. ResetPlayerWeapons(playerid);
  307. }
  308. return 1;
  309. }
  310. return 0;
  311. }
  312.  
  313. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  314. {
  315.  
  316. ////////////////////////////////////////////////////////////////////////////////
  317.  
  318. if (newkeys == KEY_FIRE) // The fire button
  319. {
  320. new Float:X, Float:Y, Float:Z, Float:X2, Float:Y2;
  321. GetObjectPos(Puck, X, Y, Z);
  322. GetXYInFrontOfPlayer(playerid, X2, Y2, 10.0);
  323.  
  324. if(PlaysHockey[playerid] == 1 && PlayerToPoint(5.0, playerid, X, Y, Z)) // If the player is near the puck, hit.
  325. {
  326. MoveObject(Puck, X2, Y2, Z, 10);
  327. SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
  328. ApplyAnimation(playerid, "BASEBALL", "Bat_3", 10, 0, 1, 1, 0, 0); // This animation looks like you'd hit a puck.
  329. SetTimerEx("BackToSkating", 1000, 0, "i", playerid);
  330. }
  331.  
  332. if(ObjectToPoint(10.0, Puck, 1352.8638, 2187.5947, 11.0234)) // The puck is in blue goal!
  333. {
  334. PuckInBlueGoal(playerid);
  335. }
  336.  
  337. if(ObjectToPoint(10.0, Puck, 1352.5548, 2114.6733, 11.0156)) // The puck is in red goal!
  338. {
  339. PuckInRedGoal(playerid);
  340. }
  341. }
  342.  
  343. ////////////////////////////////////////////////////////////////////////////////
  344.  
  345. if (newkeys == KEY_SPRINT) // The sprint button
  346. {
  347. new Float:X, Float:Y, Float:Z, Float:X2, Float:Y2;
  348. GetObjectPos(Puck, X, Y, Z);
  349. GetXYInFrontOfPlayer(playerid, X2, Y2, 5.0);
  350.  
  351. if(PlaysHockey[playerid] == 1 && PlayerToPoint(5.0, playerid, X, Y, Z) && HasPuck[playerid] == 0) // If the player is near the puck, attach.
  352. {
  353. AttachObjectToPlayer(Puck, playerid, 0, 3.0, -1.45, 0, 0, 0);
  354. HasPuck[playerid] = 1;
  355. }
  356.  
  357. else if(PlaysHockey[playerid] == 1 && HasPuck[playerid] == 1)
  358. {
  359. GetXYInFrontOfPlayer(playerid, X2, Y2, 3.0);
  360. GetPlayerPos(playerid, X, Y, Z);
  361. DestroyObject(Puck);
  362. Puck = CreateObject(1319, X2, Y2, Z-1.45, 0, 0, 0);
  363. HasPuck[playerid] = 0;
  364. }
  365. }
  366. return 1;
  367. }
  368.  
  369. forward BackToSkating(playerid);
  370. public BackToSkating(playerid)
  371. {
  372. if(PlaysHockey[playerid] == 1)
  373. {
  374. ApplyAnimation(playerid, "SKATE", "skate_sprint", 4.1, 1, 1, 1, 1, 1); // Let's skate again!
  375. }
  376. }
  377.  
  378. forward PuckInRedGoal(playerid);
  379. public PuckInRedGoal(playerid)
  380. {
  381. GameTextForPlayer(playerid, "~g~GOAL!", 5000, 5);
  382. DestroyObject(Puck);
  383. Puck = CreateObject(1319, 1353.296509, 2149.911621, 9.537497, 0, 0, 0);
  384. }
  385.  
  386. forward PuckInBlueGoal(playerid);
  387. public PuckInBlueGoal(playerid)
  388. {
  389. GameTextForPlayer(playerid, "~g~GOAL!", 5000, 5);
  390. DestroyObject(Puck);
  391. Puck = CreateObject(1319, 1353.296509, 2149.911621, 9.537497, 0, 0, 0);
  392. }
  393.  
  394. forward IsInArea();
  395. public IsInArea()
  396. {
  397. if(IsObjectInArea(Puck, 1394.741455, 1315.215942, 2196.875244, 2108.698242))
  398. {
  399. return 1;
  400. }
  401. else
  402. {
  403. DestroyObject(Puck);
  404. Puck = CreateObject(1319, 1353.296509, 2149.911621, 9.537497, 0, 0, 0);
  405. SendClientMessageToAll(RED, "~ The puck went out of the hockey zone and has been respawned!"); // They threw the puck outta the hockey zone and has been respawned!
  406. }
  407. return 1;
  408. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement