Author Topic: Playing A Sound  (Read 954 times)

Yo, how do you play a sound that does not loop?

Be more specific? Server-sided, client-sided? To a single client, all clients?

Be more specific? Server-sided, client-sided? To a single client, all clients?
Server sided to a single client.

I recall it is done like this:

clientObject.play2D(SoundDatablock)

I recall it is done like this:

clientObject.play2D(SoundDatablock)
Can other people hear an items sound when it's equipped?

Can other people hear an items sound when it's equipped?
in the weapons state section
Code: [Select]
stateSound[0] = weaponSwitchSound;remove this line
Code: [Select]
stateScript[0] = "onActivate";add this line

then add this

Code: [Select]
function ImageName::onActivate(%this,%obj,%slot)
{
%Client = %Obj.Client;
%Client.play2D(SoundDatablock)
Parent::onActivate(%this,%obj,%slot);
}

in the weapons state section
Code: [Select]
stateSound[0] = weaponSwitchSound;remove this line
Code: [Select]
stateScript[0] = "onActivate";add this line

then add this

Code: [Select]
function ImageName::onActivate(%this,%obj,%slot)
{
%Client = %Obj.Client;
%Client.play2D(SoundDatablock)
Parent::onActivate(%this,%obj,%slot);
}
Why not just answer my question?

Can other people hear an items sound when it's equipped?
Normally yes, which kinda ruins a lot of stealth missions. More than once I've heard someone pull a weapon, and I whipped around and shot them dead.

Normally yes, which kinda ruins a lot of stealth missions. More than once I've heard someone pull a weapon, and I whipped around and shot them dead.
So how would I make it play a sound to everyone within the same radius as a normal weapon's?

So how would I make it play a sound to everyone within the same radius as a normal weapon's?
The line that he said to replace is the line that plays the normal weapon switch sound.
Note that a few weapons do not have switch sounds either due to scripting errors or stealth reasons.

A client-side sound could be pretty odd.
Since you would expect others to hear it too.

However, this is just my opinion on it, you are free to check it out of course.
If it is something that is not like a weapon switch sound or a reload sound, then it might just work out all fine.
Otherwise i advise strongly to not make it client-side.