Advertisement
legodude

Custom Horns

Sep 28th, 2011
724
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.17 KB | None | 0 0
  1. #define FILTERSCRIPT
  2.  
  3. #include <a_samp>
  4.  
  5. #define HORN_DIALOG (16234)
  6. #define HORNKEY KEY_SUBMISSION
  7. new horns[9][2][64] = {
  8. {"http://sampsounds.site40.net/1.mp3","horn 1"},
  9. {"http://sampsounds.site40.net/2.mp3","horn 2"},
  10. {"http://sampsounds.site40.net/3.mp3","horn 3"},
  11. {"http://sampsounds.site40.net/4.mp3","horn 4"},
  12. {"http://sampsounds.site40.net/5.mp3","horn 5"},
  13. {"http://sampsounds.site40.net/6.mp3","horn 6"},
  14. {"http://sampsounds.site40.net/7.mp3","horn 7"},
  15. {"http://sampsounds.site40.net/8.mp3","horn 8"},
  16. {"http://sampsounds.site40.net/9.mp3","horn 9"}
  17. };
  18.  
  19. new HornsStr[256];
  20.  
  21. new Horn[MAX_PLAYERS];
  22.  
  23. public OnFilterScriptInit()
  24. {
  25.     print("\n--------------------------------------");
  26.     print(" Custom Horn Sounds.");
  27.     print("--------------------------------------\n");
  28.     for(new i; i<sizeof(horns);i++)
  29.     {
  30.         if(i<sizeof(horns)-1)
  31.         {
  32.             format(HornsStr,sizeof(HornsStr),"%s%s\n",HornsStr, horns[i][1]);
  33.         }
  34.         else
  35.         {
  36.             format(HornsStr,sizeof(HornsStr),"%s%s",HornsStr, horns[i][1]);
  37.         }
  38.     }
  39.     return 1;
  40. }
  41.  
  42. public OnPlayerCommandText(playerid, cmdtext[])
  43. {
  44.     if (strcmp("/horn", cmdtext, true, 10) == 0)
  45.     {
  46.         ShowPlayerDialog(playerid,HORN_DIALOG,DIALOG_STYLE_LIST,"Select your horn",HornsStr,"Choose","Listen");
  47.         return 1;
  48.     }
  49.     return 0;
  50. }
  51.  
  52. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  53. {
  54.     if(dialogid==HORN_DIALOG)
  55.     {
  56.         if(!response)
  57.         {
  58.             PlayAudioStreamForPlayer(playerid, horns[listitem][0]);
  59.             ShowPlayerDialog(playerid,HORN_DIALOG,DIALOG_STYLE_LIST,"Select your horn",HornsStr,"Choose","Listen");
  60.         }
  61.         else
  62.         {
  63.             Horn[playerid]=listitem;
  64.         }
  65.     }
  66.     return 1;
  67. }
  68. #define RELEASED(%0) \
  69.     (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
  70. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  71. {
  72.     if (RELEASED(HORNKEY))
  73.     {
  74.         new Float:p[3];
  75.         GetPlayerPos(playerid,p[0],p[1],p[2]);
  76.         for(new i;i<MAX_PLAYERS;i++)
  77.         {
  78.             if(IsPlayerInRangeOfPoint(i,35,p[0],p[1],p[2]))
  79.             {
  80.                 PlayAudioStreamForPlayer(i, horns[Horn[playerid]][0]);
  81.             }
  82.         }
  83.         PlayAudioStreamForPlayer(playerid, horns[Horn[playerid]][0]);
  84.     }
  85.     return 1;
  86. }
  87.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement