Custom music script

Post » Mon Mar 14, 2011 5:35 pm

I need a script for playing custom music, when the player is inside certain cells. Also, I need it to loop and not to end half-way when exiting the cell/s (meaning it has to play fully before it can change into "normal" music). Anyone?

EDIT: I think I will remove the Vanilla music completely from the island I am working on, so it'll play only my custom music.
User avatar
Eoh
 
Posts: 3378
Joined: Sun Mar 18, 2007 6:03 pm

Post » Tue Mar 15, 2011 2:27 am

You want the http://cs.elderscrolls.com/constwiki/index.php/StreamMusic command. I've done this before once. Put the script on a dummy item in the cell and use something like this (I haven't scripted Oblivion in a while so it may be a bit off, the last scripting I did was for Morrowind):
Begin GameModefloat timerif timer >= [length of song in seconds]StreamMusic [song file]set timer to 0elseset timer to ( timer + GetSecondsPassed )endifend


Sorry about the lack of indents, I'm doing this straight into the forum.
User avatar
Rhi Edwards
 
Posts: 3453
Joined: Fri Jul 28, 2006 1:42 am

Post » Mon Mar 14, 2011 11:34 pm

You want the http://cs.elderscrolls.com/constwiki/index.php/StreamMusic command. I've done this before once. Put the script on a dummy item in the cell and use something like this (I haven't scripted Oblivion in a while so it may be a bit off, the last scripting I did was for Morrowind):
Begin GameModefloat timerif timer >= [length of song in seconds]StreamMusic [song file]set timer to 0elseset timer to ( timer + GetSecondsPassed )endifend


Sorry about the lack of indents, I'm doing this straight into the forum.


Didn't work :D And it works once (and then again after a minute or so) if I do via console.
User avatar
Isaac Saetern
 
Posts: 3432
Joined: Mon Jun 25, 2007 6:46 pm

Post » Tue Mar 15, 2011 5:15 am

So, maybe the script just needs perfecting. But I have tried all sorts of things :D Hasn't quite worked out yet.
User avatar
Leanne Molloy
 
Posts: 3342
Joined: Sat Sep 02, 2006 1:09 am

Post » Mon Mar 14, 2011 10:08 pm

Could someone please perfect the script? I really need it.
User avatar
Steven Nicholson
 
Posts: 3468
Joined: Mon Jun 18, 2007 1:24 pm

Post » Mon Mar 14, 2011 10:32 pm

Bump...
User avatar
ruCkii
 
Posts: 3360
Joined: Mon Mar 26, 2007 9:08 pm

Post » Tue Mar 15, 2011 1:46 am

Bump, once again :D
User avatar
Jonathan Montero
 
Posts: 3487
Joined: Tue Aug 14, 2007 3:22 am

Post » Mon Mar 14, 2011 6:49 pm

Realised this was a bit rubbish. See if this works:

float TimerBegin OnLoadset Timer to [length of song in seconds]endBegin GameModeif timer >= [length of song in seconds]StreamMusic [song file]set timer to 0elseset timer to ( timer + GetSecondsPassed )endifend

User avatar
Jeffrey Lawson
 
Posts: 3485
Joined: Tue Oct 16, 2007 5:36 pm

Post » Mon Mar 14, 2011 1:39 pm

FYI: StreamMusic is finnicky and may not work. It's a rather incomplete and buggy feature that isn't even officially supported.
User avatar
Alister Scott
 
Posts: 3441
Joined: Sun Jul 29, 2007 2:56 am

Post » Mon Mar 14, 2011 1:56 pm

Use the mod which allows you to do it :) can't remember the name but ask around for it.
User avatar
JERMAINE VIDAURRI
 
Posts: 3382
Joined: Tue Dec 04, 2007 9:06 am

Post » Mon Mar 14, 2011 2:57 pm

Use the mod which allows you to do it :) can't remember the name but ask around for it.

No no, I will publish the mod this is for so I will need to do it by myself. With a little help from you fellow forumists :D (Yay, I invented a new word!)
User avatar
Steph
 
Posts: 3469
Joined: Sun Nov 19, 2006 7:44 am

Post » Mon Mar 14, 2011 8:22 pm

I've never had problems with StreamMusic, or at least not in the simple script I illustated. Try prehaps making a silent song to stream to clear all music and play the music as a sound if that doesn't work.
User avatar
Brandi Norton
 
Posts: 3334
Joined: Fri Feb 09, 2007 9:24 pm

Post » Tue Mar 15, 2011 1:30 am

I've never had problems with StreamMusic, or at least not in the simple script I illustated. Try prehaps making a silent song to stream to clear all music and play the music as a sound if that doesn't work.

Well, the song starts as soon as it loads, but it doesn't loop. Also, I have currently two songs to play. I added the second song to the script, but as soon as the first is done, vanilla music takes control.
User avatar
ijohnnny
 
Posts: 3412
Joined: Sun Oct 22, 2006 12:15 am

Post » Mon Mar 14, 2011 5:19 pm

