Raised This Month: $51 Target: $400
 12% 

Random sound when round starts


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
HowToRuski
Senior Member
Join Date: Feb 2019
Location: Hungary
Old 04-09-2023 , 11:01   Random sound when round starts
Reply With Quote #1

Hello, i think im wrong in this source code, the sound isnt being played, but the sound files precaches.
any help?

PHP Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Warning Sound"
#define VERSION "1.0"
#define AUTHOR "LVNDR"


const MAX_SOUNDS 2;
new 
g_Sounds[MAX_SOUNDS][32] = {
    {
"revenge/warning1.wav"},
    {
"revenge/warning2.wav"}
};

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_event("HLTV""event_round_start""a""1=0""2=0"
}

public 
plugin_precache()
{
    for (new 
0MAX_SOUNDSi++)
    {
        
precache_sound(g_Sounds[i]);
    }
}

public 
event_round_start()
{
    
set_task(2.0"countdown")
}

public 
countdown()
{
    
set_task(5.0"biohazard_detected")
}

public 
biohazard_detected()
{
    new 
randSound random_num(0MAX_SOUNDS 1);
    
emit_sound(0CHAN_AUTOg_Sounds[randSound], VOL_NORMATTN_NONE0PITCH_NORM);

HowToRuski is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 04-09-2023 , 11:49   Re: Random sound when round starts
Reply With Quote #2

Check if the sound wav file is compatible for goldsrc.p
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
HowToRuski
Senior Member
Join Date: Feb 2019
Location: Hungary
Old 04-09-2023 , 11:53   Re: Random sound when round starts
Reply With Quote #3

Quote:
Originally Posted by Natsheh View Post
Check if the sound wav file is compatible for goldsrc.p
It wasn't sorry.

Last edited by HowToRuski; 04-09-2023 at 12:59.
HowToRuski is offline
Hakim Azizov
Member
Join Date: Mar 2023
Old 04-09-2023 , 14:04   Re: Random sound when round starts
Reply With Quote #4

Change your codes to this

PHP Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Warning Sound"
#define VERSION "1.0"
#define AUTHOR "LVNDR"

new g_Sounds[][] = {
    {
"revenge/warning1.wav"},
    {
"revenge/warning2.wav"}
};

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_event("HLTV""event_round_start""a""1=0""2=0"
}

public 
plugin_precache()
{
    for (new 
0sizeof(g_Sounds); i++)
    {
        
precache_sound(g_Sounds[i]);
    }
}

public 
event_round_start()
{
    
set_task(2.0"countdown")
}

public 
countdown()
{
    
set_task(5.0"biohazard_detected")
}

public 
biohazard_detected()
{
    new 
randSound random_num(0sizeof(g_Sounds) - 1);
    
client_cmd(0"spk ^"%s^""g_Sounds[randSound]);

Hakim Azizov is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 04-09-2023 , 15:08   Re: Random sound when round starts
Reply With Quote #5

Quote:
Originally Posted by Hakim Azizov View Post
Change your codes to this

PHP Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Warning Sound"
#define VERSION "1.0"
#define AUTHOR "LVNDR"

new g_Sounds[][] = {
    {
"revenge/warning1.wav"},
    {
"revenge/warning2.wav"}
};

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_event("HLTV""event_round_start""a""1=0""2=0"
}

public 
plugin_precache()
{
    for (new 
0sizeof(g_Sounds); i++)
    {
        
precache_sound(g_Sounds[i]);
    }
}

public 
event_round_start()
{
    
set_task(2.0"countdown")
}

public 
countdown()
{
    
set_task(5.0"biohazard_detected")
}

public 
biohazard_detected()
{
    new 
randSound random_num(0sizeof(g_Sounds) - 1);
    
client_cmd(0"spk ^"%s^""g_Sounds[randSound]);

There's no need to change his code, infact his method is more stable.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
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 13:21.


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