Raised This Month: $ Target: $400
 0% 

Solved how to use SVC_SOUND?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Matias_Esf
Junior Member
Join Date: May 2012
Location: Argentina
Old 07-06-2022 , 15:53   how to use SVC_SOUND?
Reply With Quote #1

Hi.!

how to use the svc_sound?

https://wiki.alliedmods.net/Half-Lif...ages#SVC_SOUND

I want to play sounds through the index of the sound obtained through the sound_precache

Code:
Name:	SVC_SOUND
Structure:	
9 bits	Flags
8 bits	Volume * 255 (flags&1)
8 bits	Attenuation * 64 (flags&2)
3 bits	Channel
11 bits	EntityIndex
] 16 bits	SoundIndex (flags&4)
] or	
] 8 bits	SoundIndex !(flags&4)
n bits	Origin
8 bits	Pitch (flags&8)
n bits	alignment to byte boundary

Code:
#define clamp_byte(%1)     ( clamp( %1, 0, 255 ) ) 
stock emit_sound_byindex( const index, sound_index, channel = CHAN_AUTO, Float:vol = VOL_NORM, Float:atten = ATTN_NORM,  pitch = PITCH_NORM, flags = 0 )
{
	message_begin( index ? MSG_ONE : MSG_ALL, SVC_SOUND,  .player = index );
	write_byte( flags );
	write_byte( clamp_byte( floatround( vol ) ) );
	write_byte( clamp_byte( floatround( atten ) ) );
	write_byte( channel );
	write_byte( index );
	write_byte( sound_index );
	write_coord(0);
	write_coord(0);
	write_coord(0);
	write_byte(pitch);
	write_byte(0);
	message_end();	
}
what am I doing wrong? this is what i have done so far and the game ends when i run it

Last edited by Matias_Esf; 07-06-2022 at 23:56.
Matias_Esf is offline
 



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 09:24.


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