Well, the song starts as soon as it loads, but it doesn't loop. Also, I have currently two songs to play. I added the second song to the script, but as soon as the first is done, vanilla music takes control.

Could we see the sript with the two songs?
User avatar
jessica robson
 
Posts: 3436
Joined: Mon Oct 09, 2006 11:54 am

Post » Tue Mar 15, 2011 12:27 am

Could we see the sript with the two songs?

Yep, these are the scripts I have used. Order is ascending date of change.

Spoiler
scriptname aaaForbiddenMusicScript

Begin GameMode

float timer

if player.GetInSameCell ForbiddenMusic37
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

elseif player.GetInSameCell ForbiddenMusic36
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

elseif player.GetInSameCell ForbiddenMusic35
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

elseif player.GetInSameCell ForbiddenMusic34
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

elseif player.GetInSameCell ForbiddenMusic32
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

elseif player.GetInSameCell ForbiddenMusic31
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

elseif player.GetInSameCell ForbiddenMusic30
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

elseif player.GetInSameCell ForbiddenMusic29
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

elseif player.GetInSameCell ForbiddenMusic28
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

elseif player.GetInSameCell ForbiddenMusic27
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

elseif player.GetInSameCell ForbiddenMusic26
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

elseif player.GetInSameCell ForbiddenMusic25
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

elseif player.GetInSameCell ForbiddenMusic24
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

elseif player.GetInSameCell ForbiddenMusic23
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

elseif player.GetInSameCell ForbiddenMusic22
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

elseif player.GetInSameCell ForbiddenMusic21
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

elseif player.GetInSameCell ForbiddenMusic20
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

elseif player.GetInSameCell ForbiddenMusic19
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

elseif player.GetInSameCell ForbiddenMusic18
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

elseif player.GetInSameCell ForbiddenMusic17
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

elseif player.GetInSameCell ForbiddenMusic16
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

elseif player.GetInSameCell ForbiddenMusic15
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

elseif player.GetInSameCell ForbiddenMusic14
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

elseif player.GetInSameCell ForbiddenMusic13
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

elseif player.GetInSameCell ForbiddenMusic12
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

elseif player.GetInSameCell ForbiddenMusic11
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

elseif player.GetInSameCell ForbiddenMusic10
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

elseif player.GetInSameCell ForbiddenMusic9
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

elseif player.GetInSameCell ForbiddenMusic8
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

elseif player.GetInSameCell ForbiddenMusic7
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

elseif player.GetInSameCell ForbiddenMusic6
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

elseif player.GetInSameCell ForbiddenMusic5
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

elseif player.GetInSameCell ForbiddenMusic4
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

elseif player.GetInSameCell ForbiddenMusic3
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

elseif player.GetInSameCell ForbiddenMusic2
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

elseif player.GetInSameCell ForbiddenMusic1
if timer >= 139
StreamMusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif
endif


Spoiler
scriptname aaaForbiddenMusicScript3

float fQuestDelayTime
float timer
short wasInCombat
short Fisplayed


begin gamemode

; Makes the script run every 0.5 second to ensure that the music starts to play pretty fast
set fQuestDelayTime to .5

; If the player is not in this cell, just return
if (player.getInWorldspace "aaForbidIsle"==0)
set timer to -1
return
endif

; Timer counts the time left to start the music again.
set timer to (timer - getSecondsPassed)

; At the instant the player leaves combat, set timer to -1 to start the music again
if (player.IsInCombat)
if (wasInCombat == 0)
set wasInCombat to 1
endif
elseif (wasInCombat)
set wasInCombat to 0
set timer to -1
endif

; If timer 0, the music is still playing, so do nothing
if (timer > 0)
return
endif

; Start music, and set timer equal to music length in seconds
if Fisplayed == 0
Streammusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 165;Length of music, in seconds goes here
set Fisplayed to 1
endif
end


; This part is to make sure it continues the music while in menu mode
; The code is mostly the same, but with no combat check.
begin menumode

; If the player is not in this cell, just return
if (player.getInWorldspace "aaForbidIsle"==0)
set timer to -1
return
endif

; If timer 0, the music is still playing, so do nothing
set timer to (timer - getSecondsPassed)
if (timer > 0)
return
endif

; Start music, and set timer equal to music length in seconds
if Fisplayed == 0
Streammusic "data\music\ForbiddenIsland\Natives.mp3"
set timer to 165
set Fisplayed to 1
endif

if Fisplayed == 1
Streammusic "data\music\ForbiddenIsland\JungleOrchestra.mp3"
set timer to 233
set Fisplayed to 0
endif
end


Spoiler
scn aaaForbiddenMusicScript2

float Timer

Begin onload

set Timer to 139

end

Begin GameMode

if timer >= 139
StreamMusic "music\ForbiddenIsland\Natives.mp3"
set timer to 0
else
set timer to ( timer + GetSecondsPassed )
endif

end


Spoiler
scn aaaForbiddenMusicScript4

float fQuestDelayTime
float Timer
short music1
short music2

Begin OnLoad

if music1 == 1
set Timer to 165
elseif music2 == 1
set timer to 233
endif

