Advertisement
Guest User

welp

a guest
Jun 25th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.90 KB | None | 0 0
  1. const string g_SpriteName = 'sprites/640_logo.spr';
  2. const uint g_Delay = 1;
  3.  
  4. dictionary g_SoundList;
  5. dictionary g_ChatTimes;
  6.  
  7. array<string> @g_SoundListKeys;
  8.  
  9. CClientCommand g_ListSounds("anonymous", "List all chat sounds", @listsounds);
  10.  
  11. void PluginInit() {
  12. g_Module.ScriptInfo.SetAuthor("animaliZed - Only admin");
  13. g_Module.ScriptInfo.SetContactInfo("irc://irc.rizon.net/#/dev/null");
  14.  
  15. g_Hooks.RegisterHook(Hooks::Player::ClientSay, @ClientSay);
  16. }
  17.  
  18. void MapInit() {
  19. g_SoundList.deleteAll();
  20. g_ChatTimes.deleteAll();
  21.  
  22. ReadSounds();
  23.  
  24. for (uint i = 0; i < g_SoundListKeys.length(); ++i) {
  25. g_Game.PrecacheGeneric("sound/" + string(g_SoundList[g_SoundListKeys[i]]));
  26. g_SoundSystem.PrecacheSound(string(g_SoundList[g_SoundListKeys[i]]));
  27. }
  28. g_Game.PrecacheModel(g_SpriteName);
  29. }
  30.  
  31. const string g_SoundFile = "scripts/plugins/ChotSounds.txt";
  32. void ReadSounds() {
  33. File@ file = g_FileSystem.OpenFile(g_SoundFile, OpenFile::READ);
  34. if (file !is null && file.IsOpen()) {
  35. while(!file.EOFReached()) {
  36. string sLine;
  37. file.ReadLine(sLine);
  38. if (sLine.SubString(0,1) == "#" || sLine.IsEmpty())
  39. continue;
  40.  
  41. array<string> parsed = sLine.Split(" ");
  42. if (parsed.length() < 2)
  43. continue;
  44.  
  45. g_SoundList[parsed[0]] = parsed[1];
  46. }
  47. file.Close();
  48. @g_SoundListKeys = g_SoundList.getKeys();
  49. }
  50. }
  51.  
  52. void listsounds(const CCommand@ pArgs) {
  53. CBasePlayer@ pPlayer = g_ConCommandSystem.GetCurrentPlayer();
  54.  
  55. g_PlayerFuncs.ClientPrint(pPlayer, HUD_PRINTCONSOLE, "AVAILABLE SOUND TRIGGERS\n");
  56. g_PlayerFuncs.ClientPrint(pPlayer, HUD_PRINTCONSOLE, "------------------------\n");
  57.  
  58. string sMessage = "";
  59.  
  60. for (uint i = 1; i < g_SoundListKeys.length()+1; ++i) {
  61. sMessage += g_SoundListKeys[i-1] + " | ";
  62.  
  63. if (i % 5 == 0) {
  64. sMessage.Resize(sMessage.Length() -2);
  65. g_PlayerFuncs.ClientPrint(pPlayer, HUD_PRINTCONSOLE, sMessage);
  66. g_PlayerFuncs.ClientPrint(pPlayer, HUD_PRINTCONSOLE, "\n");
  67. sMessage = "";
  68. }
  69. }
  70.  
  71. if (sMessage.Length() > 2) {
  72. sMessage.Resize(sMessage.Length() -2);
  73. g_PlayerFuncs.ClientPrint(pPlayer, HUD_PRINTCONSOLE, sMessage + "\n");
  74. }
  75.  
  76. g_PlayerFuncs.ClientPrint(pPlayer, HUD_PRINTCONSOLE, "\n");
  77. }
  78.  
  79. HookReturnCode ClientSay(SayParameters@ pParams) {
  80. const CCommand@ pArguments = pParams.GetArguments();
  81.  
  82. if (pArguments.ArgC() > 0) {
  83. const string soundArg = pArguments.Arg(0).ToLowercase();
  84.  
  85. if (g_SoundList.exists(soundArg)) {
  86. CBasePlayer@ pPlayer = pParams.GetPlayer();
  87. pParams.ShouldHide = true;
  88. string sid = g_EngineFuncs.GetPlayerAuthId(pPlayer.edict());
  89.  
  90. if (!g_ChatTimes.exists(sid)) {
  91. g_ChatTimes[sid] = 0;
  92. }
  93.  
  94. uint t = uint(g_EngineFuncs.Time()*1000);
  95. uint d = t - uint(g_ChatTimes[sid]);
  96.  
  97. if (d < g_Delay) {
  98. float w = float(g_Delay - d) / 1.0f;
  99. g_PlayerFuncs.SayText(pPlayer, "[ChotSounds] AntiSpam: Your sounds are muted for " + ceil(w) + " seconds.\n");
  100. return HOOK_CONTINUE;
  101. }g_SoundList[soundArg];
  102. else {
  103. string ambientName = "vc__" + g_SoundList[soundArg];
  104. dictionary keyvalues;
  105. keyvalues["targetname"] = ambientName;
  106. keyvalues["message"] = g_SoundList[soundArg];
  107. keyvalues["pitch"] = string(state.pitch);
  108. keyvalues["spawnflags"] = "49";
  109. keyvalues["playmode"] = "1";
  110. keyvalues["health"] = string(vol * 10);
  111.  
  112. array<CBaseEntity@> ambients;
  113. for (uint g = 0; g < gain; g++)
  114. ambients.insertLast( g_EntityFuncs.CreateEntity( "ambient_generic", keyvalues, true ) );
  115.  
  116. g_EntityFuncs.FireTargets(ambientName, null, null, USE_ON);
  117.  
  118. // delete the entities we just created
  119. for (uint g = 0; g < ambients.length(); g++)
  120. if (ambients[g] !is null)
  121. g_EntityFuncs.Remove(ambients[g]);
  122.  
  123. pPlayer.ShowOverheadSprite(g_SpriteName, 1.0f, 5.0f);
  124. }
  125. g_ChatTimes[sid] = t;
  126. return HOOK_HANDLED;
  127. }
  128. }
  129. return HOOK_CONTINUE;
  130. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement