Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 2 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Advanced script widgets
Apjjm Offline
Is easy to say

Posts: 496
Threads: 18
Joined: Apr 2011
Reputation: 52
#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


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



Users browsing this thread: 3 Guest(s)