For direct access use https://forums.oldunreal.com
It's been quite a while since oldunreal had an overhaul, but we are moving to another server which require some updates and changes. The biggest change is the migration of our old reliable YaBB forum to phpBB. This system expects you to login with your username and old password known from YaBB.
If you experience any problems there is also the usual "password forgotten" function. Don't forget to clear your browser cache!
If you have any further concerns feel free to contact me: Smirftsch@oldunreal.com

Replication Issue.

The section related to UnrealScript and modding. This board is for coders to discuss and exchange experiences or ask questions.
User avatar
Raven
OldUnreal Member
Posts: 311
Joined: Fri Jun 10, 2005 5:10 am

Replication Issue.

Post by Raven »

I have two functions Trigger and replicated EVENT_Trigger. Trigger is called on dedicated server, and it calls function EVENT_Trigger. The problem is, that EVENT_Trigger isn't replicated to the clients. Here's code:

Code: Select all

class RMusic_Controller extends RMusic_Component;

var() class PlayerClass;      // Player class (if you want to have own music directory)
var() string RMusic_File;            // Music file to play
var() bool RMusic_PlayAtStartup;      // Should it be played at level start
var() bool RMusic_MuteUMX;            // If true will mute all music in umx files
var() bool RMusic_BroadcastToAll;      // If true, it'll broadcast functions to all players
var() bool RMusic_bUnloadPreviousDSP;      // If true, all DSP plugins will be unloaded
var() bool RMusic_bOwnFadeUpdateTime;      // Should use custom fade time
var() float RMusic_OwnFadeUpdateTime;      // How often fading state will be updated
var() bool RMusic_bUseSaveControl;      // If true, Controller will spawn RMusic_Save actor to restore music in level (usefull only in SinglePlayer)
var string RMusic_DSPPlugins[16];      // DSP plugins to load (not used, left because of compatibility reasons)
var() enum EAction
{
    AC_Play,                        // Plays music
    AC_Stop,                        // Stops music
    AC_Pause,                        // Pauses music
    AC_UnPause,                        // Unpasues music
    AC_ShutDown                        // Shutdown FMODEX (avoid this one ;) )
} Action;                        // Action
var() enum EPlayType
{
    PT_Loop,                        // Loops music
    PT_PlayOnce                        // Plays once
} RMusic_PlayType;                  // Play type
var() enum ERMusicTransition
{
    TRANS_Instanly,                  // Instant transition
    TRANS_Fade                        // Smooth fade
} RMusic_Transition;                  // Transition type

replication
{
      reliable if( Role == ROLE_Authority )
            EVENT_Trigger;
}
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * Used to play music
 */
simulated function EVENT_Trigger(PlayerPawn PP)
{
      local RMusic_Player RMusic_Player;
      local int i;
      local bool bLooped;
      local PlayerPawn RMusic_LocalPlayer;


      if(Level.NetMode == NM_DedicatedServer)
      {
            log("called on dedicated by"@PP);
            return;
      }
      BroadCastMessage("Called in Client");

      if( RMusic_PlayType == PT_Loop ) bLooped = true;
      else bLooped = false;
      RMusic_Player = Find_RMusicPlayerByPPawn(self, PP, PlayerClass);

      if(Level.NetMode == NM_Standalone && RMusic_bUseSaveControl) EVENT_Save();

      if( RMusic_Player != none )
      {
            RMusic_LocalPlayer = PP;

            if( RMusic_MuteUMX ) RMusic_LocalPlayer.ClientSetMusic(Music'RMusicPlayer.null', 0, 0, MTRAN_FastFade);
            if( RMusic_bUnloadPreviousDSP )
            {
                  RMusic_Player.RMusic_UnLoadPlugin("ALL");
                  RMusic_Player.bHasDSP=false;
            }
            if(RMusic_bOwnFadeUpdateTime && RMusic_OwnFadeUpdateTime > 0) RMusic_Player.FaderUpdateTime=RMusic_OwnFadeUpdateTime;
            switch Action
            {
                  case AC_Play:
                        if(RMusic_Transition == TRANS_Instanly)
                              RMusic_Player.RMusic_Play(RMusic_File,bLooped);
                        else
                              RMusic_Player.RMusic_PlayStream(RMusic_File,bLooped);
                  break;
                  case AC_Stop:
                        if(RMusic_Transition == TRANS_Instanly)
                              RMusic_Player.RMusic_Stop();
                        else
                              RMusic_Player.GoToState('RMusic_FadeOut');
                  break;
                  case AC_Pause:
                        if(RMusic_Transition == TRANS_Instanly)
                              RMusic_Player.RMusic_Pause(true);
                        else
                              RMusic_Player.GoToState('RMusic_FadeOutPause');
                  break;
                  case AC_UnPause:
                        if(RMusic_Transition == TRANS_Instanly)
                              RMusic_Player.RMusic_Pause(false);
                        else
                              RMusic_Player.GoToState('RMusic_FadeInUnPause');
                  break;
                  case AC_ShutDown:
                        RMusic_Player.RMusic_Close();
                  break;
            }
            if( RMusic_Player.bAuthoritative )
            {
                  RMusic_Player.RMusic_LocalPlayer = RMusic_LocalPlayer;
                  RMusic_Player.RMusic_OldLevel = RMusic_LocalPlayer.Level;
            }
      }
}
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * Used only if RMusic_PlayAtStartup is false
 */
