OFPEC Forum
Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting Multiplayer => Topic started by: LurchiDerLurch 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
-
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)
-
init.sqf
AAS_PublicSound = "";
clientOnly.sqf
"AAS_PublicSound" addPublicVariableEventHandler
{
_soundSource = (_this select 1) select 0;
_sound = (_this select 1) select 1;
_soundSource say _sound;
};
yourScriptCallingTheSound.sqf
_soundsource = "HeliHEmpty" createVehicle (position player);
_sound = "MySoundFile";
AAS_PublicSound = [_soundsource,_sound];
publicVariable "AAS_PublicSound";
_soundsource say _sound;
-
init.sqf
public string AAS_PublicSound = "";
clientOnly.sqf
"AAS_PublicSound" addPublicVariableEventHandler
{
_soundSource = (_this select 1) select 0;
_sound = (_this select 1) select 1;
_soundSource say _sound;
};
yourScriptCallingTheSound.sqf
_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:
-
Say is played at the objects' location. So if you are far away, you won't hear it.
http://community.bistudio.com/wiki/say
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.
-
@kju
what is this public string?
I've never heard of this and couldn't find anything on it on the wiki.
-
Ups sorry. It is a convention introduced by CoolBox.
#define public
#define string
So its an empty replacement. They are to help reading code.