Home   Help Search Login Register  

Author Topic: car radio  (Read 1055 times)

0 Members and 1 Guest are viewing this topic.

Offline Gruntage

  • Missions Depot
  • Administrator
  • *****
  • How do I get outta this chickensh*t outfit?
car radio
« on: 20 Mar 2010, 17:27:12 »
Ello guys

Ive been tryin to get a music player to work when the player is in a car. I need the script to be activated from an addaction like:

Code: [Select]
radio = player addaction ["Turn radio on","radio.sqs"]
But i cant get the radio to turn off when the player leaves the vehicle. Also the music needs to be random, not just 1 track playing.

Thx in advance

gruntage
"But one thing I can tell you from not just OFP but life in general:  criticism is directly proportional to quality. The more criticism a mission receives, the better the outcome" - macguba

Offline Krieg

  • Mission Maker
  • Members
  • *
  • Who dares wins.
Re: car radio
« Reply #1 on: 20 Mar 2010, 19:13:56 »
I think you might need separate scripts.

Code: ("Musiccar1.sqs") [Select]
#loop
?(player in car1) : goto "add"
~0.01
goto "loop"

#add
player addAction ["Turn on the car radio", "radio.sqs"]
exit

Code: ("Musiccar2.sqs") [Select]
#loop
?!(player in car1) : goto "rem"
~0.01
goto "loop"

#rem
player removeAction 0
this exec "Musiccar3.sqs"
exit

Code: ("Musiccar3.sqs") [Select]
0.1 fadeMusic 0
player removeAction 0
this exec "Musiccar1.sqs"
exit

Code: ("radio.sqs") [Select]
_random = random 11
_a = _random - (_random mod 1)

player removeAction 0
player addAction ["Turn off the car radio", "Musiccar3.sqs"]

~(random 3)

?(_a == 1) : goto "1"
?(_a == 2) : goto "2"
?(_a == 3) : goto "3"
?(_a == 4) : goto "4"
?(_a == 5) : goto "5"
?(_a == 6) : goto "6"
?(_a == 7) : goto "7"
?(_a == 8) : goto "8"
?(_a == 9) : goto "9"
?(_a == 10) : goto "10"
?(_a == 11) : goto "11"

#1
playMusic "res1a"
exit

#2
playMusic "res1b"
exit

#3
playMusic "res2"
exit

#4
playMusic "res3"
exit

#5
playMusic "res4"
exit

#6
playMusic "res5"
exit

#7
playMusic "res6"
exit

#8
playMusic "res7"
exit

#9
playMusic "res8"
exit

#10
playMusic "res9"
exit

#11
playMusic "res10"
exit

Note that "radio.sqs" will play only Resistance soundtracks. The script is easily modifiable, so modify it to suit your needs.

Edit: Found few bugs, fixed the scripts.

Hope that helps,
Krieg
« Last Edit: 21 Mar 2010, 09:21:08 by Krieg »
If you see a light at the end of the tunnel, then it's probably an enemy tank.