function Trigger( actor Other, pawn EventInstigator )
{
      local Pawn A;
      local PlayerPawn P;

      if( !RMusic_PlayAtStartup )
      {
            if( Level.NetMode == NM_Standalone )
            {
                  EVENT_Player();
            }
            else if( Level.NetMode == NM_DedicatedServer || Level.NetMode == NM_ListenServer )
            {
                  if( RMusic_BroadcastToAll )
                  {
                        A = Level.PawnList;
                        While ( A != None )
                        {
                              if ( A.IsA('PlayerPawn') )
                                    EVENT_Trigger(PlayerPawn(A));
                              A = A.nextPawn;
                        }
                  }
                  else
                  {
                        // Only affect the one player.
                        P = PlayerPawn(EventInstigator);
                        if( P == None )
                              return;
                        EVENT_Trigger(P);
                  }
            }
      }
}

defaultproperties
{
      PlayerClass=class'RMusicPlayer.RMusic_Player'
      RMusic_MuteUMX=true
      RMusic_bUnloadPreviousDSP=false
      RMusic_OwnFadeUpdateTime=0.001

      Texture=texture'RMusicPlayer.Icons.RMusic_Controller'

      bNoDelete=true
      RemoteRole=ROLE_SimulatedProxy
}
I've tried every possible RemoteRole with no success. Can someone who knows replication better then meh, what I've done wrong ?
Image
User avatar
.:..:
OldUnreal Member
Posts: 1637
Joined: Tue Aug 16, 2005 4:35 am

Re: Replication Issue.

Post by .:..: »

Well FYI: functions can't be replicated to anyone except Actor owner.
So heres an alternative way of doing this (not 100 % sure if this will do it though):

Code: Select all

class RMusic_Controller extends RMusic_Component;

var() class PlayerClass;      // Player class (if you want to have own music directory)
var() string RMusic_File;            // Music file to play
var() bool RMusic_PlayAtStartup;      // Should it be played at level start
var() bool RMusic_MuteUMX;            // If true will mute all music in umx files
var() bool RMusic_BroadcastToAll;      // If true, it'll broadcast functions to all players
var() bool RMusic_bUnloadPreviousDSP;      // If true, all DSP plugins will be unloaded
var() bool RMusic_bOwnFadeUpdateTime;      // Should use custom fade time
var() float RMusic_OwnFadeUpdateTime;      // How often fading state will be updated
var() bool RMusic_bUseSaveControl;      // If true, Controller will spawn RMusic_Save actor to restore music in level (usefull only in SinglePlayer)
var string RMusic_DSPPlugins[16];      // DSP plugins to load (not used, left because of compatibility reasons)
var() enum EAction
{
   AC_Play,                        // Plays music
   AC_Stop,                        // Stops music
   AC_Pause,                        // Pauses music
   AC_UnPause,                        // Unpasues music
   AC_ShutDown                        // Shutdown FMODEX (avoid this one ;) )
} Action;                        // Action
var() enum EPlayType
{
   PT_Loop,                        // Loops music
   PT_PlayOnce                        // Plays once
} RMusic_PlayType;                  // Play type
var() enum ERMusicTransition
{
   TRANS_Instanly,                  // Instant transition
   TRANS_Fade                        // Smooth fade
} RMusic_Transition;                  // Transition type

