Home   Help Search Login Register  

Author Topic: Play a sound public  (Read 2161 times)

0 Members and 1 Guest are viewing this topic.

Offline LurchiDerLurch

  • Members
  • *
Play a sound public
« on: 19 Apr 2010, 21:48:35 »
Hello everyone!

I need to know how I can play a sound that everybody can hear (or not if he's too far away!)

playSound "sound"; -this is local or not?
unit say "sound"; -local? or global?
sound = createSoundSource ["sound",position Player,[],10]; - isn't working for me

Lurchi

Offline Loyalguard

  • Former Staff
  • ****
Re: Play a sound public
« Reply #1 on: 19 Apr 2010, 23:46:52 »
playSound is not local.  It will play the sound at every player location so you can be on the other side of the map and you will hear it as if you are right next to the sound.

Say will make the unit "say" the sound only as loud as defined in CfgSounds in the descriptiopn.ext or #include so you have to be relatively close to hear it.  So it is local per se, but the unit saying the sound does not have to be local to the player hearing it.

createSoundSource will only play sounds from class sound inside CfgVehicles.  So unless you choose one of those predefined sounds, or create your own via an addon, it will not play a sound (and may cause errors I assume)

Offline kju

  • Members
  • *
    • PvPScene - The ArmA II multiplayer community
Re: Play a sound public
« Reply #2 on: 20 Apr 2010, 09:53:39 »
init.sqf
Code: [Select]
AAS_PublicSound = "";
clientOnly.sqf
Code: [Select]
"AAS_PublicSound" addPublicVariableEventHandler
{
_soundSource = (_this select 1) select 0;
_sound = (_this select 1) select 1;
_soundSource say _sound;
};

yourScriptCallingTheSound.sqf
Code: [Select]
_soundsource = "HeliHEmpty" createVehicle (position player);
_sound = "MySoundFile";
AAS_PublicSound = [_soundsource,_sound];
publicVariable "AAS_PublicSound";
_soundsource say _sound;
« Last Edit: 21 Apr 2010, 07:35:42 by kju »

Offline LurchiDerLurch

  • Members
  • *
Re: Play a sound public
« Reply #3 on: 20 Apr 2010, 10:17:21 »
init.sqf
Code: [Select]
public string AAS_PublicSound = "";
clientOnly.sqf
Code: [Select]
"AAS_PublicSound" addPublicVariableEventHandler
{
_soundSource = (_this select 1) select 0;
_sound = (_this select 1) select 1;
_soundSource say _sound;
};

yourScriptCallingTheSound.sqf
Code: [Select]
_soundsource = "HeliHEmpty" createVehicle (position player);
_sound = "MySoundFile";
AAS_PublicSound = [_soundsource,_sound];
publicVariable "AAS_PublicSound";
_soundsource say _sound;

This will play the sound global - every player can hear this, right?

So the effect should be the same:

playSound is not local.  It will play the sound at every player location so you can be on the other side of the map and you will hear it as if you are right next to the sound.

Correct me if I'm wrong  :dunno:

Offline kju

  • Members
  • *
    • PvPScene - The ArmA II multiplayer community
Re: Play a sound public
« Reply #4 on: 20 Apr 2010, 14:19:46 »
Say is played at the objects' location. So if you are far away, you won't hear it.

http://community.bistudio.com/wiki/say

Quote
If the camera is not within given range, title is not shown and the sound will not be heard.

You could optimize the script for MP to make a check if any isPlayer unit is close enough before calling the PV.

Offline ModestNovice

  • Members
  • *
Re: Play a sound public
« Reply #5 on: 21 Apr 2010, 00:43:11 »
@kju
what is this public string?

I've never heard of this and couldn't find anything on it on the wiki.
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley

Offline kju

  • Members
  • *
    • PvPScene - The ArmA II multiplayer community
Re: Play a sound public
« Reply #6 on: 21 Apr 2010, 07:35:25 »
Ups sorry. It is a convention introduced by CoolBox.

#define public
#define string

So its an empty replacement. They are to help reading code.