TobiaszPL Posted November 24, 2019 Share Posted November 24, 2019 Hey its me again :oTobi !... Yes im Tobi :o !... I just want to ask You about opinion maybe You will find something to Fix some Bugs etc.this single one script handle whole TheRadio Mod so if You want You can look at this and as i said... maybe You find something to Fix... Scriptname QLG_MasterScript_TheRadio extends ObjectReference { This is Main Radio Script for [Tobi] TheRadio Mod !... } ;===- Base Info. -===; ;Created: 2019-07-19 ;Update: 2019-11-23 ;Author: TobiPL ;Unit: M.PC<1> ;===- Var. setup -============================================ ;***=-- Music List --=***; FormList Property QMusics Auto { List of Music Tracks } ;***=-- FormLists --=***; FormList Property FunList Auto { List of Fun Messages } ;***=-- Messages! --=***; Message Property QMainMSG Auto { Maing Message to SHow } ;***=- Simple Var. -=***; Int Playing = -1 ; Is any musing playing? -1 Means :NO: - other values for ID ;===============================================; ;===- Main Script -=============================; ;***********************************************; Event OnActivate( ObjectReference QRef ) ; Show Fun Message if Enabled If( FunMSG ) If( Utility.RandomInt( 0 , 3 ) > 1 ) ( FunList.GetAt( Utility.RandomInt( 0 , FunList.GetSize() ) ) as Message ).show() EndIf EndIf ; Show Main Menu While( true ) int Ret = QMainMSG.Show() If( Ret == 0 ) Debug.Notification( "Noo, Come Back!..." ) Return ;===================; ElseIf( Ret == 1 ) QPlayMenu() ;===================; ElseIf( Ret == 2 ) QSettingsMenu() ;===================; EndIf EndWhile EndEvent ;== Message Property QPlayMSG Auto { Menu Message to Show } Function QPlayMenu() While( true ) Int Ret = QPlayMSG.Show() If( Ret == 0 ) ; Player press Exit, Back to MainMenu Return ElseIf( Ret == 1 ) ; Stop playing Music If( Playing >= 0 ) ( ( QMusics.GetAt( Order ) as FormList ).GetAt( Playing ) as MusicType ).Remove() Playing = -1 EndIf Else QPlay( Ret - 2 ) EndIf EndWhile EndFunction Message Property QError_PlayMusic Auto { Error To show if player want to Play music but there is already playing one } Function QPlay( int ID ) If( Playing == -1 ) ( ( QMusics.GetAt( Order ) as FormList ).GetAt( ID ) as MusicType ).Add() Playing = ID Return Else If( ErrorMSG ) QError_PlayMusic.Show() Else Debug.Notification( "There is already playing music !..." ) EndIf EndIf EndFunction FormList Property QSettings Auto { List of Messages for Settings } ;***=- Settings -=***; Int FunMSG = 1 ; Should show Fun Messages? Int ErrorMSG = 0 ; Should show Error Messages? Int Order = 0 ; Should play in Order or Random? ( 0 = Random // 1 = Order ) Function QSettingsMenu() While( true ) Int Ret = ( QSettings.GetAt( ( FunMSG + ( ( ErrorMSG * 2 ) + ( Order * 4 ) ) ) ) as Message ).Show( FunMSG , ErrorMSG , Order ) If( Ret == 0 ) Return ; Player Want to change Fun Messages at start of Menu ElseIf( Ret == 1 ) If( FunMSG == 1 ) FunMSG = 0 Else FunMSG = 1 EndIf ; Player Want to Change Error Messages ( 0 = Notification // 1 = Boxes ) ElseIf( Ret == 2 ) If( ErrorMSG == 1 ) ErrorMSG = 0 Else ErrorMSG = 1 EndIf ; Player Wan to Change order ( 0 = Random // 1 = Order ) ElseIf( Ret == 3 ) If( Order == 1 ) Order = 0 Else Order = 1 EndIf EndIf EndWhile EndFunction ; The End Link to comment Share on other sites More sharing options...
NexusComa Posted November 24, 2019 Share Posted November 24, 2019 Here is one of mine .. from Enchanted Ship in a Bottle(player home) mod. It can stop a track and start a new one. If you wanted to add that. Scriptname Ship00_MusicPlayer extends ObjectReference;* Music Player * By: NexusComa * ; nexusmods.comObjectReference Property LightMarker AutoObjectReference Property Marker AutoMusicType Property _MusicTrackMain AutoMusicType Property _MusicTrackAlt AutoMusicType Property _NONE AutoEvent OnInit()Marker.Disable()GoToState("Switch")EndEvent;------------State SwitchEvent OnActivate(ObjectReference akActionRef)If(Marker.IsDisabled())_Enable()Else_Disable()EndIfEndEventEndState;------------Function _Enable()Marker.Enable()LightMarker.Enable()_MusicTrackMain.Add()Utility.Wait(1.0)_NONE.Remove()Utility.Wait(2.0)LightMarker.Disable()EndFunction;------------Function _Disable()Marker.Disable()LightMarker.Disable()_NONE.Add()Utility.Wait(1.0)_MusicTrackMain.Remove()_MusicTrackAlt.Remove()EndFunction; Link to comment Share on other sites More sharing options...
ReDragon2013 Posted November 25, 2019 Share Posted November 25, 2019 (edited) the code line Utility.RandomInt( 0 , FunList.GetSize() )should be as follow Utility.RandomInt( 0 , FunList.GetSize() - 1 )Why? formlists and arrays starts by Zero, not One.. I also have rewritten your script as follow:QLG_MasterScript_TheRadio Scriptname QLG_MasterScript_TheRadio extends ObjectReference { This is Main Radio Script for [Tobi] TheRadio Mod !... } ; https://forums.nexusmods.com/index.php?/topic/8169448-what-is-wrong-with-my-script-11/ ;===- Base Info. -===; ;Created: 2019-07-19 ;Update: 2019-11-23 ;Author: TobiPL ;Unit: M.PC<1> Message PROPERTY QMainMSG auto ; Maing Message to Show Message PROPERTY QPlayMSG auto ; Menu Message to Show Message PROPERTY QError_PlayMusic auto ; Error when player wants to play new music, but there is already playing one FormList PROPERTY QSettings auto ; { List of Messages for Settings } FormList PROPERTY FunList auto ; { List of Fun Messages } FormList PROPERTY QMusics auto ; { List of Music Tracks } Int Playing = -1 ; Is any musing playing? ; -1 = not playing, others has value for running music track ;***=- Settings -=***; Bool FunMSG = TRUE ; Should show Fun Messages? Bool Shuffle = TRUE ; Should play the music shuffled? (0 = in order, 1 = Random) Bool ErrorMSG ;= False ; Should show Error Messages? ; -- EVENTs -- EVENT OnActivate( ObjectReference QRef ) QFunMsg() ; Show Fun Message, if Enabled QMenu() Debug.Notification( "Noo, Come Back!..." ) ENDEVENT ; -- FUNCTIONs -- 6 ;----------------- FUNCTION QFunMsg() ;----------------- IF ( FunMSG ) IF (Utility.RandomInt(0, 3) < 2) RETURN ; - STOP - no luck to show fun message this time ENDIF ; ---------------------- int i = FunList.GetSize() - 1 IF (i >= 0) i = Utility.RandomInt(0, i) (FunList.GetAt(i) as Message).show() ENDIF ENDIF ENDFUNCTION ;--------------- FUNCTION QMenu() ;--------------- int i = 1 WHILE(i) i = QMainMSG.Show() ; --- Main Menu --- IF (i == 1) WHILE (i) i = QPlayMSG.Show() ; --- Play Menu --- IF (i == 1) QStop() ; stop music track ELSEIF (i > 0) QPlay(i - 2) ; play music track ENDIF ENDWHILE ELSEIF (i == 2) QSettingsMenu() ; --- Settings Menu --- ENDIF ENDWHILE ; i == 0 ENDFUNCTION ;--------------- FUNCTION QStop() ; Stop playing Music ;--------------- IF (Playing >= 0) QGetMusic().Remove() Playing = -1 RETURN ; - STOP - ENDIF ;--------------------- ;;; IF ( ErrorMSG ) ;;; QError_PlayMusic.show() ;;; ELSE Debug.Notification( "A music track is not playing!" ) ;;; ENDIF ENDFUNCTION ;----------------------------- MusicType FUNCTION QGetMusic() ; helper ;----------------------------- int i = Playing formList fmL = QMusics.GetAt(Shuffle as Int) as FormList ; take formlist from GetAt(0) or GetAt(1) RETURN fmL.GetAt(i) as MusicType ENDFUNCTION ;-------------------- FUNCTION QPlay(Int i) ;-------------------- IF (Playing < 0) Playing = i QGetMusic().Add() RETURN ; - STOP - ENDIF ;--------------------- IF ( ErrorMSG ) QError_PlayMusic.show() ELSE Debug.Notification( "A music track is already playing!" ) ENDIF ENDFUNCTION ;----------------------- FUNCTION QSettingsMenu() ;----------------------- int i = 1 WHILE (i) i = (FunMSG as Int) + ((ErrorMSG as Int) * 2) + ((Shuffle as Int) * 4) i = (QSettings.GetAt(i) as Message).show(FunMSG as Int, ErrorMSG as Int, Shuffle as Int) IF (i == 0) ; return back ELSEIF (i == 1) ; player wants to switch (on/off) the Fun Messages by activating FunMSG = !FunMSG ELSEIF (i == 2) ; player wants to change layout of error messages (0 = Notification, 1 = MessageBox) ErrorMSG = !ErrorMsg ELSEIF (i == 3) ; player wants to change the playlist order (0 = Random, 1 = Order) Shuffle = !Shuffle ENDIF ENDWHILE ; i == 0 ENDFUNCTION Make sure you are using "ADD" and "Remove" of the musicType correctly, because they are using an internal music stack that could be corrupted else. Edited November 25, 2019 by ReDragon2013 Link to comment Share on other sites More sharing options...
Recommended Posts