end

Begin GameMode

set fQuestDelayTime to 1

if music1 == 1
if timer >= 165
StreamMusic "music\ForbiddenIsland\Natives.mp3"
set timer to 0
set music1 to 0
set music2 to 1
else
set timer to ( timer + GetSecondsPassed )
endif
elseif music2 == 1
if timer >= 233
StreamMusic "music\ForbiddenIsland\JungleOrchestra.mp3"
set timer to 0
set music1 to 1
set music2 to 0
else
set timer to ( timer + GetSecondsPassed )
endif
endif

end


Number one is glitchy and doesn't really work. Number two did work, but not well. Number three works pretty good, but not good enough. Number four - well, let's just say that there is something wrong in there :D I did not really have time to perfect the script, so I posted it here as incomplete. I will go to sleep now though, as it is 1:29 in the morning here...
User avatar
KU Fint
 
Posts: 3402
Joined: Mon Dec 04, 2006 4:00 pm

Post » Mon Mar 14, 2011 5:14 pm

Bumping, along with informing that I have composed a third song. I don't want it to loop with the others, but I want it to loop on it's own.
User avatar
Stephanie Kemp
 
Posts: 3329
Joined: Sun Jun 25, 2006 12:39 am

Post » Tue Mar 15, 2011 12:19 am

Could you tell us what is wrong with script three? Why is it 'not good enough'? If you tell us that we can probably help.
User avatar
Samantha Pattison
 
Posts: 3407
Joined: Sat Oct 28, 2006 8:19 pm

Post » Mon Mar 14, 2011 4:00 pm

Well, the song starts as soon as it loads, but it doesn't loop. Also, I have currently two songs to play. I added the second song to the script, but as soon as the first is done, vanilla music takes control.

As I said before, the songs won't loop. And as soon as the first one is done playing, I hear the Vanilla music.
User avatar
Damned_Queen
 
Posts: 3425
Joined: Fri Apr 20, 2007 5:18 pm

Post » Mon Mar 14, 2011 8:56 pm

I need a script for playing custom music, when the player is inside certain cells. Also, I need it to loop and not to end half-way when exiting the cell/s (meaning it has to play fully before it can change into "normal" music). Anyone?


Unfortunately, the only way to do this is to change the music in the data file.

Just delete ALL oblivion default music and just put the song you want in. That is the most effective and best method for this problem.
User avatar
brandon frier
 
Posts: 3422
Joined: Wed Oct 17, 2007 8:47 pm

Post » Tue Mar 15, 2011 2:05 am

Unfortunately, the only way to do this is to change the music in the data file.

Just delete ALL oblivion default music and just put the song you want in. That is the most effective and best method for this problem.

Well, once I publish the mod, I really wouldn't want to make other people to replace their music files, would I?
User avatar
Harry-James Payne
 
Posts: 3464
Joined: Wed May 09, 2007 6:58 am

Post » Tue Mar 15, 2011 2:47 am

Well, once I publish the mod, I really wouldn't want to make other people to replace their music files, would I?


Sure you can. Just put a txt file with instructions. Tell people to clear their music folder out and copy and paste your music in. They could always store their oblivion vanilla music in another folder if they choose so they can copy and paste the music back in once they've finished with your mod.

My method is 100% effective and works. How many others can say that with 100% certainty?
User avatar
AnDres MeZa
 
Posts: 3349
Joined: Thu Aug 16, 2007 1:39 pm

Post » Tue Mar 15, 2011 2:40 am

Sure you can. Just put a txt file with instructions. Tell people to clear their music folder out and copy and paste your music in. They could always store their oblivion vanilla music in another folder if they choose so they can copy and paste the music back in once they've finished with your mod.

My method is 100% effective and works. How many others can say that with 100% certainty?

Your comments make me lol hard every time... Do I smell a troll here?
User avatar
Devin Sluis
 
Posts: 3389
Joined: Wed Oct 24, 2007 4:22 am

Post » Mon Mar 14, 2011 9:03 pm

Your comments make me lol hard every time... Do I smell a troll here?


A fella like me tries to help and all you can do is show disrespect? How utterly appalling. I actually nearly fainted in disgust!
User avatar
james reed
 
Posts: 3371
Joined: Tue Sep 18, 2007 12:18 am

Post » Mon Mar 14, 2011 1:35 pm

Since StreamMusic is notably unreliable, it could have you chasing your tail in your scripts. Would it be possible to add each song as a sound object instead and use PlaySound maybe? :huh:
User avatar
Destinyscharm
 
Posts: 3404
Joined: Sun Jul 23, 2006 6:06 pm

Post » Mon Mar 14, 2011 4:14 pm

Since StreamMusic is notably unreliable, it could have you chasing your tail in your scripts. Would it be possible to add each song as a sound object instead and use PlaySound maybe? :huh:

Perhaps; I should see into it...
User avatar
Kit Marsden
 
Posts: 3467
Joined: Thu Jul 19, 2007 2:19 pm

Next

Return to IV - Oblivion