Jump to content
Sign in to follow this  
lonesoldier

Making a random script

Recommended Posts

Ok here my prob:

I have 4 radio sounds. I need a script that will cycle through those sounds each time it is activated.

For example i activate it first time and it plays sound 4, then i activate it again and it plays sound 1, then i activate it again and it plays sound 3, then activate again and plays sound 2. I want it to cycle randomly one sound per activation. How would i get it to do this.

And i need it to be able to be activated infinite amount of times, as it will probably be activated more than 30 times.

Thanks in advance.

Also heres a script someone made for me for it:

#start

_sound = Random (4)

?(_sound == 0) : goto"play1"

?(_sound == 1) : goto"play2"

?(_sound == 2) : goto"play3"

?(_sound == 3) : goto"play4"

#play1

; can be any radio command

aP SideRadio "gotem"

goto"end"

#play2

aP SideRadio "heshistory"

goto"end"

#play3

aP SideRadio "killconfirmed"

goto"end"

#play4

aP SideRadio "goodbye"

goto"end"

#end

goto"start"

exit

That one only plays the first sound.

heres another one:

#start

? (say == 0) : goto "one"

? (say > 0) : goto "two"

? (say > 1) : goto "three"

? (say > 2) : goto "four"

~0.1

goto "start"

#one

say = say +1

player sideradio "gotem"

goto "exit"

#two

say = say +2

player sideradio "killconfirmed"

goto "exit"

#three

say = say +3

player sideradio "goodbye"

goto "exit"

#four

player sideradio "heshistory"

goto "lastexit"

#exit

exit

#lastexit

say = 0

exit

Thats the scond one. And it plays the first sound, then the second sound and keeps playing the second sound each time its activated.

Also another question. How do i get the game to detect each time someone on EAST side is killed? And every time one is killed it activates that script.

Heres how someone made it for me, but it only works on the odd occasion:

Trigger 1:

Condition: this

Activation: countunits = thislist

Second Trigger:

condition: ("not alive _x" count Countunits) > 0

Activation: [] exec "voices.sqs"

Voices.sqs is that script.

Thanks in advance. i need a reply ASAP as this is as far as i can go in the mission at this point in time, until my prob is fixed.

Share this post


Link to post
Share on other sites

OK, for your random number creation use this:

_sound = random 4

_sound = _sound - (_sound mod 1)

this creates 4 different "whole numbers":

0, 1, 2, 3

Now just use your conditions this way:

?(_sound == 0) : goto"play1"

?(_sound == 1) : goto"play2"

?(_sound == 2) : goto"play3"

?(_sound == 3) : goto"play4"

---------------------------------------

Now to the 1 east got killed detection;

Use a trigger:

East/present (size as big as it covers the whole eastern troops)

Name the trigger by it's name field: triggerA

Now put somewhere else the list of this trigger into

a string: countall=count (list triggerA)

Now, setup another trigger (range 0/0)/repeatedly

condition: count (list triggerA) < countall

activation: [] exec "voices.sqs"; countall=count (list triggerA)

P.S: i haven't testet it yet, but it should work - i'll try it

later aswell for myself and post any results in here

~S~ CD

Share this post


Link to post
Share on other sites

Thanks mate. biggrin.gif. Ill test, then post what happens. Cheers.

Oh also, for that bit of script you posted, where abouts in that other script do i replace with what you provided? Could you maybe edit the whole script i posted and post it here, because i SUCK at scripting.

Thanks.

Share this post


Link to post
Share on other sites

OFP's random function seems to be normally distributed. so values in the median will get called more often.(in your case 2)

if you just use "random 4" then no "_sound=_sound mod 1" you can also use this

?(_sound >= 0 && _sound<1) : goto"play1"

?(_sound >= 1 && _sound<2) : goto"play2"

?(_sound >= 2 && _sound<3) : goto"play3"

?(_sound >= 3 && _sound<4) : goto"play4"

just a tip. smile.gif

Share this post


Link to post
Share on other sites

OK, here's the new script:

_sound = random 4

_sound = _sound - (_sound mod 1)

?(_sound == 0) : aP SideRadio "gotem"

?(_sound == 1) : aP SideRadio "heshistory"

?(_sound == 2) : aP SideRadio "killconfirmed"

?(_sound == 3) : aP SideRadio "goodbye"

exit

You see, i've removed your goto's, because there's

no need for them in this nolooping script.

Ralph - off course he could use the from-to range definition,

but then again we should ask ourselves: why makin things

easy, if we can do them complicated aswell? tounge.gif

~S~ CD

Share this post


Link to post
Share on other sites

Thanks very much mate!!!

If you wanna beta test it sometime, just to check it out then message me or something and ill give you think URL for it.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×