Jump to content
Sign in to follow this  
kakagoegie

car radio

Recommended Posts

Ok guys here is the plan. I'm making a MP mission where I want all cars/trucks to have a car radio. I want them to be able to play all the music from 7th via the action menu. Now i got 4 problems.

1) I only want the driver of the car to be able to use the radio. Does anybody now a code line, so only the driver of a vehicle "gets" the action menu. The action menu should only appear to the driver of the car.

2) I want to define the 7th music as sound so 2 cars can listen 2 different songs at the same time. Also if you get out of the car, you can still hear the music a bit until you're enough away. I now got something like this:

Quote[/b] ]

class CfgSounds

{

class 7thdecide

{

name = "";

sound[] = {"7thdecide.ogg", db+0, 1.0};

};

But the name 7thdecide.ogg is wrong. What name should I put there so the music from the Music.pbo is used.

3) This isn't exactly a problem. But I think you can do it a more handy way. In my way i need about 8 scripts for the car radio.

This is the radio.sqs

Quote[/b] ]

player removeaction car radio

player addaction ["7th - decide","7thdecide.sqs"]

player addaction ["7th - darken","7thdarken.sqs"]

player addaction ["7th - lifeless","7thlifeless.sqs"]

etc.

Now in my way if you for example click 7th - decide. You would get the 7thdecide.sqs:

Quote[/b] ]

*the vehicle where the player is in* say "7thdecide"

player removeaction 7th - decide

player removeaction 7th - darken

player removeaction 7th - lifeless

etc.

player addaction ["car radio","radio.sqs"]

I know this can be put in 1 script, I just don't know how.

4) What should I put at *the vehicle where the player is in*, see question 3

Thank you for reading, I hope you can help me!

Share this post


Link to post
Share on other sites
Guest The Cobra
But the name 7thdecide.ogg is wrong. What name should I put there so the music from the Music.pbo is used.
Here are the music-track names (if anyone needs to know):

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

track1

track2

track3

track4

track5

track6

track7

track8

track9

track10

track11

track12

track13

track14

track15

track16

track17

rtrack1a

rtrack1b

rtrack2

rtrack3

rtrack4

rtrack5

rtrack6

rtrack7

rtrack8

rtrack9

rtrack10

7thoverdose

7thlifeless

7thimgonnafly

7thdecide

7thdarken

7thmylife

-->7thdecide<--

Maybe it isn't in .ogg format?

huh.gif

Share this post


Link to post
Share on other sites
Quote[/b] ]class CfgSounds

{

class 7thdecide

{

name = "";

sound[] = {"7thdecide", db+0, 1.0};

};

I tried this too, it won't work.

Share this post


Link to post
Share on other sites

The actual path for the songs can be found by snooping around in the official config<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> class 7thDecide

{

name = $STR_CFG_MUSIC_7TH_DECIDE;

sound[] = {\Music\Seventh_decide.ogg, db+0, 1.0};

};

class 7thIAmGonaFly

{

name = $STR_CFG_MUSIC_7TH_IAMGONAFLY;

sound[] = {\Music\Seventh_iamgonnafly.ogg, db+0, 1.0};

};

class 7thLifeless

{

name = $STR_CFG_MUSIC_7TH_LIFELESS;

sound[] = {\Music\Seventh_lifeless.ogg, db+0, 1.0};

};

class 7thOverdose

{

name = $STR_CFG_MUSIC_7TH_OVERDOSE;

sound[] = {\Music\Seventh_overdose.ogg, db+0, 1.0};

};

Share this post


Link to post
Share on other sites

Well now, I have this in the discription.ext:

Quote[/b] ]class CfgSounds

