HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /*
  2. end_sound.sp
  3.  
  4. Description:
  5. Plays Music/sound at the end of the map.
  6.   Has a cvar for the filename to play
  7.  
  8. Versions:
  9. 1.2
  10. * Initial Release
  11.  
  12. Fordította: BBk
  13. */
  14.  
  15.  
  16. #include <sourcemod>
  17. #include <sdktools>
  18.  
  19. #define PLUGIN_VERSION "1.2"
  20.  
  21. #pragma semicolon 1
  22. #define MAX_FILE_LEN 255
  23.  
  24. public Plugin:myinfo =
  25. {
  26. name = "Map End Music/Sound",
  27. author = "TechKnow",
  28. description = "Zene/hang lejatszasa a palya vegen.",
  29. version = PLUGIN_VERSION,
  30. url = "http://forums.alliedmods.net"
  31. };
  32.  
  33. new Handle:cvarSoundName;
  34. new String:soundFileName[MAX_FILE_LEN];
  35.  
  36.  
  37. public OnPluginStart()
  38. {
  39. CreateConVar("sm_MapEnd_Sound_version", PLUGIN_VERSION, "MapEnd_Sound_Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
  40. cvarSoundName = CreateConVar("sm_end_sound", "mapend/end.mp3", "A hang lejatszasa a palya vegen");
  41. HookEvent("round_end", EndEvent);
  42.  
  43. AutoExecConfig(true, "end_sound");
  44. OnMapStart();
  45. }
  46.  
  47.  
  48. public OnMapStart()
  49. {
  50. GetConVarString(cvarSoundName, soundFileName, MAX_FILE_LEN);
  51. decl String:buffer[MAX_FILE_LEN];
  52. PrecacheSound(soundFileName, true);
  53. Format(buffer, MAX_FILE_LEN, "sound/%s", soundFileName);
  54. AddFileToDownloadsTable(buffer);
  55. }
  56.  
  57. public EndEvent(Handle:event,const String:name[],bool:dontBroadcast)
  58. {
  59. new timeleft;
  60. GetMapTimeLeft(timeleft);
  61. if (timeleft <= 0)
  62. {
  63. for(new i = 1; i <= GetMaxClients(); i++)
  64. if(IsClientConnected(i) && !IsFakeClient(i))
  65. {
  66. decl String:buffer[255];
  67. Format(buffer, sizeof(buffer), "play %s", (soundFileName), SNDLEVEL_RAIDSIREN);
  68. ClientCommand((i), buffer);
  69. }
  70. }
  71. }
  72.  
  73. public OnEventShutdown()
  74. {
  75. UnhookEvent("round_end", EndEvent);
  76. }