Guest User

Untitled

a guest
Jul 16th, 2013
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.67 KB | None | 0 0
  1. // This is a comment
  2. // uncomment the line below if you want to write a filterscript
  3. #define FILTERSCRIPT
  4.  
  5. // Includes
  6. #include <a_samp>
  7. #include <zcmd>
  8. #include <sscanf2>
  9. #include <streamer>
  10. #include <foreach>
  11.  
  12.  
  13. // Defines
  14. #define COLOR_WHITE 0xFFFFFFFF
  15. #define COLOR_LIGHTBLUE 0x33CCFFFF
  16. #define COLOR_GREY 0xAFAFAFFF
  17.  
  18.  
  19. new Boombox[MAX_PLAYERS];
  20.  
  21. public OnFilterScriptInit()
  22. {
  23. print("\n--------------------------------------");
  24. print(" Boombox");
  25. print("--------------------------------------\n");
  26. return 1;
  27. }
  28.  
  29. public OnFilterScriptExit()
  30. {
  31. return 1;
  32. }
  33.  
  34. public OnPlayerConnect(playerid)
  35. {
  36. DeletePVar(playerid, "BoomboxObject"); DeletePVar(playerid, "BoomboxURL");
  37. DeletePVar(playerid, "bposX"); DeletePVar(playerid, "bposY"); DeletePVar(playerid, "bposZ"); DeletePVar(playerid, "bboxareaid");
  38. if(IsValidDynamicObject(GetPVarInt(playerid, "BoomboxObject"))) DestroyDynamicObject(GetPVarInt(playerid, "BoomboxObject"));
  39. return 1;
  40. }
  41.  
  42. public OnPlayerDisconnect(playerid)
  43. {
  44. if(GetPVarType(playerid, "BoomboxObject"))
  45. {
  46. DestroyDynamicObject(GetPVarInt(playerid, "BoomboxObject"));
  47. if(GetPVarType(playerid, "bboxareaid"))
  48. {
  49. foreach(Player,i)
  50. {
  51. if(IsPlayerInDynamicArea(i, GetPVarInt(playerid, "bboxareaid")))
  52. {
  53. StopAudioStreamForPlayer(i);
  54. SendClientMessage(i, COLOR_GREY, " The boombox creator has disconnected from the server.");
  55. }
  56. }
  57. }
  58. }
  59. return 1;
  60. }
  61.  
  62. public OnPlayerSpawn(playerid)
  63. {
  64. return 1;
  65. }
  66.  
  67. public OnPlayerDeath(playerid, killerid, reason)
  68. {
  69. return 1;
  70. }
  71.  
  72. public OnVehicleSpawn(vehicleid)
  73. {
  74. return 1;
  75. }
  76.  
  77. public OnVehicleDeath(vehicleid, killerid)
  78. {
  79. return 1;
  80. }
  81.  
  82. public OnPlayerText(playerid, text[])
  83. {
  84. return 1;
  85. }
  86.  
  87. public OnPlayerCommandText(playerid, cmdtext[])
  88. {
  89. if (strcmp("/mycommand", cmdtext, true, 10) == 0)
  90. {
  91. // Do something here
  92. return 1;
  93. }
  94. return 0;
  95. }
  96.  
  97. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  98. {
  99. return 1;
  100. }
  101.  
  102. public OnPlayerExitVehicle(playerid, vehicleid)
  103. {
  104. return 1;
  105. }
  106.  
  107. public OnPlayerStateChange(playerid, newstate, oldstate)
  108. {
  109. return 1;
  110. }
  111.  
  112. public OnPlayerEnterCheckpoint(playerid)
  113. {
  114. return 1;
  115. }
  116.  
  117. public OnPlayerLeaveCheckpoint(playerid)
  118. {
  119. return 1;
  120. }
  121.  
  122. public OnPlayerEnterRaceCheckpoint(playerid)
  123. {
  124. return 1;
  125. }
  126.  
  127. public OnPlayerLeaveRaceCheckpoint(playerid)
  128. {
  129. return 1;
  130. }
  131.  
  132. public OnRconCommand(cmd[])
  133. {
  134. return 1;
  135. }
  136.  
  137. public OnPlayerRequestSpawn(playerid)
  138. {
  139. return 1;
  140. }
  141.  
  142. public OnObjectMoved(objectid)
  143. {
  144. return 1;
  145. }
  146.  
  147. public OnPlayerObjectMoved(playerid, objectid)
  148. {
  149. return 1;
  150. }
  151.  
  152. public OnPlayerPickUpPickup(playerid, pickupid)
  153. {
  154. return 1;
  155. }
  156.  
  157. public OnVehicleMod(playerid, vehicleid, componentid)
  158. {
  159. return 1;
  160. }
  161.  
  162. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  163. {
  164. return 1;
  165. }
  166.  
  167. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  168. {
  169. return 1;
  170. }
  171.  
  172. public OnPlayerSelectedMenuRow(playerid, row)
  173. {
  174. return 1;
  175. }
  176.  
  177. public OnPlayerExitedMenu(playerid)
  178. {
  179. return 1;
  180. }
  181.  
  182. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  183. {
  184. return 1;
  185. }
  186.  
  187. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  188. {
  189. return 1;
  190. }
  191.  
  192. public OnRconLoginAttempt(ip[], password[], success)
  193. {
  194. return 1;
  195. }
  196.  
  197. public OnPlayerUpdate(playerid)
  198. {
  199. return 1;
  200. }
  201.  
  202. public OnPlayerStreamIn(playerid, forplayerid)
  203. {
  204. return 1;
  205. }
  206.  
  207. public OnPlayerStreamOut(playerid, forplayerid)
  208. {
  209. return 1;
  210. }
  211.  
  212. public OnVehicleStreamIn(vehicleid, forplayerid)
  213. {
  214. return 1;
  215. }
  216.  
  217. public OnVehicleStreamOut(vehicleid, forplayerid)
  218. {
  219. return 1;
  220. }
  221.  
  222. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  223. {
  224. return 1;
  225. }
  226.  
  227. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  228. {
  229. return 1;
  230. }
  231. CMD:boombox(playerid, params[])
  232. {
  233. new string[128];
  234. if(!GetPVarType(playerid, "BoomboxObject"))
  235. {
  236. if(sscanf(params, "s[256]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /boombox [music url]");
  237. foreach(Player, i)
  238. {
  239. if(GetPVarType(i, "BoomboxObject"))
  240. {
  241. if(IsPlayerInRangeOfPoint(playerid, 30.0, GetPVarFloat(i, "bposX"), GetPVarFloat(i, "bposY"), GetPVarFloat(i, "bposZ")))
  242. {
  243. SendClientMessage(playerid, COLOR_GREY, " There is another boombox nearby, place yours somewhere else.");
  244. return 1;
  245. }
  246. }
  247. }
  248.  
  249. new Float:x, Float:y, Float:z, Float:a;
  250. GetPlayerPos(playerid, x, y, z); GetPlayerFacingAngle(playerid, a);
  251. SetPVarInt(playerid, "BoomboxObject", CreateDynamicObject(2103, x, y, z, 0.0, 0.0, 0.0, .worldid = GetPlayerVirtualWorld(playerid), .interiorid = GetPlayerInterior(playerid)));
  252. SetPVarFloat(playerid, "bposX", x); SetPVarFloat(playerid, "bposY", y); SetPVarFloat(playerid, "bposZ", z);
  253. SetPVarInt(playerid, "bboxareaid", CreateDynamicSphere(x, y, z, 30.0, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid)));
  254. format(string, sizeof(string), " You have placed your boombox at your location.");
  255. SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
  256. foreach(Player, i)
  257. {
  258. if(IsPlayerInDynamicArea(i, GetPVarInt(playerid, "bboxareaid")))
  259. {
  260. PlayAudioStreamForPlayer(i, params, GetPVarFloat(playerid, "bposX"), GetPVarFloat(playerid, "bposY"), GetPVarFloat(playerid, "bposZ"), 30.0, 1);
  261. }
  262. }
  263. SetPVarString(playerid, "BoomboxURL", params);
  264. }
  265. else
  266. {
  267. DestroyDynamicObject(GetPVarInt(playerid, "BoomboxObject"));
  268. DeletePVar(playerid, "BoomboxObject"); DeletePVar(playerid, "BoomboxURL");
  269. DeletePVar(playerid, "bposX"); DeletePVar(playerid, "bposY"); DeletePVar(playerid, "bposZ");
  270. if(GetPVarType(playerid, "bboxareaid"))
  271. {
  272. foreach(Player,i)
  273. {
  274. if(IsPlayerInDynamicArea(i, GetPVarInt(playerid, "bboxareaid")))
  275. {
  276. StopAudioStreamForPlayer(i);
  277. SendClientMessage(i, COLOR_GREY, " The boombox creator has removed his boombox.");
  278. }
  279. }
  280. DeletePVar(playerid, "bboxareaid");
  281. }
  282. SendClientMessage(playerid, COLOR_LIGHTBLUE, " You have removed your boombox.");
  283. }
  284. return 1;
  285. }
  286.  
  287. // Boombox editing - Usage: /boomboxnext [url]
  288. CMD:boomboxnext(playerid, params[])
  289. {
  290. if(!Boombox[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You don't have a boombox placed.");
  291. if(sscanf(params, "s[256]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /boomboxnext [music url]");
  292. SendClientMessage(playerid, COLOR_GREY, " You have changed the music your boombox is playing.");
  293. foreach(Player, i)
  294. {
  295. if(IsPlayerInDynamicArea(i, GetPVarInt(playerid, "bboxareaid")))
  296. {
  297. PlayAudioStreamForPlayer(i, params, GetPVarFloat(playerid, "bposX"), GetPVarFloat(playerid, "bposY"), GetPVarFloat(playerid, "bposZ"), 30.0, 1);
  298. }
  299. }
  300. SetPVarString(playerid, "BoomboxURL", params);
  301. return 1;
  302. }
  303.  
  304. public OnPlayerEnterDynamicArea(playerid, areaid)
  305. {
  306. foreach(Player, i)
  307. {
  308. if(GetPVarType(i, "bboxareaid"))
  309. {
  310. new station[256];
  311. GetPVarString(i, "BoomboxURL", station, sizeof(station));
  312. if(areaid == GetPVarInt(i, "bboxareaid"))
  313. {
  314. PlayAudioStreamForPlayer(playerid, station, GetPVarFloat(i, "bposX"), GetPVarFloat(i, "bposY"), GetPVarFloat(i, "bposZ"), 30.0, 1);
  315. SendClientMessage(playerid, COLOR_GREY, " You are listening to music coming out of a nearby boombox.");
  316. return 1;
  317. }
  318. }
  319. }
  320. return 1;
  321. }
  322.  
  323. public OnPlayerLeaveDynamicArea(playerid, areaid)
  324. {
  325. foreach(Player, i)
  326. {
  327. if(GetPVarType(i, "bboxareaid"))
  328. {
  329. if(areaid == GetPVarInt(i, "bboxareaid"))
  330. {
  331. StopAudioStreamForPlayer(playerid);
  332. SendClientMessage(playerid, COLOR_GREY, " You have went far away from the boombox.");
  333. return 1;
  334. }
  335. }
  336. }
  337. return 1;
  338. }
Advertisement
Add Comment
Please, Sign In to add comment