Raised This Month: $32 Target: $400
 8% 

Solved StopSound dont work..


Post New Thread Reply   
 
Thread Tools Display Modes
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
backwards
AlliedModders Donor
Join Date: Feb 2014
Location: USA
Old 12-10-2017 , 08:29   Re: StopSound dont work..
Reply With Quote #2

The StopSound function isn't meant to stop sounds forever, it only stops the sound from playing if it's currently playing the instant you run the cmd. If you want a hook for worldspace emited sounds you can stop most of them using an AddNormalSoundHook: https://sm.alliedmods.net/new-api/sd...ormalSoundHook
__________________
I highly recommend joining the SourceMod Discord Server for real time support.
backwards is offline
Javierko
AlliedModders Donor
Join Date: Sep 2017
Location: Czech republic
Old 12-10-2017 , 13:06   Re: StopSound dont work..
Reply With Quote #3

Thanks for help..

Solved
__________________
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
Javierko is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 23:10.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode