Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

FPSC Classic Scripts / Is it possible for a script to play a random sound out of several choices?

Author
Message
The Master D
15
Years of Service
User Offline
Joined: 20th Feb 2009
Location:
Posted: 18th Nov 2012 19:21
Hey everybody, I've been gone for a while now, and I'm finally getting back into FPSC, and I'm working on the sound/script parts of everything. I want to be able to give a choice of, let's say five, different recordings to be played when I pick up a new weapon, is it possible to be able to script that? If so, can someone help me out? I've been pulling my hair out over the past couple days trying to figure this out, and any help is massively appreciated!

In Matrix, you bend spoon.
In Soviet Russia, spoon bends you.
BlackFox
FPSC Master
16
Years of Service
User Offline
Joined: 5th May 2008
Location: Knight to Queens Bishop 3
Posted: 18th Nov 2012 19:51
Use the "random=x" command.

Quote: "RANDOM=X is true when a random value between 0 and X is equal to one"


For example, using a pickup script:




There's no problem that can't be solved without applying a little scripting.
The Master D
15
Years of Service
User Offline
Joined: 20th Feb 2009
Location:
Posted: 18th Nov 2012 20:07
So if I were to just use that script and just put in my sound file where you said YOURSOUND, it would work fine?

In Matrix, you bend spoon.
In Soviet Russia, spoon bends you.
BlackFox
FPSC Master
16
Years of Service
User Offline
Joined: 5th May 2008
Location: Knight to Queens Bishop 3
Posted: 18th Nov 2012 20:17
Quote: "So if I were to just use that script and just put in my sound file where you said YOURSOUND, it would work fine?"


Yes. Here is an example test script I used to ensure it works:

pickup_randomsound.fpi



I attach to the item(s) main script (ensure they are dynamic). 5 items were placed and each time I picked up an item, the sound was random. You can either use "sound=x" or "plrsound=x".


There's no problem that can't be solved without applying a little scripting.
The Master D
15
Years of Service
User Offline
Joined: 20th Feb 2009
Location:
Posted: 18th Nov 2012 20:20
Alright, I understand it now. Thanks man! That was a huge help

In Matrix, you bend spoon.
In Soviet Russia, spoon bends you.

Login to post a reply

Server time is: 2024-11-23 19:19:14
Your offset time is: 2024-11-23 19:19:14