Jump to content

Repeat Script Command?


danielj97

Recommended Posts

Hello,

 

Im working on a script to play music, and the way its working is this:

 


Scn aaaMusicSpell
Begin OnActivate
          	StreamMusic "Data\Music\DanielJ97\Carleto Project\1.mp3"
          	StreamMusic "Data\Music\DanielJ97\Carleto Project\2.mp3"
          	StreamMusic "Data\Music\DanielJ97\Carleto Project\3.mp3"
          	StreamMusic "Data\Music\DanielJ97\Carleto Project\4.mp3"
          	StreamMusic "Data\Music\DanielJ97\Carleto Project\5.mp3"
          	StreamMusic "Data\Music\DanielJ97\Carleto Project\6.mp3"
          	StreamMusic "Data\Music\DanielJ97\Carleto Project\7.mp3"
          	StreamMusic "Data\Music\DanielJ97\Carleto Project\8.mp3"
          	StreamMusic "Data\Music\DanielJ97\Carleto Project\9.mp3"       	
End

 

 

Thats what im thinking should manage to run the script, via the player going through a triggerbox and it starts. Im working on that bit ^^

 

But what Im needing just now is some way to get the script to loop itself so the music keeps playing and playing and playing. What will the script be to get this to work?

 

Thanks

Link to comment
Share on other sites

Try this script. It might run indefinately, but I hope that the Begin OnReset block will stop the script on reset. Let me know if if worked or if it helped to point you in the right direction. I will be offline for a few days, but I will look this article up when I get back online. Hopefully making a simple return addition to the bottom of the block will help loop the Begin OnActivate script without having to add timers and a Begin GameMode block.

 

 


Scn aaaMusicSpell

short musicplaying

Begin OnActivate
       if musicplaying == 0
             set music playing to 1
                  if music playing == 1
                        StreamMusic "Data\Music\DanielJ97\Carleto Project\1.mp3"
                        set musicplaying to 2
                  endif
                  if musicplaying == 2
                        StreamMusic "Data\Music\DanielJ97\Carleto Project\2.mp3"
                        set musicplaying to 3
                  endif
                  if musicplaying == 3
                        StreamMusic "Data\Music\DanielJ97\Carleto Project\3.mp3"
                        set musicplaying to 4
                  endif
                  if musicplaying == 4
                        StreamMusic "Data\Music\DanielJ97\Carleto Project\4.mp3"
                        set musicplaying to 5
                  endif
                  if musicplaying == 5
                        StreamMusic "Data\Music\DanielJ97\Carleto Project\5.mp3"
                        set musicplaying to 6
                  endif
                  if musicplaying == 6
                        StreamMusic "Data\Music\DanielJ97\Carleto Project\6.mp3"
                        set musicplaying to 7
                  endif
                  if musicplaying == 7
                        StreamMusic "Data\Music\DanielJ97\Carleto Project\7.mp3"
                        set musicplaying to 8
                  endif
                  if musicplaying == 8
                        StreamMusic "Data\Music\DanielJ97\Carleto Project\8.mp3"
                        set musicplaying to 9
                  endif
                  if musicplaying == 9
                        StreamMusic "Data\Music\DanielJ97\Carleto Project\9.mp3"  
                        set musicplaying to 10
                  endif
                  if musicplaying == 10
                        set musicplaying to 0
                        return
                  endif
         endif
End

Begin onReset
       set musicplaying to 0
End

 

 

Hope this helps,

theuseless

Link to comment
Share on other sites

Try this script. It might run indefinately, but I hope that the Begin OnReset block will stop the script on reset. Let me know if if worked or if it helped to point you in the right direction. I will be offline for a few days, but I will look this article up when I get back online. Hopefully making a simple return addition to the bottom of the block will help loop the Begin OnActivate script without having to add timers and a Begin GameMode block.

 

 


Scn aaaMusicSpell

short musicplaying

