Advertisement
Guest User

Untitled

a guest
Jan 25th, 2020
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <cstrike>
  3. #include <sdktools>
  4. #include <sdkhooks>
  5. #include <clientprefs>
  6. #include <csgocolors>
  7.  
  8. #pragma semicolon 1
  9. #pragma newdecls required
  10.  
  11. Handle Cookie_KillSound;
  12. bool killSound[MAXPLAYERS + 1];
  13.  
  14. public Plugin myinfo =
  15. {
  16. name = "Dead Sound",
  17. author = "Charlie W.",
  18. description = "",
  19. version = "1.1",
  20. url = ""
  21. };
  22.  
  23. #define SOUND_PATH "sound/arena/kill.mp3"
  24. #define RELATIVE_SOUND_PATH "/arena/kill.mp3"
  25.  
  26. public void OnMapStart()
  27. {
  28. AddFileToDownloadsTable(SOUND_PATH);
  29. FakePrecacheSound(RELATIVE_SOUND_PATH);
  30. }
  31.  
  32. public void OnPluginStart()
  33. {
  34. Cookie_KillSound = RegClientCookie("kill_sound", "Enable/Disable Kill sound", CookieAccess_Private);
  35.  
  36. RegConsoleCmd("sm_quake", Command_Sound , "Enable/Disable kill sound");
  37. RegConsoleCmd("sm_kłejk", Command_Sound , "Enable/Disable kill sound");
  38.  
  39. HookEvent("player_death", PlayerDeath);
  40. }
  41.  
  42. public void OnClientCookiesCached(int client)
  43. {
  44. char scookie[64];
  45.  
  46. GetClientCookie(client, Cookie_KillSound, scookie, sizeof(scookie));
  47. if(!StrEqual(scookie, ""))
  48. killSound[client] = view_as<bool>(StringToInt(scookie));
  49. else
  50. killSound[client] = true;
  51. return;
  52. }
  53.  
  54. public Action Command_Sound(int client, int args)
  55. {
  56. if(killSound[client])
  57. {
  58. SetClientCookie(client, Cookie_KillSound, "0");
  59. CPrintToChat(client, "{default}[{green}Arena{default}] Wyłączyłeś właśnie dziwięk po zabiciu przeciwnika.", "Off");
  60. }
  61. else if(!killSound[client])
  62. {
  63. SetClientCookie(client, Cookie_KillSound, "1");
  64. CPrintToChat(client, "{default}[{green}Arena{default}] Włączyłeś właśnie dziwięk po zabiciu przeciwnika.", "On");
  65. }
  66. OnClientCookiesCached(client);
  67. return Plugin_Handled;
  68. }
  69.  
  70. public Action PlayerDeath(Handle event, const char[] name, bool dontBroadcast)
  71. {
  72. int attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
  73. if(killSound[attacker])
  74. EmitSoundToClient(attacker, RELATIVE_SOUND_PATH);
  75. }
  76.  
  77. public void FakePrecacheSound(const char[] szPath)
  78. {
  79. AddToStringTable(FindStringTable("soundprecache"), szPath);
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement