mariuswww Posted January 7, 2014 Report Share Posted January 7, 2014 I would like to make the BMA script (AFA script) play a random sound file (from a list of "Const char" ) when the BMA is triggered. How would I go about doing that? For now its like this if (Audio == 0)Audio::PlaySample(PfadAudio); if (Audio3D == 0){int x;x = Audio::PlaySample3D(PfadAudio3D, go->GetPosition());}My question is basicly what do I put to make it select a random sound of the Const char list? Quote Link to comment Share on other sites More sharing options...
The Loot Posted January 7, 2014 Report Share Posted January 7, 2014 if (Audio == 0) { int random = Math::rand()%5; if (random == 0) Audio::PlaySample(Sound1); else if (random == 1) Audio::PlaySample(Sound2); else if (random == 2) Audio::PlaySample(Sound3); else if (random == 3) Audio::PlaySample(Sound4); else Audio::PlaySample(Sound5); } if (Audio3D == 0) { int x; int random = Math::rand()%5; if (random == 0) x = Audio::PlaySample3D(Sound3D1, box->GetPosition(), true); else if (random == 1) x = Audio::PlaySample3D(Sound3D2, box->GetPosition(), true); else if (random == 2) x = Audio::PlaySample3D(Sound3D3, box->GetPosition(), true); else if (random == 3) x = Audio::PlaySample3D(Sound3D4, box->GetPosition(), true); else x = Audio::PlaySample3D(Sound3D5, box->GetPosition(), true); box->SetUserData(x); } Quote Link to comment Share on other sites More sharing options...
mariuswww Posted January 7, 2014 Author Report Share Posted January 7, 2014 if (Audio == 0){ int random = Math::rand()%5; if (random == 0) Audio::PlaySample(Sound1); else if (random == 1) Audio::PlaySample(Sound2); else if (random == 2) Audio::PlaySample(Sound3); else if (random == 3) Audio::PlaySample(Sound4); else Audio::PlaySample(Sound5);}if (Audio3D == 0){ int x; int random = Math::rand()%5; if (random == 0) x = Audio::PlaySample3D(Sound3D1, box->GetPosition(), true); else if (random == 1) x = Audio::PlaySample3D(Sound3D2, box->GetPosition(), true); else if (random == 2) x = Audio::PlaySample3D(Sound3D3, box->GetPosition(), true); else if (random == 3) x = Audio::PlaySample3D(Sound3D4, box->GetPosition(), true); else x = Audio::PlaySample3D(Sound3D5, box->GetPosition(), true); box->SetUserData(x);}Wow fast reply! Thank you very much, I cant test right now but ill try asap when I get home Quote Link to comment Share on other sites More sharing options...