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

No sound emited by entity


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CryWolf
Veteran Member
Join Date: Jul 2008
Location: Romania
Old 10-22-2014 , 07:36   No sound emited by entity
Reply With Quote #1

Hi AM community, i have created an entity binded to a console comand and i want to add sounds to it when players are around , just it doesn't work and i don't know why, some help please

My code
PHP Code:
new const d_sounds [ ] [ ] =
{
    
"barnacle/bcl_alert2.wav",
    
"x/nih_die2.wav",
    
"x/x_pain1.wav",
    
"x/x_pain2.wav",
    
"x/x_pain3.wav"

and plugin_init
PHP Code:
register_forward FM_Think"PmPSound" ); 
now the forward
PHP Code:
public PmPSound entchannel, const sound [ ] )
{
    static 
classname 32 ];
    
pev(ent,pev_classname,classname,31);
    
    if(
equali(classnameitem_name))
    {
        if ( 
get_pcvar_num pCvar_sound ) )
        {
            new 
random sizeof d_sounds ) );
            
emit_sound entCHAN_VOICEd_sounds ], VOL_NORMATTN_NORM0PITCH_NORM );
            return 
FMRES_SUPERCEDE;
        }
    }
    return 
FMRES_IGNORED;

and created entity
PHP Code:
new ent engfunc EngFunc_CreateNamedEntityengfunc EngFunc_AllocString"info_target" ) );
    
set_pev entpev_classnameitem_name );
    
engfunc EngFunc_SetModelentp_model ); 
+ the global
PHP Code:
new const item_name [ ] = "dm_pumplin" 
what's wrong here ? because i hear no sound when i'm around entity.
__________________
I dont walk trough this world with fear in my heart.
www.dark-arena.com L4D, CS1.6, CZ Servers

Last edited by CryWolf; 10-22-2014 at 07:42.
CryWolf is offline
Send a message via MSN to CryWolf Send a message via Yahoo to CryWolf
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 10-22-2014 , 07:53   Re: No sound emited by entity
Reply With Quote #2

does your entity even "think"

post full code

Last edited by jimaway; 10-22-2014 at 07:54.
jimaway is offline
red_bull2oo6
Senior Member
Join Date: Mar 2012
Location: Braila, Romania
Old 10-22-2014 , 08:02   Re: No sound emited by entity
Reply With Quote #3

as jimaway said i think here is the problem..
your entity never think

PHP Code:
new ent engfunc EngFunc_CreateNamedEntityengfunc EngFunc_AllocString"info_target" ) );
    
set_pev entpev_classnameitem_name );
    
engfunc EngFunc_SetModelentp_model ); 
->>

PHP Code:
new ent engfunc EngFunc_CreateNamedEntityengfunc EngFunc_AllocString"info_target" ) );
set_pev entpev_classnameitem_name );
engfunc EngFunc_SetModelentp_model ); 
set_pev entpev_nextthinkget_gametime( ) + 0.1 ); 
you need to make it instantly think after you create it.. and you'll set the new 'think delay' in the thinking forward.

-->
PHP Code:
public PmPSound entchannel, const sound [ ] )
{
    static 
classname 32 ];
    
pev(ent,pev_classname,classname,31);
    
    if(
equali(classnameitem_name))
    {
        
set_peventpev_nextthinkget_gametime( ) + 1.0 ); // your delay instead 1.0 
        
        
if ( get_pcvar_num pCvar_sound ) )
        {
            new 
random sizeof d_sounds ) );
            
emit_sound entCHAN_VOICEd_sounds ], VOL_NORMATTN_NORM0PITCH_NORM );
            return 
FMRES_SUPERCEDE;
        }
    }
    return 
FMRES_IGNORED;

__________________

My PC Themes . .

Last edited by red_bull2oo6; 10-22-2014 at 08:05.
red_bull2oo6 is offline
CryWolf
Veteran Member
Join Date: Jul 2008
Location: Romania
Old 10-22-2014 , 10:01   Re: No sound emited by entity
Reply With Quote #4

Thanks red it works but don't know why only the first time when spawning the entity.

Intra si tu in pana mea pe steam )
__________________
I dont walk trough this world with fear in my heart.
www.dark-arena.com L4D, CS1.6, CZ Servers
CryWolf is offline
Send a message via MSN to CryWolf Send a message via Yahoo to CryWolf
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 10-22-2014 , 10:44   Re: No sound emited by entity
Reply With Quote #5

Add this set_pev( ent, pev_nextthink, get_gametime( ) + 1.0 ); // your delay instead 1.0 outside the if( ) check. Also, PmSound is not a good name since it's almost the same as PM_Sound. You may want to choose a better name.
__________________
HamletEagle is offline
CryWolf
Veteran Member
Join Date: Jul 2008
Location: Romania
Old 10-23-2014 , 10:16   Re: No sound emited by entity
Reply With Quote #6

Thanks guys Solved!


Salutare!
__________________
I dont walk trough this world with fear in my heart.
www.dark-arena.com L4D, CS1.6, CZ Servers
CryWolf is offline
Send a message via MSN to CryWolf Send a message via Yahoo to CryWolf
Reply


Thread Tools
Display Modes

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 15:11.


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