Facebook Twitter YouTube Frictional Games | Forum | Newsletter | Dev Blog | Dev Wiki | Support


Thread Closed 
 
Thread Rating:
  • 2 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Advanced script widgets
Author Message
Apjjm Offline
Super Moderator

Posts: 482
Joined: Apr 2011
Reputation: 49
Post: #13
RE: Advanced script widgets

There is a more flexible concise way to play a random sound:
void playRandomSound(string soundName, string[] sounds, string atEntity, float fadeTime, bool saveSound)
{
  //Select a random index from the array
  int rand = RandInt(0,sounds.length()-1);
  //Play the sound at that index with the given settings
  PlaySoundAtEntity(soundName, sounds[rand], atEntity, fadeTime, saveSound);
}
Usage could be something like:
//Idea 1:
void someFunction()
{
  string[] mySounds = {"Sound1.snt","Sound2.snt","randomSound.snt","Magic.snt"};
  playRandomSound("Random",mySounds,"Player",0.5f,false);
}
//Idea 2:
string[] levelSounds = {"Sound1.snt","Sound2.snt","randomSound.snt","Magic.snt"};
void OtherCodeHere() {}
void someScriptCollisionCallback(string &in asParent, string &in asChild, int alStat)
{
  playRandomSound("Random",levelSounds,asChild,0.5f,false);
}
Void MoreCodeHere() {}
But nice list, i may have one or two neat little scripts i can dig out.
(This post was last modified: 04-27-2011 09:23 PM by Apjjm.)
04-27-2011 09:21 PM
Find all posts by this user
Thread Closed 


Messages In This Thread
Advanced script widgets - palistov - 04-24-2011, 01:22 AM
RE: Script widgets for new modders! - Kyle - 04-24-2011, 02:11 AM
RE: Script widgets for new modders! - Kyle - 04-24-2011, 02:37 AM
RE: Script widgets for new modders! - Kyle - 04-24-2011, 03:06 AM
RE: Advanced script widgets - laser50 - 04-24-2011, 09:27 AM
RE: Advanced script widgets - Kyle - 04-24-2011, 11:11 AM
RE: Advanced script widgets - teddifisk - 04-25-2011, 09:10 PM
RE: Advanced script widgets - palistov - 04-26-2011, 03:43 PM
RE: Advanced script widgets - Exostalker - 04-26-2011, 05:22 PM
RE: Advanced script widgets - Apjjm - 04-27-2011 09:21 PM
RE: Advanced script widgets - palistov - 04-27-2011, 10:01 PM
RE: Advanced script widgets - Simpanra - 05-01-2011, 10:31 PM



User(s) browsing this thread: 1 Guest(s)