replication
{
      reliable if( Role == ROLE_Authority )
            EVENT_Trigger;
}
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Used to play music
*/
simulated function EVENT_Trigger(PlayerPawn PP)
{
      local RMusic_Player RMusic_Player;
      local int i;
      local bool bLooped;
      local PlayerPawn RMusic_LocalPlayer;


      if(Level.NetMode == NM_DedicatedServer)
      {
            log("called on dedicated by"@PP);
            return;
      }
      BroadCastMessage("Called in Client");

      if( RMusic_PlayType == PT_Loop ) bLooped = true;
      else bLooped = false;
      RMusic_Player = Find_RMusicPlayerByPPawn(self, PP, PlayerClass);

      if(Level.NetMode == NM_Standalone && RMusic_bUseSaveControl) EVENT_Save();

      if( RMusic_Player != none )
      {
            RMusic_LocalPlayer = PP;

            if( RMusic_MuteUMX ) RMusic_LocalPlayer.ClientSetMusic(Music'RMusicPlayer.null', 0, 0, MTRAN_FastFade);
            if( RMusic_bUnloadPreviousDSP )
            {
                  RMusic_Player.RMusic_UnLoadPlugin("ALL");
                  RMusic_Player.bHasDSP=false;
            }
            if(RMusic_bOwnFadeUpdateTime && RMusic_OwnFadeUpdateTime > 0) RMusic_Player.FaderUpdateTime=RMusic_OwnFadeUpdateTime;
            switch Action
            {
                  case AC_Play:
                        if(RMusic_Transition == TRANS_Instanly)
                              RMusic_Player.RMusic_Play(RMusic_File,bLooped);
                        else
                              RMusic_Player.RMusic_PlayStream(RMusic_File,bLooped);
                  break;
                  case AC_Stop:
                        if(RMusic_Transition == TRANS_Instanly)
                              RMusic_Player.RMusic_Stop();
                        else
                              RMusic_Player.GoToState('RMusic_FadeOut');
                  break;
                  case AC_Pause:
                        if(RMusic_Transition == TRANS_Instanly)
                              RMusic_Player.RMusic_Pause(true);
                        else
                              RMusic_Player.GoToState('RMusic_FadeOutPause');
                  break;
                  case AC_UnPause:
                        if(RMusic_Transition == TRANS_Instanly)
                              RMusic_Player.RMusic_Pause(false);
                        else
                              RMusic_Player.GoToState('RMusic_FadeInUnPause');
                  break;
                  case AC_ShutDown:
                        RMusic_Player.RMusic_Close();
                  break;
            }
            if( RMusic_Player.bAuthoritative )
            {
                  RMusic_Player.RMusic_LocalPlayer = RMusic_LocalPlayer;
                  RMusic_Player.RMusic_OldLevel = RMusic_LocalPlayer.Level;
            }
      }
}
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Used only if RMusic_PlayAtStartup is false
*/
function Trigger( actor Other, pawn EventInstigator )
{
      local Pawn A;
      local PlayerPawn P;

      if( !RMusic_PlayAtStartup )
      {
            if( Level.NetMode == NM_Standalone )
            {
                  EVENT_Player();
            }
            else if( Level.NetMode == NM_DedicatedServer || Level.NetMode == NM_ListenServer )
            {
                  if( RMusic_BroadcastToAll )
                  {
                        A = Level.PawnList;
                        While ( A != None )
                        {
                              if ( A.IsA('PlayerPawn') )
                              {
                                    SetOwner(A);
                                    EVENT_Trigger(PlayerPawn(A));
                              }
                              A = A.nextPawn;
                        }
                  }
                  else
                  {
                        // Only affect the one player.
                        P = PlayerPawn(EventInstigator);
                        if( P == None )
                              return;
                        SetOwner(P);
                        EVENT_Trigger(P);
                  }
            }
      }
}

defaultproperties
{
      PlayerClass=class'RMusicPlayer.RMusic_Player'
      RMusic_MuteUMX=true
      RMusic_bUnloadPreviousDSP=false
      RMusic_OwnFadeUpdateTime=0.001

      Texture=texture'RMusicPlayer.Icons.RMusic_Controller'

      bNoDelete=true
      RemoteRole=ROLE_SimulatedProxy
      bAlwaysRelevant=True
}
1823223D2A33224B0 wrote:...and now im stuck trying to fix everything you broke for the next 227 release xD :P
(ಠ_ಠ)
User avatar
Raven
OldUnreal Member
Posts: 311
Joined: Fri Jun 10, 2005 5:10 am

Re: Replication Issue.

Post by Raven »

\o/ works :). Tnx man, it was true mystery for meh :)
Image

Return to “UScript Board”