Begin OnActivate
       if musicplaying == 0
             set music playing to 1
              	if music playing == 1
                    	StreamMusic "Data\Music\DanielJ97\Carleto Project\1.mp3"
                    	set musicplaying to 2
              	endif
              	if musicplaying == 2
                    	StreamMusic "Data\Music\DanielJ97\Carleto Project\2.mp3"
                    	set musicplaying to 3
              	endif
              	if musicplaying == 3
                    	StreamMusic "Data\Music\DanielJ97\Carleto Project\3.mp3"
                    	set musicplaying to 4
              	endif
              	if musicplaying == 4
                    	StreamMusic "Data\Music\DanielJ97\Carleto Project\4.mp3"
                    	set musicplaying to 5
              	endif
              	if musicplaying == 5
                    	StreamMusic "Data\Music\DanielJ97\Carleto Project\5.mp3"
                    	set musicplaying to 6
              	endif
              	if musicplaying == 6
                    	StreamMusic "Data\Music\DanielJ97\Carleto Project\6.mp3"
                    	set musicplaying to 7
              	endif
              	if musicplaying == 7
                    	StreamMusic "Data\Music\DanielJ97\Carleto Project\7.mp3"
                    	set musicplaying to 8
              	endif
              	if musicplaying == 8
                    	StreamMusic "Data\Music\DanielJ97\Carleto Project\8.mp3"
                    	set musicplaying to 9
              	endif
              	if musicplaying == 9
                    	StreamMusic "Data\Music\DanielJ97\Carleto Project\9.mp3"  
                    	set musicplaying to 10
              	endif
              	if musicplaying == 10
                    	set musicplaying to 0
                    	return
              	endif
         endif
End

Begin onReset
       set musicplaying to 0
End

 

 

Hope this helps,

theuseless

 

