Bob_Marley

[PAWNO] Advanced Dynamic Radio R2

Oct 15th, 2012
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.60 KB | None | 0 0
  1. #file "player.amx"
  2. #include <a_samp>
  3. #include <YSI\y_hooks>
  4. #define Audio(%1,%2) \
  5.             PlayAudioStreamForPlayer(%1,%2)
  6. #define Stop(%1) \
  7.             StopAudioStreamForPlayer(%1)   
  8. new bool:RadioVehicle[MAX_PLAYERS char];
  9. hook OnFilterScriptInit() print(">> Radio R2 successfully loaded.");
  10. hook OnFilterScriptExit() print(">> Stop.");
  11. hook OnPlayerDeath(playerid, killerid, reason) StopAudioStreamForPlayer(playerid);
  12. hook OnPlayerDisconnect(playerid, reason) StopAudioStreamForPlayer(playerid);  
  13. hook OnPlayerCommandText(playerid, cmdtext[])
  14. {
  15.     if(strcmp(cmdtext, "/radio", true) == 0) return Useradio(playerid);
  16.     if(strcmp(cmdtext, "/buyradio", true) == 0) return Buyradio(playerid);
  17.     return SendClientMessage(playerid,-1,"SERVER: Unknown command.");    
  18. }
  19. hook OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  20. {
  21.     if(newkeys & 8192)
  22.     {  
  23.         if(GetPlayerVehicleID(playerid)){
  24.             if(!RadioVehicle{playerid}){
  25.                 Audio(playerid,"http://webcast.emg.fm:55655/europaplus128.mp3");
  26.                 RadioVehicle{playerid} = true;
  27.                 SendClientMessage(playerid,-1,"To turn off the radio in the car then numpad4");
  28.                 SendClientMessage(playerid,-1,"To scroll through the radio, press N");
  29.             }
  30.             else{  
  31.                 Stop(playerid);
  32.                 RadioVehicle{playerid} = false;
  33.             }              
  34.         }
  35.     }
  36.     if(newkeys & KEY_NO){
  37.         if(GetPlayerVehicleID(playerid)){
  38.             new rand=random(6);  
  39.             switch(rand){  
  40.                 case 0: Audio(playerid,"1");                        
  41.                 case 1: Audio(playerid,"2");
  42.                 case 2: Audio(playerid,"3");
  43.                 case 3: Audio(playerid,"4");
  44.                 case 4: Audio(playerid,"5");
  45.                 case 5: Audio(playerid,"6");
  46.                 case 6: Audio(playerid,"7");                           
  47.             }
  48.         }
  49.     }      
  50.     return 1;
  51. }
  52. hook OnPlayerStateChange(playerid, newstate, oldstate)
  53. {
  54.     if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
  55.     {
  56.           SendClientMessage(playerid,-1,"To turn on the car radio, press numpad4");
  57.     }
  58.     else if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER) Stop(playerid);
  59. }
  60. hook OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]){
  61.     switch(dialogid){
  62.         case 1:{
  63.             switch(listitem) {
  64.                 case 0:{
  65.                     Audio(playerid,"http://webcast.emg.fm:55655/europaplus128.mp3");
  66.                     SendClientMessage(playerid,-1,"Are you wearing the headphones.");
  67.                 }
  68.                 case 1:{
  69.                     Stop(playerid);
  70.                     SendClientMessage(playerid,-1,"Are you wearing the headphones.");
  71.                 }                  
  72.             }
  73.         }
  74.         case 2:{
  75.             switch(listitem) {
  76.                 case 0:{
  77.                     SetPVarInt(playerid,"Radio",1);
  78.                     SendClientMessage(playerid, -1, "You bought a player with headphones.");
  79.                     GivePlayerMoney(playerid, -5);
  80.                 }                  
  81.             }
  82.         }
  83.     }  
  84. }
  85.  
  86. Useradio(playerid)  
  87. {    
  88.     printf("Use radio %s.",Name(playerid));
  89.     if(GetPVarInt(playerid,"Radio") == 0)return SendClientMessage(playerid, -1, "You do not have the player.");
  90.     return ShowPlayerDialog(playerid,1,DIALOG_STYLE_LIST,"Selecting a radio station","Europa plus\n\
  91.    {FF0000}Radio OFF{FFFFFF}","ENTER","EXIT");
  92. }
  93. Buyradio(playerid)  
  94. {    
  95.     printf("Buy radio %s.",Name(playerid));
  96.     return ShowPlayerDialog(playerid,2,DIALOG_STYLE_LIST,"Buy","Player","ENTER","EXIT");
  97. }
  98. stock Name(playerid)
  99. {
  100.     new name[MAX_PLAYER_NAME];
  101.     GetPlayerName(playerid, name, sizeof(name));
  102.     return name;
  103. }  
  104. #endscript
Advertisement
Add Comment
Please, Sign In to add comment