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

Solved how to use SVC_SOUND?


Post New Thread Reply   
 
Thread Tools Display Modes
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
Mistrick
Senior Member
Join Date: Aug 2012
Location: Russia
Old 07-06-2022 , 20:46   Re: how to use SVC_SOUND?
Reply With Quote #2

AMXX doesn't have API for bits in messages.
https://github.com/dreamstalker/rehl....cpp#L740-L753
Use rh_emit_sound2 from reapi
Mistrick is offline
Matias_Esf
Junior Member
Join Date: May 2012
Location: Argentina
Old 07-06-2022 , 23:56   Re: how to use SVC_SOUND?
Reply With Quote #3

Quote:
Originally Posted by Mistrick View Post
AMXX doesn't have API for bits in messages.
https://github.com/dreamstalker/rehl....cpp#L740-L753
Use rh_emit_sound2 from reapi

uhh..ok, thanks for answering
Matias_Esf 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 06:59.


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