Raised This Month: $ Target: $400
 0% 

Roundsound Cvar On/Off


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ashcan
Senior Member
Join Date: May 2008
Old 01-26-2010 , 03:54   Roundsound Cvar On/Off
Reply With Quote #1

hello i use that plugin:

Code:
//RoundSound.amxx -by PaintLancer-mod by DZEK

#include <amxmodx>

public plugin_init() 
{ 
register_plugin("RoundSound mod","1.1 mod","PaintLancer-mod by Dzek")
register_event("SendAudio", "t_win", "a", "2&%!MRAD_terwin")
register_event("SendAudio", "ct_win", "a", "2&%!MRAD_ctwin") 
}
public t_win()
{
new rand = random_num(0,3)
client_cmd(0,"stopsound")
switch(rand)
{
case 0: play_any_sound("misc/tt1.mp3")
case 1: play_any_sound("misc/tt2.mp3")
case 2: play_any_sound("misc/tt3.mp3")
case 3: play_any_sound("misc/tt4.mp3")

}
return PLUGIN_HANDLED
}
public ct_win()
{
new rand = random_num(0,3)
client_cmd(0,"stopsound")
switch(rand)
{
case 0: play_any_sound("misc/ct1.mp3")
case 1: play_any_sound("misc/ct2.mp3")
case 2: play_any_sound("misc/ct3.mp3")
case 3: play_any_sound("misc/ct4.mp3")
}
return PLUGIN_HANDLED
}
public play_any_sound(sound[])
{
new is_mpeg = ( containi(sound, ".mp") != -1 )
if ( is_mpeg )
client_cmd(0, "mp3 play ^"sound/%s^"", sound)
else
client_cmd(0, "spk ^"%s^"", sound)
}

public plugin_precache() 
{
precache_generic("sound/misc/ct1.mp3")
precache_generic("sound/misc/ct2.mp3")
precache_generic("sound/misc/ct3.mp3")
precache_generic("sound/misc/ct4.mp3")
precache_generic("sound/misc/tt1.mp3")
precache_generic("sound/misc/tt2.mp3")
precache_generic("sound/misc/tt3.mp3")
precache_generic("sound/misc/tt4.mp3")

return PLUGIN_CONTINUE
}
And my question is:
How to add cvar to that so i can change state of plugin (on/off) only with cvar?

Regards

edit add:
if someone can change this sma code so please make all changes bold

Last edited by Ashcan; 01-26-2010 at 04:01.
Ashcan is offline
Ashcan
Senior Member
Join Date: May 2008
Old 01-26-2010 , 11:44   Re: Roundsound Cvar On/Off
Reply With Quote #2

up
Ashcan is offline
Mxnn
Veteran Member
Join Date: Aug 2009
Location: AT MY HOME
Old 01-26-2010 , 13:07   Re: Roundsound Cvar On/Off
Reply With Quote #3

PHP Code:
//RoundSound.amxx -by PaintLancer-mod by DZEK

#include <amxmodx>

new CVAR_ENABLE

public plugin_init()
{
    
CVAR_ENABLE register_cvar("rs_enable""1")
    
register_plugin("RoundSound mod","1.1 mod","PaintLancer-mod by Dzek")
    
register_event("SendAudio""t_win""a""2&%!MRAD_terwin")
    
register_event("SendAudio""ct_win""a""2&%!MRAD_ctwin")
}
public 
t_win()
{
    if (
get_pcvar_num(CVAR_ENABLE)) {
        
        new 
rand random_num(0,3)
        
client_cmd(0,"stopsound")
        switch(
rand)
        {
            case 
0play_any_sound("misc/tt1.mp3")
            case 
1play_any_sound("misc/tt2.mp3")
            case 
2play_any_sound("misc/tt3.mp3")
            case 
3play_any_sound("misc/tt4.mp3")
            
        }
    }
    return 
PLUGIN_HANDLED
}
public 
ct_win()
{
    if (
get_pcvar_num(CVAR_ENABLE)) {
        new 
rand random_num(0,3)
        
client_cmd(0,"stopsound")
        switch(
rand)
        {
            case 
0play_any_sound("misc/ct1.mp3")
            case 
1play_any_sound("misc/ct2.mp3")
            case 
2play_any_sound("misc/ct3.mp3")
            case 
3play_any_sound("misc/ct4.mp3")
        }
    }
    return 
PLUGIN_HANDLED
}
public 
play_any_sound(sound[])
{
    new 
is_mpeg = ( containi(sound".mp") != -)
    if ( 
is_mpeg )
        
client_cmd(0"mp3 play ^"sound/%s^""sound)
    else
        
client_cmd(0"spk ^"%s^""sound)
}

public 
plugin_precache()
{
    
precache_generic("sound/misc/ct1.mp3")
    
precache_generic("sound/misc/ct2.mp3")
    
precache_generic("sound/misc/ct3.mp3")
    
precache_generic("sound/misc/ct4.mp3")
    
precache_generic("sound/misc/tt1.mp3")
    
precache_generic("sound/misc/tt2.mp3")
    
precache_generic("sound/misc/tt3.mp3")
    
precache_generic("sound/misc/tt4.mp3")
    
    return 
PLUGIN_CONTINUE

Test it

EDIT: You can't bump until 2 weeks. See the rules u.u (don't worry, i have also done )

Last edited by Mxnn; 01-26-2010 at 16:38.
Mxnn 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 07:22.


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