News UnrealEd Files Mods FragBU Liandri Archives
BeyondUnreal Forums

Go Back   BeyondUnreal Forums > Unreal Development > Coding

Reply
 
Thread Tools Display Modes
Old 17th Sep 2005, 08:53 AM   #1
Raven
Registered User
 
Raven's Avatar
 
Join Date: Jan. 17th, 2004
Posts: 147
[UT'99] How to interact with an actor, when level ends

I build mp3 player, and the problem is, that when I play mp3 in one level, and load another, mp3 keep playing :/. I tried 'event Destroyed' and mutator:
Code:
class RMp3PlayerStopper extends Mutator;

var RMp3Player JukeBox;

function AddMutator(Mutator M)
{
    if ( M.IsA('RMp3PlayerStopper') )
    {
        return; //only allow one mutator
    }
    Super.AddMutator(M);
}


function BeginPlay()
{
    foreach AllActors(class'RMp3Player', JukeBox)
       break;
    log("Mp3Player: mutator begins play");
}

function bool HandleEndGame()
{      
      ShutDownMusicSys();
      Super.HandleEndGame();
      return False;
}

function ShutDownMusicSys()
{
   log("Mp3Player: shuttin gdown");
   JukeBox.ShutDown();
   JukeBox.Destroy();
}
but nothing works. So my question is: how to interact with an actor, when level is about to change?

Last edited by Raven; 17th Sep 2005 at 10:56 AM.
Raven is offline   Reply With Quote
Old 17th Sep 2005, 03:43 PM   #2
Raven
Registered User
 
Raven's Avatar
 
Join Date: Jan. 17th, 2004
Posts: 147
I've tried something else. I decide to spawn mp3player in entry level

Code:
(..)
simulated function PostBeginPlay()
{
	if (Level.NetMode != NM_DedicatedServer)
		SetTimer(1.0,true);
}

simulated function Timer()
{

	if (Level.NetMode == NM_DedicatedServer) return;

	if (Level.LevelAction == LEVACT_None) {
		foreach AllActors(class'PlayerPawn',PP)
			break;

		if (PP == none) return;

		foreach PP.GetEntryLevel().AllActors(class'RMp3Player',JukeBox)
			break;

		if (JukeBox == none)
			JukeBox = PP.GetEntryLevel().Spawn(class'RMp3Player');
			
		JukeBox.ReadPlayerPawn(PP);
			
                Mp3PlayerInit();
		SetTimer(0, false);
	}
}
(..)
and check if new level is loading, and then stop playing sound

Code:
class RMp3Player extends Actor
      native
      config(user)
      NoUserCreate;

var native string Directory;
var config int MusicVolume;
var bool bWasInitialized;
var PlayerPawn PP;
var LevelInfo CurLevel, OldLevel;
//var bool bDoFade;
//var bool bIsPaused;

native(2230) final function bool MusicSystemInit();             //Initialize music system
native(2331) final function bool PlaySong(string title);        //Plays song (use only for the first time)
native(2432) final function StopSong();                         //Stop playing new song
native(2533) final function ChangeVolume(int Volume);           //Changes volume
native(2634) final function PlayNewSong(string title);          //Plays new song
native(2735) final function ShutDown();                         //Shuts down music system
//native(2836) final function PauseMusic(bool PauseMusic);        //Pause music

function ReadPlayerPawn(PlayerPawn PlP)
{
        PP=PlP;
        OldLevel = PlP.level;
}


event Tick(float Delta)
{
	if (PP == none || !bWasInitialized) return;

	CurLevel = PP.player.console.viewport.actor.level;

	if (CurLevel != OldLevel && CurLevel != Level)
//        if(PP.player.console.viewport.actor.level.LevelAction == LEVACT_Loading)
        {
                log("Mp3Player: InShuttingDown");
                if(bWasInitialized)
                {
		     ShutDown();
		     bWasInitialized=false;
		}
//		Destroy();
	}
}

defaultproperties
{
   Directory="../music/"
   MusicVolume=128
   bHidden=True
}
but then UT just hangs up with 'loading' screen. Nothig important appears in the log (just normal ut logs) :/

Last edited by Raven; 17th Sep 2005 at 03:46 PM.
Raven is offline   Reply With Quote
Old 19th Sep 2005, 02:14 AM   #3
Raven
Registered User
 
Raven's Avatar
 
Join Date: Jan. 17th, 2004
Posts: 147
I solved this problem . I don't know why, but all problems (ut hangs up) was caused by one of the native functions. So now I use another for shutting down this bastard. Mp3Player can be found: http://turniej.unreal.pl/mp3player/indexen.html and http://turniej.unreal.pl/mp3player/RvMp3Player.zip.
Raven is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 01:19 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.

Copyright ©1998 - 2012, BeyondUnreal, Inc.
Privacy Policy | Terms of Use
Bandwidth provided by AtomicGamer