Creating a SoundSource will play different sounds locally.
The creation of the source is all synced but the track selected is random to every player present.
Creating a SoundSource will play different sounds locally.
The creation of the source is all synced but the track selected is random to every player present.
What do you mean by track selected? createSoundSource is like createVehicle command only for sounds. When you indicate what sound to create it is created from config globally, therefore it will be the same globally. Unless you have different sounds under the same name on different PCs (which is possible if everyone is running a different mod) this could not happen.
I tested the command just to be sure, executing this on 1 client:
createSoundSource ["Sound_Alarm", position player, [], 0];
plays alarm at the same place on all clients. Could you please provide more information with repro?
Sound_Alarm is defined in cfgVehicles and has a link (sound) to cfgSFX. the CfgSFX Class contains a list of multiple tracks which get selected at random which doesn't get synct.
"sounds[]={ "track01", "track02", "track03"};"
class cfgVehicles
{
class Sound;
class myCustomSound: Sound
{
scope=2; sound="myCustomSound_SFX"; displayName="myCustomSound"; vehicleClass="sounds";
};
};
class CfgSFX
{
class myCustomSound_SFX
{
sounds[]= { "radio01", "radio02", "radio03" }; name="Custom Sound"; radio01[]= { "testsound_01_40sek.ogg", 6, 1, 50, 0.082999997, 0, 0, 0 }; radio02[]= { "testsound_02_40sek.ogg", 6, 1, 50, 0.082999997, 0, 0, 0 }; radio03[]= { "testsound_03_40sek.ogg", 6, 1, 50, 0.082999997, 0, 0, 0 }; empty[]= { "", 0, 0, 0, 0, 0, 0, 0 };
};
};
by creating "myCustomSound" playes can get one of the 3 different tracks(radio01 - radio03) + the empty one.
I have maybe slightly disappointing news, this is not a bug but feature. When more than 1 sound is supplied in sounds[] array, a random sound is picked up and played. In multiplayer every PC would pick its own random sound and this is unlikely to change for the near future.
However the good news is that you as modder or mission designed have a choice how you want to configure your SFX sounds. You can put different sounds under different classnames, 1 for each instead of putting them all in 1 array, then select which sound class you would like to play at random. This will guarantee that the same sound it played everywhere.
For example: createSoundSource [selectRandom ["Sound_Alarm1","Sound_Alarm2","Sound_Alarm3"], position player, [], 0];