Thread: [Solved] StopSound dont work..
View Single Post
Author Message
Javierko
AlliedModders Donor
Join Date: Sep 2017
Location: Czech republic
Old 12-10-2017 , 08:15   StopSound dont work..
Reply With Quote #1

Hey coders,

i am making menu items..

One menu item (start) will turn on sound..
And menu item (off) will turn off sound or stop playing sound, but this what i write dont work.
I tried another codes, but dont work too.

Please help, thanks.

PHP Code:
#include <emitsoundany>
#include <sourcemod>

#define Zvedam "testing/zvedam.mp3"
#define LoopClients(%1) for(int %1 = 1; %1 <= MaxClients; %1++)

#pragma semicolon 1
#pragma newdecls required

public Plugin myinfo =
{
    
name "Menu",
    
author "Javi",
    
description "TEST",
    
version "1.0",
    
url "test"
};

public 
void OnMapStart()
{
  
AddFileToDownloadsTable("sound/testing/zvedam.mp3");
  
PrecacheSoundAny("testing/zvedam.mp3");  
}

public 
void OnPluginStart()
{
  
RegConsoleCmd("sm_test"Command_test);   
}

public 
Action Command_test(int clientint args)
{
  
Menu menu = new Menu(m_headmenu);
  
menu.SetTitle("HeadMenu");
  
menu.AddItem("start""Turn on music");
  
menu.AddItem("off""Turn off music");
  
menu.Display(clientMENU_TIME_FOREVER);
  
  return 
Plugin_Handled;
}

public 
int m_headmenu(Menu menuMenuAction actionint clientint index)
{
  if(
action == MenuAction_Select)
  {
    
char szItem[12];
    
menu.GetItem(indexszItemsizeof(szItem));
    if(
StrEqual(szItem"start"false))
    {
      
EmitSoundToAllAny(Zvedam);
    }
    else if(
StrEqual(szItem"off"false)) 
    {
      
LoopClients(i)
      {
        
StopSoundPermAny(iZvedam);
      }
    } 
  }
  else if(
action == MenuAction_End)
  {
    
delete menu;
  }
}

stock void StopSoundPermAny(int ichar[] sound
{
  
StopSound(iSNDCHAN_AUTOsound);
  
StopSound(iSNDCHAN_WEAPONsound);
  
StopSound(iSNDCHAN_VOICEsound);
  
StopSound(iSNDCHAN_ITEMsound);
  
StopSound(iSNDCHAN_BODYsound);
  
StopSound(iSNDCHAN_STREAMsound);
  
StopSound(iSNDCHAN_VOICE_BASEsound);
  
StopSound(iSNDCHAN_USER_BASEsound);

__________________
My Github & Sourcemod work.
If you like my work and if you want to support me, you can through PayPal.

Official SourceMod CZ/SK Discord: https://discord.gg/Qvar55a

Last edited by Javierko; 12-10-2017 at 13:06.
Javierko is offline