Advertisement
Guest User

Untitled

a guest
May 2nd, 2014
1,765
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.69 KB | None | 0 0
  1. /*
  2.                                                                     Megaphone Filterscript
  3.  
  4.                     The megaphone filterscript was scripted by Rehasher, credits must not be removed from the filterscript.
  5.                     The filterscript is licensed under the Don't be a dick public license (DBAD). http://www.dbad-license.org/ Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed.
  6.  
  7. */
  8.  
  9.  
  10. #include <a_samp>
  11. #include <zcmd>
  12. #include <sscanf2>
  13. #include <foreach>
  14.  
  15. // ==================================
  16. // |            ARRAY               |
  17. // |    Includes sound ids and      |
  18. // |    voice descriptions.         |
  19. // ==================================
  20.  
  21.  
  22. new MegaphoneSounds[][] =
  23. {
  24.     // SPLIT COMMA
  25.     // SOUND ID , DESCRIPTION
  26.     {"9605,Give up. You're surrounded!"},
  27.     {"9612,We know you're in there!"},
  28.     {"10200,Hey you! Police. Stop!"},
  29.     {"15800,This is the Los Santos Police Department; Stay where you are!"},
  30.     {"15801,Freeze! Or we will open fire"},
  31.     {"15802,Go! Go! Go!"},
  32.     {"34402,Police! Don't move!"},
  33.     {"34403,Get outta the car with your hands in the air!"},
  34.     {"15825,LSPD. Stop right... are you insane? You'll kill us all!"}
  35. };
  36.  
  37. // ==================================
  38. // |            DEFINITIONS         |
  39. // | Colours, dialogs and more...   |
  40. // ==================================
  41.  
  42.  
  43. #define DIALOG_MEGAPHONE_MENU       (10201)
  44.  
  45. #define COLOR_WHITE                 0xFFFFFFFF
  46. #define COLOR_LIGHTBLUE             0x0080FFFF
  47. #define COLOR_RED                   0xAA3333AA
  48. #define VERSION                     ("1.1")
  49.  
  50. #define SCM SendClientMessage
  51.  
  52. // ==================================
  53. // |            VARIABLES           |
  54. // | Used for stuff, many stuff     |
  55. // ==================================
  56.  
  57. new Message[1000];
  58.  
  59. // ==================================
  60. // |            CALLBACKS           |
  61. // | Used for stuff, many stuff     |
  62. // ==================================
  63.  
  64. public OnFilterScriptInit()
  65. {
  66.     printf("   "); printf("   "); printf("   ");
  67.  
  68.     print("Megaphone Filterscript                          ");
  69.     print("Filtescript was successfully loaded.            ");
  70.     printf("Filterscript Version : %s                      ", VERSION);
  71.  
  72.     printf("   "); printf("   "); printf("   ");
  73.     return 1;
  74. }
  75.  
  76. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  77. {
  78.     if(dialogid == DIALOG_MEGAPHONE_MENU)
  79.     {
  80.         if(!response) return SCM(playerid, COLOR_WHITE, "Cancel");
  81.         new soundid, tw1 = 0;
  82.         for(new w1 = 0; w1 < sizeof(MegaphoneSounds); w1++)
  83.         {
  84.             if(tw1 != listitem)
  85.             {
  86.                 tw1++;
  87.                 continue;
  88.             }
  89.             new tmp1[2][128];
  90.             split(MegaphoneSounds[w1], tmp1, ',');
  91.             soundid = strval(tmp1[0]);
  92.             break;
  93.         }
  94.         new Float:pos[4];
  95.         GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
  96.         PlaySoundEx(soundid, pos[0], pos[1], pos[2], 15);
  97.         return 1;
  98.     }
  99.     return 0;
  100. }
  101.  
  102. // ==================================
  103. // |            COMMANDS            |
  104. // | Used for stuff, many stuff     |
  105. // ==================================
  106.  
  107. CMD:megaphone(playerid, params[])
  108. {
  109.     if(!sscanf(params, "s[250]", params))
  110.     {
  111.         format(Message, sizeof(Message), "*MEGAPHONE* %s", params);
  112.         ProxDetector(15.0, playerid, Message, COLOR_RED);
  113.         return 1;
  114.     }
  115.  
  116.     new str1[2500], c1 = 0;
  117.     for(new w1 = 0; w1 < sizeof(MegaphoneSounds); w1++)
  118.     {
  119.         new tmp1[2][128];
  120.         split(MegaphoneSounds[w1], tmp1, ',');
  121.         if(c1 == 0) format(str1, sizeof(str1), "{FFFFFF}%s\n", tmp1[1]);
  122.         if(c1 > 0) format(str1, sizeof(str1), "%s{FFFFFF}%s\n", str1, tmp1[1]);
  123.         c1++;
  124.     }
  125.     ShowPlayerDialog(playerid, DIALOG_MEGAPHONE_MENU, DIALOG_STYLE_LIST, "Megaphone Menu", str1, "Play", "Cancel");
  126.     return 1;
  127. }
  128.  
  129. // ==================================
  130. // |            STOCKS              |
  131. // | Used for stuff, many stuff     |
  132. // ==================================
  133.  
  134. stock ProxDetector(Float:radi, playerid, string[], color)
  135. {
  136.     new Float:x,Float:y,Float:z;
  137.     GetPlayerPos(playerid,x,y,z);
  138.     foreach(Player,i)
  139.     {
  140.         if(IsPlayerInRangeOfPoint(i,radi,x,y,z))
  141.         {
  142.             SCM(i,color,string);
  143.         }
  144.     }
  145. }
  146.  
  147. stock split(const strsrc[], strdest[][], delimiter)
  148. {
  149.     new i, li;
  150.     new aNum;
  151.     new len;
  152.     while(i <= strlen(strsrc))
  153.     {
  154.         if(strsrc[i] == delimiter || i == strlen(strsrc))
  155.         {
  156.             len = strmid(strdest[aNum], strsrc, li, i, 128);
  157.             strdest[aNum][len] = 0;
  158.             li = i+1;
  159.             aNum++;
  160.         }
  161.         i++;
  162.     }
  163.     return 1;
  164. }
  165.  
  166. stock PlaySoundEx(soundid, Float:x, Float:y, Float:z, range)
  167. {
  168.     foreach(new i : Player)
  169.     {
  170.         if(!IsPlayerConnected(i)) continue;
  171.         if(!IsPlayerInRangeOfPoint(i, range, x, y, z)) continue;
  172.         PlayerPlaySound(i, soundid, 0, 0, 0);
  173.     }
  174. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement