Raised This Month: $ Target: $400
 0% 

Use sound when action done.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SaM.ThE.MaN
Senior Member
Join Date: Jan 2010
Old 06-20-2010 , 11:39   Use sound when action done.
Reply With Quote #1

Hi,

hmm , i would like to know how to play a sound , a custom sound when i do something .

Example 1: I jump and the sound plays (HE JUMPED)
Example 2: I shoot and the sound plays (HE SHOT)
etc . etc
__________________
  • Project : Level Plugin
o [||||||||||] - 100%
  • Project : OnePieceMod
o [||||||||||] - 20%
SaM.ThE.MaN is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 06-20-2010 , 12:23   Re: Use sound when action done.
Reply With Quote #2

Code:
#include <amxmodx> #include <fakemeta> #include <hamsandwich> new sound[] = "lala.wav" public plugin_precache() {     precache_sound( sound ) } public plugin_init() {     register_plugin( "Jump Shoot Ex", "1.0", "Wrecked" )         new wname[32]     for( new i = CSW_P228; i < CSW_P90; i++ )     {         if( i != 2 )         {             get_weaponname( i, wname, 31 )             RegisterHam( Ham_Weapon_PrimaryAttack, wname, "HamWeaponAttackPost", 1 )         }     }         RegisterHam( Ham_Player_Jump, "player", "HamJumpPost", 1 ) } public HamJumpPost( id ) {     if( !( pev( id, pev_oldbuttons ) & IN_JUMP ) && is_user_alive( id ) )     {         client_cmd( id, "spk %s", sound )     } } public HamWeaponAttackPost( wep ) {     new id = pev( wep, pev_owner )     if( !( pev( id, pev_oldbuttons ) & IN_ATTACK ) )     {         client_cmd( id, "spk %s", sound )     } }
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
SaM.ThE.MaN
Senior Member
Join Date: Jan 2010
Old 06-20-2010 , 13:49   Re: Use sound when action done.
Reply With Quote #3

oh thanx thanx , another question ,

What if there is a menu,

consisting 2 items :

1. Cow
2. Goat

when i select cow , the sound plays moooo.
and goat it says maaaa.

example
__________________
  • Project : Level Plugin
o [||||||||||] - 100%
  • Project : OnePieceMod
o [||||||||||] - 20%
SaM.ThE.MaN is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 06-20-2010 , 13:54   Re: Use sound when action done.
Reply With Quote #4

PHP Code:
#include <amxmodx>

#pragma semicolon 1

new cow[] = "sound/cow.wav";
new 
goat[] = "sound/goat.wav";

public 
plugin_init()
{
    
register_plugin("rofl""1337""Drekes");
    
    
register_clcmd("say /menu""mainmenu");
}

public 
plugin_precache()
{
    
precache_sound(cow);
    
precache_sound(goat);
}

public 
mainmenu(id)
{
    new 
menu menu_create("Animal Menu""sub_mainmenu");
    
    
menu_additem(menu"Cow""1"0);
    
menu_additem(menu"goat""2"0);
    
    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
    
menu_display(idmenu);
}

public 
sub_mainmenu(idmenuitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    
    new 
Data[7], Name[64];
    new 
AccessCallback;
    
menu_item_getinfo(menuitemAccessData,5Name63Callback);
    
    new 
Key str_to_num(Data);
    
    switch(
Key)
    {
        case 
1:
            
client_cmd(id"spk ^"%s^""cow);
            
        case 
2:
            
client_cmd(id"spk ^"%s^"");
    }
    
    return 
PLUGIN_HANDLED;

__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.

Last edited by drekes; 06-20-2010 at 17:02.
drekes is offline
Send a message via MSN to drekes
SaM.ThE.MaN
Senior Member
Join Date: Jan 2010
Old 06-20-2010 , 14:14   Re: Use sound when action done.
Reply With Quote #5

what is this for : #pragma semicolon 1
__________________
  • Project : Level Plugin
o [||||||||||] - 100%
  • Project : OnePieceMod
o [||||||||||] - 20%
SaM.ThE.MaN is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 06-20-2010 , 14:35   Re: Use sound when action done.
Reply With Quote #6

Quote:
Originally Posted by SaM.ThE.MaN View Post
what is this for : #pragma semicolon 1
It makes you put a semicolon at the end of every statement or function or stuff or junk. Search for it, you'll find some topics about it; I actually think I started one a while back.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
SaM.ThE.MaN
Senior Member
Join Date: Jan 2010
Old 06-20-2010 , 16:42   Re: Use sound when action done.
Reply With Quote #7

Quote:
spk sound/goat.wav
unknown command spk sound/goat.wav

even when i enter a valid address , exp : sound\ambience\cow.wav

it says the same thing.

i think invalid command , anyways not working 4 me
__________________
  • Project : Level Plugin
o [||||||||||] - 100%
  • Project : OnePieceMod
o [||||||||||] - 20%
SaM.ThE.MaN is offline
RedRobster
Veteran Member
Join Date: Apr 2010
Location: Your Closet
Old 06-20-2010 , 16:57   Re: Use sound when action done.
Reply With Quote #8

On this subject, what is the difference between "spk" and "echo"? I have seen both used, but never got the difference.

**If I'm not mistaken, you will also have to precache the sounds for them to work.
RedRobster is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 06-20-2010 , 17:00   Re: Use sound when action done.
Reply With Quote #9

Quote:
Originally Posted by RedRobster View Post
On this subject, what is the difference between "spk" and "echo"? I have seen both used, but never got the difference.

**If I'm not mistaken, you will also have to precache the sounds for them to work.
spk is to play .wav files, echo is to print something in console afaik.

yes, you need to precache them.

Edit: I changed the code, try now
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.

Last edited by drekes; 06-20-2010 at 17:02.
drekes is offline
Send a message via MSN to drekes
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 14:55.


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