Guest User

Basketball System V.01x

a guest
Apr 25th, 2012
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.56 KB | None | 0 0
  1. /* SA-MP Filterscript
  2. *
  3. * (c) Copyright 2012, Kaliber V 1.0
  4. *
  5. */
  6. #include <a_samp>
  7. /******************************************************************************/
  8. #define COLOR_LIGHTRED 0xFF6347AA
  9. #define COLOR_LIGHTBLUE 0x33CCFFAA
  10. #define COLOR_WHITE 0xFFFFFFAA
  11. #define COLOR_LIGHTGREEN 0x7CFC00AA
  12. #define COLOR_YELLOW 0xFFFF00AA
  13. #define PRESSED(%0) \
  14. (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
  15. /******************************************************************************/
  16. #define Dialog0 3239
  17. /******************************************************************************/
  18. forward Korb(playerid);
  19. forward Korb1(playerid);
  20. forward Verloren(playerid);
  21. /******************************************************************************/
  22. enum pInfo{
  23. pBall,
  24. pBesitzt,
  25. pTimer,
  26. pWurf,
  27. pRichtung,
  28. };
  29. new PlayerInfo[MAX_PLAYERS][pInfo];
  30. /******************************************************************************/
  31. public OnFilterScriptInit()
  32. {
  33. print("\n\tCopyright (c) by Kaliber\n");
  34. return 1;
  35. }
  36. public OnFilterScriptExit()
  37. {
  38. for(new i = 0; i<MAX_PLAYERS; i++)
  39. {
  40. DestroyObject(PlayerInfo[i][pBall]);
  41. }
  42. return 1;
  43. }
  44. public OnPlayerCommandText(playerid, cmdtext[])
  45. {
  46. if(strcmp(cmdtext, "/ball", true) == 0)
  47. {
  48. if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_LIGHTRED,"Du darfst dafür in keinem Auto sitzen !");
  49. if(PlayerInfo[playerid][pBesitzt] == 1) return SendClientMessage(playerid, COLOR_LIGHTRED,"Du besitzt schon einen Ball !");
  50. if(Platz(playerid))
  51. {
  52. new Float: X, Float: Y, Float: Z, Float: A;
  53. GetPlayerPos(playerid, X, Y, Z);
  54. GetPlayerFacingAngle(playerid, A);
  55. PlayerInfo[playerid][pBall] = CreateObject(2114,X,Y,Z,0,0,A,200.0);
  56. AttachObjectToPlayer(PlayerInfo[playerid][pBall], playerid, 0.05, 0.25, 0.0, 0.0, 0.5, 0.5);
  57. PlayerInfo[playerid][pBesitzt] = 1;
  58. SendClientMessage(playerid, COLOR_LIGHTBLUE,"Du hast dir erfolgreich einen Basketball geholt !");
  59. return 1;
  60. }
  61. else
  62. {
  63. return SendClientMessage(playerid, COLOR_LIGHTRED,"Du bist nicht am Basketball Platz Tippe: {FFFFFF}/platz");
  64. }
  65. }
  66. if(strcmp(cmdtext, "/platz", true) == 0)
  67. {
  68. ShowPlayerDialog(playerid,Dialog0,DIALOG_STYLE_LIST,"{FF0000}Wähle einen Basketball Platz !","Los Santos Groove Street","Bestätigen","Abbrechen");
  69. return 1;
  70. }
  71. if(strcmp(cmdtext, "/ablegen", true) == 0)
  72. {
  73. DestroyObject(PlayerInfo[playerid][pBall]);
  74. PlayerInfo[playerid][pBesitzt] = 0;
  75. PlayerInfo[playerid][pWurf] = 0;
  76. KillTimer(PlayerInfo[playerid][pTimer]);
  77. SendClientMessage(playerid, COLOR_YELLOW,"Du hast den Ball erfolgreich weggeschmissen !");
  78. return 1;
  79. }
  80. return 0;
  81. }
  82. public OnPlayerDisconnect(playerid)
  83. {
  84. DestroyObject(PlayerInfo[playerid][pBall]);
  85. return 1;
  86. }
  87. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  88. {
  89. if(dialogid == Dialog0)
  90. {
  91. if(response == 1)
  92. {
  93. switch (listitem)
  94. {
  95. case 0:
  96. {
  97. SetPlayerPos(playerid, 2524.3328,-1667.5042,15.0407);
  98. SetPlayerFacingAngle(playerid, 268.9362);
  99. SetCameraBehindPlayer(playerid);
  100. SendClientMessage(playerid, COLOR_LIGHTBLUE,"Willkommen auf dem Basketball Platz in Los Santos !");
  101. }
  102. }
  103. }
  104. if(response == 0)
  105. {
  106. return 1;
  107. }
  108. }
  109. return 1;
  110. }
  111. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  112. {
  113. if (PRESSED(KEY_SECONDARY_ATTACK))
  114. {
  115. if(PlayerInfo[playerid][pBesitzt] == 1)
  116. {
  117. if(PlayerInfo[playerid][pWurf] == 1) return SendClientMessage(playerid, COLOR_LIGHTRED,"Du wirfst gerade schon !");
  118. new Float: X, Float: Y, Float: Z, Float: A;
  119. GetPlayerPos(playerid, X, Y, Z);
  120. GetPlayerFacingAngle(playerid, A);
  121. SendClientMessage(playerid, COLOR_LIGHTBLUE,"Ball erfolgreich geworfen !");
  122. DestroyObject(PlayerInfo[playerid][pBall]);
  123. if(A >= 210 && A < 300)
  124. {
  125. PlayerInfo[playerid][pRichtung] = 1;
  126. PlayerInfo[playerid][pBall] = CreateObject(2114, X+1, Y, Z, 0, 0, A, 200.0);
  127. MoveObject(PlayerInfo[playerid][pBall], X+10, Y, Z+5, 4.0, 0, 0, A);
  128. }
  129. else if(A >= 0 && A < 120)
  130. {
  131. PlayerInfo[playerid][pRichtung] = 2;
  132. PlayerInfo[playerid][pBall] = CreateObject(2114, X-1, Y, Z, 0, 0, A, 200.0);
  133. MoveObject(PlayerInfo[playerid][pBall], X-10, Y, Z+5, 4.0, 0, 0, A);
  134. }
  135. else if(A >= 300)
  136. {
  137. PlayerInfo[playerid][pRichtung] = 3;
  138. PlayerInfo[playerid][pBall] = CreateObject(2114, X, Y+1, Z, 0, 0, A, 200.0);
  139. MoveObject(PlayerInfo[playerid][pBall], X, Y+10, Z+5, 4.0, 0, 0, A);
  140. }
  141. else if(A >= 120 && A <= 209)
  142. {
  143. PlayerInfo[playerid][pRichtung] = 4;
  144. PlayerInfo[playerid][pBall] = CreateObject(2114, X, Y-1, Z, 0, 0, A, 200.0);
  145. MoveObject(PlayerInfo[playerid][pBall], X, Y-10, Z+5, 4.0, 0, 0, A);
  146. }
  147. PlayerInfo[playerid][pWurf] = 1;
  148. SetTimerEx("Korb1", 1000*2, 0, "i", playerid);
  149. }
  150. }
  151. return 1;
  152. }
  153. public Korb1(playerid)
  154. {
  155. PlayerInfo[playerid][pTimer] = SetTimerEx("Korb", 1, 1, "i",playerid);
  156. return 1;
  157. }
  158. public Korb(playerid)
  159. {
  160. if(PlayerInfo[playerid][pBesitzt] == 0) return 1;
  161. new Float: X, Float: Y, Float: Z, Float: X1, Float: Z1, Float: Y1;
  162. GetPlayerPos(playerid, X1, Y1, Z1);
  163. if(GetObjectPos(PlayerInfo[playerid][pBall], X, Y, Z))
  164. {
  165. if(ObjectToPoint(1.0, PlayerInfo[playerid][pBall], 2533.4287,-1667.4817,16.9912))
  166. {
  167. Gewonnen(playerid);
  168. PlayerInfo[playerid][pWurf] = 0;
  169. KillTimer(PlayerInfo[playerid][pTimer]);
  170. return 1;
  171. }
  172. if(Z <= Z1)
  173. {
  174. PlayerInfo[playerid][pWurf] = 0;
  175. KillTimer(PlayerInfo[playerid][pTimer]);
  176. SendClientMessage(playerid, COLOR_LIGHTRED,"Du hast den Korb nicht getroffen, versuche es erneut !");
  177. SetTimerEx("Verloren", 1000*5, 0, "i", playerid);
  178. return 1;
  179. }
  180. if(PlayerInfo[playerid][pRichtung] == 1)
  181. {
  182. MoveObject(PlayerInfo[playerid][pBall], X+5, Y, Z-2, 4.0, 0, 0, 0);
  183. }
  184. else if(PlayerInfo[playerid][pRichtung] == 2)
  185. {
  186. MoveObject(PlayerInfo[playerid][pBall], X-5, Y, Z-2, 4.0, 0, 0, 0);
  187. }
  188. else if(PlayerInfo[playerid][pRichtung] == 3)
  189. {
  190. MoveObject(PlayerInfo[playerid][pBall], X, Y+5, Z-2, 4.0, 0, 0, 0);
  191. }
  192. else if(PlayerInfo[playerid][pRichtung] == 4)
  193. {
  194. MoveObject(PlayerInfo[playerid][pBall], X, Y-5, Z-2, 4.0, 0, 0, 0);
  195. }
  196. }
  197. return 1;
  198. }
  199. public Verloren(playerid)
  200. {
  201. AttachObjectToPlayer(PlayerInfo[playerid][pBall], playerid, 0.05, 0.25, 0.0, 0.0, 0.5, 0.5);
  202. return 1;
  203. }
  204. /******************************************************************************/
  205. stock Gewonnen(playerid)
  206. {
  207. new name[MAX_PLAYER_NAME], string[256];
  208. GetPlayerName(playerid, name, sizeof(name));
  209. format(string, sizeof(string),"Spieler {FF0000}%s{FFFF00} hat den Basketball Korb getroffen !",name);
  210. SendClientMessageToAll(COLOR_YELLOW, string);
  211. AttachObjectToPlayer(PlayerInfo[playerid][pBall], playerid, 0.05, 0.25, 0.0, 0.0, 0.5, 0.5);
  212. return 1;
  213. }
  214. stock Platz(playerid)
  215. {
  216. if(PlayerToPoint(15.0, playerid, 2524.3328,-1667.5042,15.0407)) return 1;
  217. return 0;
  218. }
  219. stock split(const strsrc[], strdest[][], delimiter)
  220. {
  221. new i, li;
  222. new aNum;
  223. new len;
  224. while(i <= strlen(strsrc)){
  225. if(strsrc[i]==delimiter || i==strlen(strsrc)){
  226. len = strmid(strdest[aNum], strsrc, li, i, 128);
  227. strdest[aNum][len] = 0;
  228. li = i+1;
  229. aNum++;
  230. }
  231. i++;
  232. }
  233. return 1;
  234. }
  235. stock ObjectToPoint(Float:radi, objectid, Float:x, Float:y, Float:z)
  236. {
  237. new Float:oldposx, Float:oldposy, Float:oldposz;
  238. new Float:tempposx, Float:tempposy, Float:tempposz;
  239. GetObjectPos(objectid, oldposx, oldposy, oldposz);
  240. tempposx = (oldposx -x);
  241. tempposy = (oldposy -y);
  242. tempposz = (oldposz -z);
  243. if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  244. {
  245. return 1;
  246. }
  247. return 0;
  248. }
  249. stock PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
  250. {
  251. if(IsPlayerConnected(playerid))
  252. {
  253. new Float:oldposx, Float:oldposy, Float:oldposz;
  254. new Float:tempposx, Float:tempposy, Float:tempposz;
  255. GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  256. tempposx = (oldposx -x);
  257. tempposy = (oldposy -y);
  258. tempposz = (oldposz -z);
  259. if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  260. {
  261. return 1;
  262. }
  263. }
  264. return 0;
  265. }
  266. /******************************************************************************/
Advertisement
Add Comment
Please, Sign In to add comment