PCheriyan007

CRRPG Radio in CRRPG

Jun 11th, 2011
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.44 KB | None | 0 0
  1. //============================================================================//
  2. //=============================|CRRPG Radio In Game|==========================//
  3. //=================================|by [DR]Sc0pe|=============================//
  4. //============================================================================//
  5.  
  6. //============================================================================//
  7. //                                  Requirements                              //
  8. //============================================================================//
  9. //  In order to run this [FS] you are going to need the following:            //
  10. //                                                                            //
  11. //  =================================                                         //
  12. //  1.  Incognito's Audio Plugin v0.4                                         //
  13. //  =================================                                         //
  14. //  *   Download: http://www.mediafire.com/?oziymwywxjn                       //
  15. //  *   SA-MP Forums Post: http://forum.sa-mp.com/showthread.php?t=82162      //
  16. //                                                                            //
  17. //  =========================                                                 //
  18. //  2.  Y_Less' Sscanf Plugin                                                 //
  19. //  =========================                                                 //
  20. //  *   Download: http://dl.dropbox.com/u/21683085/sscanf.zip                 //
  21. //  *   SA-MP Forums Post: http://forum.sa-mp.com/showthread.php?t=120356     //
  22. //                                                                            //
  23. //  ===============                                                           //
  24. //  3.  Zeex's ZCMD                                                           //
  25. //  ===============                                                           //
  26. //  *   Download: http://zeex.pastebin.ca/1650602                             //
  27. //  *   SA-MP Forums Post: http://forum.sa-mp.com/showthread.php?t=91354      //
  28. //                                                                            //
  29. //============================================================================//
  30. //                              End of Requirements                           //
  31. //============================================================================//
  32.  
  33. //===[Includes]===//
  34. #include <a_samp>
  35. #include <audio>
  36. #include <zcmd>
  37. #include <sscanf2>
  38.  
  39. //===[Defines (Colors)]===//
  40. #define COLOR_GREEN 0x33AA33AA
  41. #define COLOR_WHITE 0xFFFFFFAA
  42. #define COLOR_LIGHTBLUE 0x33CCFFAA
  43. #define COLOR_YELLOW 0xFFFF00AA
  44. #define COLOR_ORANGE 0xFF9900AA
  45. #define COLOR_FLBLUE 0x6495EDAA
  46. #define COLOR_ERROR 0xFF0000AA
  47.  
  48. //===[Defines (Stream URL)]===//
  49. #define STREAM_URL  "URLToStream"
  50.  
  51.  
  52. //===[Radio Script Variables]===//
  53. new Radio[MAX_PLAYERS];
  54. new Listening[MAX_PLAYERS];
  55.  
  56. public OnGameModeInit()
  57. {
  58.     Audio_CreateTCPServer(7777);
  59.     return 1;
  60. }
  61. public OnGameModeExit()
  62. {
  63.     Audio_DestroyTCPServer();
  64.     return 1;
  65. }
  66. public Audio_OnClientConnect(playerid)
  67. {
  68.     new string[128];
  69.     format(string, sizeof(string), "Audio client ID %d connected", playerid);
  70.     SendClientMessageToAll(COLOR_YELLOW, string);
  71.     Audio_TransferPack(playerid);
  72.     return 1;
  73. }
  74. public Audio_OnClientDisconnect(playerid)
  75. {
  76.     new string[128];
  77.     format(string, sizeof(string), "Audio client ID %d disconnected", playerid);
  78.     SendClientMessageToAll(COLOR_YELLOW, string);
  79.     Audio_Stop(playerid,Radio[playerid]);
  80.     return 1;
  81. }
  82. public Audio_OnTrackChange(playerid, handleid, track[])
  83. {
  84.     new string[128];
  85.     format(string, sizeof(string), "Now Playing: {FF9900}%s on CRRPG Radio", track);
  86.     SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
  87. }
  88. //===[Radio Script]===//
  89. CMD:listen(playerid, params[])
  90. {
  91.     if(Audio_IsClientConnected(playerid))
  92.     {
  93.         Radio[playerid] = Audio_PlayStreamed(playerid, STREAM_URL, false, false, false);
  94.         SendClientMessage(playerid, COLOR_LIGHTBLUE, "You are now listening to CRRPG Radio. Use /stopradio to stop listening.");
  95.         return 1;
  96.     }
  97.     else
  98.     {
  99.         SendClientMessage(playerid, COLOR_LIGHTBLUE, "Audio Bot: {FFFFFF}You are not connected to the audio server");
  100.         SendClientMessage(playerid, COLOR_YELLOW, "You may need to install the audio client, please visit the forums.");
  101.         return 1;
  102.     }
  103. }
  104. CMD:stopradio(playerid, params[])
  105. {
  106.     if(Audio_IsClientConnected(playerid))
  107.     {
  108.         if(Listening[playerid] == 1)
  109.         {
  110.             Audio_Stop(playerid, Radio[playerid]);
  111.             SendClientMessage(playerid, COLOR_LIGHTBLUE, "Audio Bot: {FFFFFF}You have shut off the Radio");
  112.             return 1;
  113.         }
  114.         else return SendClientMessage(playerid, COLOR_LIGHTBLUE, "Audio Bot: {FFFFFF}You aren't listening to any radio stations");
  115.     }
  116.     else
  117.     {
  118.         SendClientMessage(playerid, COLOR_LIGHTBLUE, "Audio Bot: {FFFFFF}You are not connected to the audio server");
  119.         SendClientMessage(playerid, COLOR_WHITE, "You may need to install the audio client, please visit the forums.");
  120.         return 1;
  121.     }
  122. }
  123. CMD:volume(playerid, params[])
  124. {
  125.     new vol, string[128];
  126.     if(sscanf(params, "i", vol)) return SendClientMessage(playerid, COLOR_ORANGE, "USAGE: {33CCFF}/volume [1-100]");
  127.     if(vol < 0 || vol > 100) return SendClientMessage(playerid, COLOR_ORANGE, "USAGE: {33CCFF}/volume [1-100]");
  128.     Audio_SetVolume(playerid, Radio[playerid], vol);
  129.     format(string, sizeof(string), "Audio Bot: {FFFFFF}Volume has been changed to %d", vol);
  130.     SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
  131.     return 1;
  132. }
Advertisement
Add Comment
Please, Sign In to add comment