Thanks, Ill go and test it. (:

Link to comment
Share on other sites

Try this script. It might run indefinately, but I hope that the Begin OnReset block will stop the script on reset. Let me know if if worked or if it helped to point you in the right direction. I will be offline for a few days, but I will look this article up when I get back online. Hopefully making a simple return addition to the bottom of the block will help loop the Begin OnActivate script without having to add timers and a Begin GameMode block.

 

 


Scn aaaMusicSpell

short musicplaying

Begin OnActivate
       if musicplaying == 0
             set music playing to 1
          		if music playing == 1
                		StreamMusic "Data\Music\DanielJ97\Carleto Project\1.mp3"
                		set musicplaying to 2
          		endif
          		if musicplaying == 2
                		StreamMusic "Data\Music\DanielJ97\Carleto Project\2.mp3"
                		set musicplaying to 3
          		endif
          		if musicplaying == 3
                		StreamMusic "Data\Music\DanielJ97\Carleto Project\3.mp3"
                		set musicplaying to 4
          		endif
          		if musicplaying == 4
                		StreamMusic "Data\Music\DanielJ97\Carleto Project\4.mp3"
                		set musicplaying to 5
          		endif
          		if musicplaying == 5
                		StreamMusic "Data\Music\DanielJ97\Carleto Project\5.mp3"
                		set musicplaying to 6
          		endif
          		if musicplaying == 6
                		StreamMusic "Data\Music\DanielJ97\Carleto Project\6.mp3"
                		set musicplaying to 7
          		endif
          		if musicplaying == 7
                		StreamMusic "Data\Music\DanielJ97\Carleto Project\7.mp3"
                		set musicplaying to 8
          		endif
          		if musicplaying == 8
                		StreamMusic "Data\Music\DanielJ97\Carleto Project\8.mp3"
                		set musicplaying to 9
          		endif
          		if musicplaying == 9
                		StreamMusic "Data\Music\DanielJ97\Carleto Project\9.mp3"  
                		set musicplaying to 10
          		endif
          		if musicplaying == 10
                		set musicplaying to 0
                		return
          		endif
         endif
End

Begin onReset
       set musicplaying to 0
End

 

 

Hope this helps,

theuseless

 

Thanks, Ill go and test it. (:

 

This makes the music stop when I leave the cell :S I want it to play from Activation to forever. So it never ends?

Link to comment
Share on other sites

Maybe try using code in a beginGameMode block. These scripts run forever. If that doesn't work, then try to make a quest script that is initially disabled. Then put the code into the quest script and activate the quest with the activator.

 

 

Activator:

 

scn XXactivatorScriptXX

short doOnce

Begin OnActivate

if doOnce == 0
startquest XXquestXX   ;  <----  set this one to the name of the quest you make
set XXquestXX.busy to 1
set XXquestXX.fQuestDelayTime to 0.1
activate
set doOnce to 1
endif


end


begin onReset    ;remove this if you don't want it to quit on reset

reset3dstate    ;remove this if you don't want it to quit on reset
set doOnce to 0    ;remove this if you don't want it to quit on reset
set XXquestXX.busy to 0    ;remove this if you don't want it to quit on reset
set XXquestXX.pause to 0    ;remove this if you don't want it to quit on reset

end    ;remove this if you don't want it to quit on reset

Put this on the Quest, XXquestXX

 

Scn XXquestScriptXX


short busy
short pause
short musicplaying
float fQuestDelayTime

begin gameMode

;================================

if (busy == 1)
	set pause to -1
	set busy to 0
endif

if (pause == 0)
	stopquest XXquestXX
	;reset conditions here (re-initialize)	
	set busy to 0
	set pause to 0
	set musicplaying to 0

	return
;------------------------------------------------

elseif (pause == -1)
       if musicplaying == 0
             set music playing to 1
                       if music playing == 1
                               StreamMusic "Data\Music\DanielJ97\Carleto Project\1.mp3"
                               set musicplaying to 2
                       endif
                       if musicplaying == 2
                               StreamMusic "Data\Music\DanielJ97\Carleto Project\2.mp3"
                               set musicplaying to 3
                       endif
                       if musicplaying == 3
                               StreamMusic "Data\Music\DanielJ97\Carleto Project\3.mp3"
                               set musicplaying to 4
                       endif
                       if musicplaying == 4
                               StreamMusic "Data\Music\DanielJ97\Carleto Project\4.mp3"
                               set musicplaying to 5
                       endif
                       if musicplaying == 5
                               StreamMusic "Data\Music\DanielJ97\Carleto Project\5.mp3"
                               set musicplaying to 6
                       endif
                       if musicplaying == 6
                               StreamMusic "Data\Music\DanielJ97\Carleto Project\6.mp3"
                               set musicplaying to 7
                       endif
                       if musicplaying == 7
                               StreamMusic "Data\Music\DanielJ97\Carleto Project\7.mp3"
                               set musicplaying to 8
                       endif
                       if musicplaying == 8
                               StreamMusic "Data\Music\DanielJ97\Carleto Project\8.mp3"
                               set musicplaying to 9
                       endif
                       if musicplaying == 9
                               StreamMusic "Data\Music\DanielJ97\Carleto Project\9.mp3"  
                               set musicplaying to 10
                       endif
                       if musicplaying == 10
                               set musicplaying to 0
                               return
                       endif
         endif
End

 

 

 

 

 

 

It may be a little more complex than it needs to be, but it should do the job. I hope.

 

 

-edit-

 

You might need to add a if player.getincell == xxcellxx in order to make it only play in a certain cell. This should be simple enough but I don't have the time to look it up now :( sorry

 

-edit-

 

GetInCellParam CellName ActorID

 

 

is the call name that you need. Add this to the block only if the music plays outside the given cell. change CellName to the cell you wish the music playing in and ActorID to the actor that you want to apply it to (player is the name in this case) Ammend this to the begginning of the quest script's beginGameMode block. Make sure to add another endif if you do so :)

 

Make sure that you don't add too many scripts with BeginGameMode into the same cell. Also try to add as few quests that will run all the time as well, as this detracts from the game's ability to process all the commands. More scripts running = more load on the game engine.

Link to comment
Share on other sites

<br>Maybe try using code in a beginGameMode block.  These scripts run forever.  If that doesn't work, then try to make a quest script that is initially disabled.  Then put the code into the quest script and activate the quest with the activator.<br><br><br>Activator:<br><br>
scn XXactivatorScriptXX<br>
<br>
short doOnce<br>
<br>
Begin OnActivate<br>
<br>
if doOnce == 0<br>
    startquest XXquestXX   ;  <----  set this one to the name of the quest you make<br>
    set XXquestXX.busy to 1<br>
    set XXquestXX.fQuestDelayTime to 0.1<br>
    activate<br>
    set doOnce to 1<br>
endif<br>
<br>
<br>
end<br>
<br>
<br>
begin onReset    ;remove this if you don't want it to quit on reset<br>
<br>
reset3dstate    ;remove this if you don't want it to quit on reset<br>
set doOnce to 0    ;remove this if you don't want it to quit on reset<br>
set XXquestXX.busy to 0    ;remove this if you don't want it to quit on reset<br>
set XXquestXX.pause to 0    ;remove this if you don't want it to quit on reset<br>
<br>
end    ;remove this if you don't want it to quit on reset<br>

<br>Put this on the Quest, XXquestXX<br><br>

Scn XXquestScriptXX<br>
<br>
<br>
short busy<br>
short pause<br>
short musicplaying<br>
float fQuestDelayTime<br>
<br>
begin gameMode<br>
<br>
;================================<br>
<br>
    if (busy == 1)<br>
        set pause to -1<br>
        set busy to 0<br>
    endif<br>
<br>
    if (pause == 0)<br>
        stopquest XXquestXX<br>
        ;reset conditions here (re-initialize)    <br>
        set busy to 0<br>
        set pause to 0<br>
        set musicplaying to 0<br>
<br>
        return<br>
;------------------------------------------------<br>
    <br>
    elseif (pause == -1)<br>
        if musicplaying == 0<br>
              set music playing to 1<br>
                        if music playing == 1<br>
                                StreamMusic "Data\Music\DanielJ97\Carleto Project\1.mp3"<br>
                                set musicplaying to 2<br>
                        endif<br>
                        if musicplaying == 2<br>
                                StreamMusic "Data\Music\DanielJ97\Carleto Project\2.mp3"<br>
                                set musicplaying to 3<br>
                        endif<br>
                        if musicplaying == 3<br>
                                StreamMusic "Data\Music\DanielJ97\Carleto Project\3.mp3"<br>
                                set musicplaying to 4<br>
                        endif<br>
                        if musicplaying == 4<br>
                                StreamMusic "Data\Music\DanielJ97\Carleto Project\4.mp3"<br>
                                set musicplaying to 5<br>
                        endif<br>
                        if musicplaying == 5<br>
                                StreamMusic "Data\Music\DanielJ97\Carleto Project\5.mp3"<br>
                                set musicplaying to 6<br>
                        endif<br>
                        if musicplaying == 6<br>
                                StreamMusic "Data\Music\DanielJ97\Carleto Project\6.mp3"<br>
                                set musicplaying to 7<br>
                        endif<br>
                        if musicplaying == 7<br>
                                StreamMusic "Data\Music\DanielJ97\Carleto Project\7.mp3"<br>
                                set musicplaying to 8<br>
                        endif<br>
                        if musicplaying == 8<br>
                                StreamMusic "Data\Music\DanielJ97\Carleto Project\8.mp3"<br>
                                set musicplaying to 9<br>
                        endif<br>
                        if musicplaying == 9<br>
                                StreamMusic "Data\Music\DanielJ97\Carleto Project\9.mp3"  <br>
                                set musicplaying to 10<br>
                        endif<br>
                        if musicplaying == 10<br>
                                set musicplaying to 0<br>
                                return<br>
                        endif<br>
          endif<br>
End<br>

<br><br><br><br><br><br><br>It may be a little more complex than it needs to be, but it should do the job.  I hope.<br><br><br>-edit-<br><br>You might need to add a if player.getincell == xxcellxx in order to make it only play in a certain cell.  This should be simple enough but I don't have the time to look it up now <img src="http://www.thenexusforums.com/public/style_emoticons/dark/sad.gif" class="bbc_emoticon" alt=":(">  sorry<br><br>-edit-<br><br>GetInCellParam CellName ActorID<br><br><br>is the call name that you need.  Add this to the block only if the music plays outside the given cell.  change CellName to the cell you wish the music playing in and ActorID to the actor that you want to apply it to (player is the name in this case)  Ammend this to the begginning of the quest script's beginGameMode block.  Make sure to add another endif if you do so <img src="http://www.thenexusforums.com/public/style_emoticons/dark/smile.gif" class="bbc_emoticon" alt=":)"><br><br>Make sure that you don't add too many scripts with BeginGameMode into the same cell.  Also try to add as few quests that will run all the time as well, as this detracts from the game's ability to process all the commands.  More scripts running = more load on the game engine.<br>

<br><br>So this should keep playing the music forever? Even if leave the cell the activator was in?<br><br>The musoc doesnt even start playing at all with that? :S<br>
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...