Code: Select all
event PostLogin( playerpawn NewPlayer )
{
local RacerReplicationInfo RRI;
RRI = Spawn(class'RacerReplicationInfo', NewPlayer);
Log("RRI = "$RRI);
}
Why? o.o What do I do of wrong?
Code: Select all
event PostLogin( playerpawn NewPlayer )
{
local RacerReplicationInfo RRI;
RRI = Spawn(class'RacerReplicationInfo', NewPlayer);
Log("RRI = "$RRI);
}
Well the event PostLogin is written inside a GameInfo, usually... And I didn't write the actor that I want to spawn cause I thought it did the same thing to any actor, it's Rri anyway. That's the RRI class:JackGriffin wrote:Can't tell without seeing the PRI class. I've found it's better to use AlwaysKeep when assigning PRI too.
When you post code you need to put the entire class in if you want good help. You keep posting these really tiny snippets and there's no way to give good help with your questions. Obviously you are assigning the class to players but how are you doing it? Is this running in a mutator class? How is your PRI structured? What errors are you getting in compiling?
Part of your job as an asker of questions is to supply plenty of information. If you keep making it back-and-forth to get your answers people are going to stop answering. It's just too much trouble.
Code: Select all
//=============================================================================
// RacerReplicationInfo.
//=============================================================================
class RacerReplicationInfo expands ReplicationInfo;
var(Racer) Actor actor;
var bool bPlaced;
event PreBeginPlay()
{
if (actor != None)
{
SetOwner(actor);
bPlaced = true;
}
else
Destroy();
super.PreBeginPlay();
}
defaultproperties
{
}
Code: Select all
class WhateverGameType extends Gameinfo config;
function PostBeginPlay()
{
Super.PostBeginPlay();
Level.Game.Spawn( class'RacerReplicationInfoNotify' );
}
Code: Select all
//=============================================================================
// RacerReplicationInfoNotify
//=============================================================================
class RacerReplicationInfoNotify expands SpawnNotify;
simulated event Actor SpawnNotification( Actor A )
{
local RacerReplicationInfo RRI;
if( A == none )
return A;
if( !A.IsA( 'PlayerPawn' ) && !A.IsA( 'Bot' ) )
return A;
// Spawn Racer ReplicationInfo for this pawn on the server
RRI = Spawn( class' RacerReplicationInfo', A );
if( A.IsA('Bot') )
return A;
return A;
}
defaultproperties
{
ActorClass=Class'Engine.Pawn'
}
Code: Select all
function bool AlwaysKeep(Actor Other)
{
if(Other.IsA('PlayerPawn'))
{
PlayerPawn(Other).PlayerReplicationInfoClass = Class'MyReplicationInfo';
return true;
}
if(Other.IsA('Bot'))
{
Bot(Other).PlayerReplicationInfoClass = Class'MyReplicationInfo';
return true;
}
if ( NextMutator != None )
return ( NextMutator.AlwaysKeep(Other) );
return false;
}
Yes but I think no anyone here understood that I'm talking about a RRI and not a PRI.sektor2111 wrote:It's about PlayerReplicationInfo deal. Player might own more actors per session than you think: weapon, different controllers, some guardians, whatever Navig stuff, etc.
I never knew about SpawnNotify actor o.o, Thank you ^-^ I'll try study how it works and I'll try itSC]-[LONG_{HoF} wrote:I'm not quite sure what class you are trying to edit but from my experience post login is not a place to to try to declare a custom Replication class.
I have referenced this before and many mods tend to use.
Code: Select all
class WhateverGameType extends Gameinfo config; function PostBeginPlay() { Super.PostBeginPlay(); Level.Game.Spawn( class'RacerReplicationInfoNotify' ); }
Then the notify should say.
Hope this helps you.Code: Select all
//============================================================================= // RacerReplicationInfoNotify //============================================================================= class RacerReplicationInfoNotify expands SpawnNotify; simulated event Actor SpawnNotification( Actor A ) { local RacerReplicationInfo RRI; if( A == none ) return A; if( !A.IsA( 'PlayerPawn' ) && !A.IsA( 'Bot' ) ) return A; // Spawn Racer ReplicationInfo for this pawn on the server RRI = Spawn( class' RacerReplicationInfo', A ); if( A.IsA('Bot') ) return A; return A; } defaultproperties { ActorClass=Class'Engine.Pawn' }
Code: Select all
event PreBeginPlay()
{
if (actor != None)
{
SetOwner(actor);
bPlaced = true;
}
else
Destroy();
super.PreBeginPlay();
}
Code: Select all
bGameRelevant=True on defaultproperties
Code: Select all
Stuff = Spawn( ActorClass, NewOwner, NewTag, NewLocation, NewRotation);
Thank you, I'm reading this: http://wiki.beyondunreal.com/Everything ... _to_ask%29Wormbo wrote:Guys, you may be going down the wrong road here.
The reason why PRI was None simply is because it destroyed itself. And the reason for that is simply that "actor" was not set. PreBeginPlay() happens inside the Spawn() function and there's not much happening before it, particularly nothing that would have set "actor" to anything.
There's nothing wrong with using PostLogin to spawn some special ReplicationInfo for something, although I agree that there are much better places to spawn it. However, it's not a PRI (as it extends ReplicationInfo, not PlayerReplicationInfo), so other means are necessary to associate it with a particular player.
Also there's no such thing as a "replication chain" in UT. ReplicationInfos are bAlwaysRelevant, so ownership is irrelevant in that regard.
So, according to what other people said before, it's better if a Player owns only one ReplicatedActor, cause if not, there would be conflicts, so I guess it's better if I replace the PlayerReplicationInfo with a RacerReplicationInfo to every Player, right?Higor wrote:Mmmhhh... no.Code: Select all
event PreBeginPlay() { if (actor != None) { SetOwner(actor); bPlaced = true; } else Destroy(); super.PreBeginPlay(); }
Try this:Also, spawn the actor using owner as parameter already as seen below:Code: Select all
bGameRelevant=True on defaultproperties
Notes: Tag is set post spawn, so new actor won't have it for it's own 'BeginPlay' events, Owner (and location, rotation) although does get passed and seen by said events.Code: Select all
Stuff = Spawn( ActorClass, NewOwner, NewTag, NewLocation, NewRotation);
Spawn returns none if the actor is destroyed at any stage of it's initialization, or if a SpawnNotify alters said result to none.