Guest User

Stream Radio Script v1.03 by Piet

a guest
Jul 27th, 2012
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.97 KB | None | 0 0
  1. /*
  2.  *  Stream Radio Script v1.03
  3.  *  Mit Kopfhörer Weiß(ein/ausschaltbar)
  4.  *  von Piet_Meier
  5.  */
  6.  
  7. //Includes
  8. #include <a_samp>
  9. #include <dini>
  10.  
  11. //Defines
  12. #define ECMD2(%0,%1) if(!strcmp(%0,cmdtext,true)||!strcmp(%1,cmdtext,true))
  13. #define DIALOG_MUSIC 32666
  14. #define HEAD_PHONES_SLOT 8
  15. #define SpielerName(%0) Name[%0]
  16.  
  17. #define HEAD_DATA "/Headphones.ini"
  18.  
  19. //Enumerator
  20. enum MusicTitleEnum
  21. {
  22.     TitleLink[256],
  23.     TitleName[64]
  24. };
  25.  
  26. //Variablen
  27. new Name[MAX_PLAYERS][MAX_PLAYER_NAME],
  28.  
  29. /*
  30.   Zum erstellen
  31.   {"Link vom Lied oder Stream", "Name vom Lied oder Stream"},
  32.   und dass dann in MusicTitle
  33.  */
  34.  
  35.     MusicTitle[][MusicTitleEnum] =
  36.     {
  37.         {"http://listen.technobase.fm/dsl.pls", "TechnoBase.fm"},
  38.         {"http://listen.housetime.fm/dsl.pls", "HouseTime.fm"}
  39.     };
  40.  
  41. public OnFilterScriptInit()
  42. {
  43.     if(!dini_Exists(HEAD_DATA))dini_Create(HEAD_DATA);
  44.    
  45.     for(new i=0; i<MAX_PLAYERS; i++)if(IsPlayerConnected(i))GetPlayerName(i, SpielerName(i), MAX_PLAYER_NAME);
  46.     return 1;
  47. }
  48.  
  49. public OnPlayerConnect(playerid)
  50. {
  51.     GetPlayerName(playerid, SpielerName(playerid), MAX_PLAYER_NAME);
  52.     return 1;
  53. }
  54.  
  55. public OnPlayerSpawn(playerid)
  56. {
  57.     StopAudioStreamForPlayer(playerid);
  58.     DistableHeadPhones(playerid, dini_Int(HEAD_DATA, SpielerName(playerid)));
  59.     return 1;
  60. }
  61.  
  62. public OnPlayerDeath(playerid, killerid, reason)
  63. {
  64.     StopAudioStreamForPlayer(playerid);
  65.     DistableHeadPhones(playerid, 0);
  66.     return 1;
  67. }
  68.  
  69. public OnPlayerCommandText(playerid, cmdtext[])
  70. {
  71.     ECMD2("/music", "/radio")
  72.     {
  73.         new str[512], nr=0;
  74.         for(new i=0; i<sizeof(MusicTitle); i++)
  75.         {
  76.             if(!nr)format(str, 512, "%s", MusicTitle[i][TitleName]);
  77.             else format(str, 512, "%s\n%s", str, MusicTitle[i][TitleName]);
  78.             nr=1;
  79.         }
  80.         ShowPlayerDialog(playerid, DIALOG_MUSIC, DIALOG_STYLE_LIST, "Music Stream's", str, "Anhören", "Schliessen");
  81.         return 1;
  82.     }
  83.    
  84.     ECMD2("/mstop", "/rstop")
  85.     {
  86.         StopAudioStreamForPlayer(playerid);
  87.         DistableHeadPhones(playerid, dini_Int(HEAD_DATA, SpielerName(playerid)));
  88.         GameTextForPlayer(playerid, "~w~Stream gestoppt.", 1500, 1);
  89.         return 1;
  90.     }
  91.    
  92.     ECMD2("/headphones", "/kopfhörer")
  93.     {
  94.         if(dini_Int(HEAD_DATA, SpielerName(playerid)) == 0)
  95.         {
  96.             dini_IntSet(HEAD_DATA, SpielerName(playerid), 1);
  97.             GameTextForPlayer(playerid, "~w~Kopfhoerer~n~aktiviert.", 1500, 1);
  98.         }
  99.         else
  100.         {
  101.             dini_IntSet(HEAD_DATA, SpielerName(playerid), 0);
  102.             GameTextForPlayer(playerid, "~w~Kopfhoerer~n~deaktiviert.", 1500, 1);
  103.         }
  104.         return 1;
  105.     }
  106.    
  107.     ECMD2("/mhelp", "/rhelp")
  108.     {
  109.         SendClientMessage(playerid, 0xFFFFFFFF, "Anhören: /radio, /music");
  110.         SendClientMessage(playerid, 0xFFFFFFFF, "");
  111.         SendClientMessage(playerid, 0xFFFFFFFF, "Stoppen: /rstop, /mstop");
  112.         SendClientMessage(playerid, 0xFFFFFFFF, "");
  113.         SendClientMessage(playerid, 0xFFFFFFFF, "Kopfhörer: /headphones, /kopfhörer");
  114.         return 1;
  115.     }
  116.     return 0;
  117. }
  118.  
  119. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  120. {
  121.     if((dialogid == DIALOG_MUSIC) && response == 1)
  122.     {
  123.         PlayAudioStreamForPlayer(playerid, MusicTitle[listitem][TitleLink]);
  124.         new str[90];
  125.         format(str, 90, "~w~Du hoerst~n~%s", MusicTitle[listitem][TitleName]);
  126.         GameTextForPlayer(playerid, str, 2000, 1);
  127.         EnableHeadPhones(playerid);
  128.     }
  129.     return 1;
  130. }
  131.  
  132. stock EnableHeadPhones(playerid)
  133. {
  134.     if(IsPlayerAttachedObjectSlotUsed(playerid, HEAD_PHONES_SLOT))RemovePlayerAttachedObject(playerid, HEAD_PHONES_SLOT);
  135.     SetPlayerAttachedObject(playerid, HEAD_PHONES_SLOT,19421,2,0.059999,0.022001,0.000000,-92.799964,-172.300109,89.600074,1.070999,0.955000,1.000000);
  136.     return 1;
  137. }
  138.  
  139. stock DistableHeadPhones(playerid, headon)
  140. {
  141.     if(IsPlayerAttachedObjectSlotUsed(playerid, HEAD_PHONES_SLOT))RemovePlayerAttachedObject(playerid, HEAD_PHONES_SLOT);
  142.     if(headon)SetPlayerAttachedObject(playerid, HEAD_PHONES_SLOT,19421,17,0.070999,0.076999,0.004999,102.700035,-79.999961,-82.699974,1.000000,1.000000,1.000000);
  143.     return 1;
  144. }
Add Comment
Please, Sign In to add comment