{

sounds[] = { Seventh_iamgonnafly};

class Seventh_iamgonnafly

{

name = $STR_CFG_MUSIC_7TH_IAMGONAFLY;

sound[] = {"\Music\Seventh_iamgonnafly.ogg", db+20, 1.0};

titles[] =

{

};

But it doesn't seem to work. I don't get an error message. But when i put a trigger with: radio say "Seventh_iamgonnafly", I just don't hear any music. So plz help me.

Share this post


Link to post
Share on other sites

Just guessing:

cfgSounds in a mission description.ext only accepts soundfiles of \missionfolder\sound

So maybe it searches at \missionfolder\sound\Music\Seventh_iamgonnafly.ogg for the ogg.

Using original music as sound without extracting/pboing it for your mission file won't be possible then.

But maybe you can play music only for clients inside the car at least. For that you won't need a own cfgMusic class, as the official music tracks are already defined as cfgMusic.

You can try if your description and scripts a correct with a small example .ogg you place inside \missionfolder\sound

Share this post


Link to post
Share on other sites

Isn't there a way, so it won't search in the music map, but in the music.pbo??

Share this post


Link to post
Share on other sites

I don't think so.

More guessing:

Ogg files inside the music.pbo are already defined in the config.cpp(?) of the .pbo

Thats why you can call them in the mission.sqm without the need for a description.ext. You just have to know the classname.

You want to use an .ogg as soundclass thats only defined as musicclass.

Maybe a small addon (just a config file) could define "\Music\Seventh_iamgonnafly.ogg" also as an available soundclass.

But I'dont know much about addonmaking, its just speculation.

Share this post


Link to post
Share on other sites
Guest The Cobra

Why dont you make a script with addevent handlers?

Like when the script detect that the vehicle has a driver, the driver get some choices pop up, and for example; "Start Radio", when you done that you can "Play 7th - Decide"...

Sorry, but I don't know how to do this, but I know it's possible.

smile_o.gif

Share this post


Link to post
Share on other sites

Also, bear in mind that CfgSounds in OFP have to be mono, where as all music is stereo.

If you want to play it as a sound (so it sounds like it's coming out of the car radio) you'll need to actually grab the music file out of the .pbo, strip it down to mono and include it in your mission folder.

The alternative is to just play music... eg:

Quote[/b] ]

player removeaction car_radio1

player removeaction car_radio2

player removeaction car_radio3

car_radio1 = player addaction ["7th - decide","7thdecide.sqs"]

car_radio2 = player addaction ["7th - darken","7thdarken.sqs"]

car_radio3 = player addaction ["7th - lifeless","7thlifeless.sqs"]

7thdecide.sqs

player removeaction car_radio1

0 fademusic 1

playmusic "7thdecide"

@ (vehicle player == player)    <- player gets out of car

player removeaction car_radio2

player removeaction car_radio3

0 fademusic 0

...

Something like that would do the trick...

Share this post


Link to post
Share on other sites

But this will mean that every player will hear the sound. Even if he's not in the same vehicle?

Share this post


Link to post
Share on other sites

Ahhh... multiplayer editing. Not my strongest suit unfortunately...

However, I think as long as the script is only run on the player that's using the radio (ie. not on the server) then only that player should hear the music. (Correct me if I'm full of it, anyone wink_o.gif ).

If you wanted everyone in the vehicle to hear it, that would be a bit more complicated...

Share this post


Link to post
Share on other sites

It's easy to make only some players hear the music, but if player 1 drives the car alone and turns on music, and picks up player 2, it will be hard, if even possible, to play the music for both of them, and at the same spot. You could start a new song from the start, but that would sound really bad since no radio station just suddenly stops playing 1 track just to play another one tounge2.gif

Share this post


Link to post
Share on other sites

I've made the scripts a bit easier. I don't want to use sounds any more. I'll just use music. So here is what I got for so far:

I got a group of soldiers called "groupje".

And a car called "radio".

I have a trigger with condition

Quote[/b] ](driver radio)==(leader groupje)

and on activation

Quote[/b] ]m0=radio addaction ["radio","radio.sqs"]

Another trigger has in condition

Quote[/b] ](vehicle (leader groupje) == (leader groupje))

and on activation

Quote[/b] ]radio removeaction m0

Than I have 8 scripts but I'll only give 2:

radio.sqs:

Quote[/b] ]

(radio) removeaction m0

(radio) removeaction m0

m1=radio addaction ["7th - Decide","m1.sqs"]

m2=radio addaction ["7th - I'm Gonna Fly ","m2.sqs"]

m3=radio addaction ["7th - Lifeless","m3.sqs"]

m4=radio addaction ["7th - Overdose","m4.sqs"]

m5=radio addaction ["7th - Darken","m5.sqs"]

m6=radio addaction ["7th - My life","m6.sqs"]

m7=radio addaction ["no music","m7.sqs"]

@ (vehicle (leader groupje) == (leader groupje))

radio removeaction m1

radio removeaction m2

radio removeaction m3

radio removeaction m4

radio removeaction m5

radio removeaction m6

radio removeaction m7

radio removeaction m0

(radio) removeaction m0

and m1.sqs:

Quote[/b] ]

m0=radio addaction ["radio","radio.sqs"]

0.5 fademusic 0.5

radio removeaction m1

radio removeaction m2

radio removeaction m3

radio removeaction m4

radio removeaction m5

radio removeaction m6

radio removeaction m7

playmusic "7thdecide"

@ (vehicle (leader groupje) == (leader groupje))

0 fademusic 0

radio removeaction m0

It works fine I only got a few questions.

1) I will use this in a MP mission. So I got the question, will all players hear the music or only (leader groupje)?

2) Now the only car where the script works is the car called "radio". What can I do to make the script work with any car.

Share this post


Link to post
Share on other sites
Guest The Cobra
Anybody?

OFPEC is your friend.

I don't think moderators like ppl bumbing up their thread. Wait for some1 to answer instead (no offense) smile_o.gif

MP scripting is alot harder though...

Share this post


Link to post
Share on other sites

Sorry about it, but I just godda know this so I can finish my mission. help.gif

Share this post


Link to post
Share on other sites

I'd probably try something like this:

Trigger

Radius: 0,0

Condition: none (repeatedly)

Condition Field: (vehicle player) != player

OnActivation: m0 = player addaction ["Radio","Music.sqs"]

OnDeactivation: 0 fademusic 0; player removeaction m0

Music.sqs

Quote[/b] ]player removeaction m0

m1=player addaction ["7th - Decide","m1.sqs"]

m2=player addaction ["7th - I'm Gonna Fly ","m2.sqs"]

m3=player addaction ["7th - Lifeless","m3.sqs"]

m4=player addaction ["7th - Overdose","m4.sqs"]

m5=player addaction ["7th - Darken","m5.sqs"]

m6=player addaction ["7th - My life","m6.sqs"]

m7=player addaction ["no music","m7.sqs"]

@ (vehicle player) == player

player removeaction m1

player removeaction m2

player removeaction m3

player removeaction m4

player removeaction m5

player removeaction m6

player removeaction m7

player removeaction m0

And have your other music scripts etc...

Something along those lines should do the trick, but I"m not sure what fun things testing that in MP would bring up :P

Good luck with it wink_o.gif

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  

×