I'm trying to make a system where certain players can change there name to have color tags without affecting there original name but sadly a replication problem happens that is confusing me greatly, it appears that the string is "" on both client and server and if I can get it to not be "" on the client then it's "" on the server and other players can't see the change only the owner
Here is the code
ForrestPRI.uc
FMXPlayerController.uc
Here is the code
ForrestPRI.uc
Code:
class ForrestPRI extends KF_StoryPRI;
var string AltPlayerName;
var bool bGotVIPValues;
replication
{
reliable if( bNetDirty && (Role == Role_Authority) )
AltPlayerName;
}
function Tick(float DT)
{
if( !bGotVIPValues )
{
bGotVIPValues = true;
if( FMXPlayerController(Owner) != none )
FMXPlayerController(Owner).InitVIPInfo();
}
Super.Tick(DT);
}
defaultproperties
{
}
Code:
var() globalconfig string AltPlayerName;
replication
{
reliable if( Role == ROLE_Authority )
SetupPlayerName;
}
exec function SetName(coerce string S)
{
local ForrestPRI FPlayerRepInfo;
local string OldName, NewName, Gender;
if( PlayerReplicationInfo == none )
return;
FPlayerRepInfo = ForrestPRI(PlayerReplicationInfo);
if( !FPlayerRepInfo.bSuperVIP )
return;
if( NameChanged > 4 && !bNameCoolDown )
{
bNameCoolDown = true;
NameChangeCoolDown = Level.TimeSeconds;
}
if( bNameCoolDown )
{
ClientMessage("Name changed too many times, please wait 10 seconds");
return;
}
if( S == "" )
{
AltPlayerName = S;
FPlayerRepInfo.AltPlayerName = S;
SaveConfig();
return;
}
if( FPlayerRepInfo.AltPlayerName == "" )
OldName = PlayerReplicationInfo.PlayerName;
else
OldName = FPlayerRepInfo.AltPlayerName;
NewName = S;
ReplaceText(NewName, " ", "_");
ReplaceText(NewName, "\"", "");
Gender = eval(PlayerReplicationInfo.bIsFemale, "her", "his");
AltPlayerName = NewName;
SetupPlayerName(FPlayerRepInfo);
SaveConfig();
if( Mut.StripColorTags(NewName) == Mut.StripColorTags(OldName) )
return;
BroadcastMessage(Mut.ParseColorTags(OldName)@Mut.ColorString("has changed"@Gender@"name to", 255, 255, 255)@Mut.ParseColorTags(NewName), true);
NameChanged++;
}
function InitVIPInfo()
{
local int i;
local ForrestPRI FPlayerRepInfo;
local string SteamID;
local bool bLoggedName;
if( PlayerReplicationInfo == none )
return;
FPlayerRepInfo = ForrestPRI(PlayerReplicationInfo);
SteamID = GetPlayerIDHash();
for(i=0;i<class'FMXBaseMut'.default.Mut.SteamIDs.Length;i++)
{
if( class'FMXBaseMut'.default.Mut.SteamIDs[i].ID == SteamID )
{
FPlayerRepInfo.bSuperVIP = True;
FPlayerRepInfo.MedalMaterial = Material(DynamicLoadObject(class'FMXBaseMut'.default.Mut.SteamIDs[i].MedalMaterial, class'Material', true));
FPlayerRepInfo.PlayerNameColor = class'FMXBaseMut'.default.Mut.SteamIDs[i].VIPColor;
}
}
SetupPlayerName(FPlayerRepInfo);
if( !bLoggedName )
{
bLoggedName = true;
if( Mut != none && AltPlayerName != "" && Mut.StripColorTags(AltPlayerName) != PlayerReplicationInfo.PlayerName )
log(Mut.StripColorTags(AltPlayerName)$"'s old name was"@PlayerReplicationInfo.PlayerName);
}
}
simulated function SetupPlayerName( ForrestPRI FPlayerRepInfo )
{
if( Level.NetMode == NM_DedicatedServer )
return;
if( AltPlayerName != "" )
FPlayerRepInfo.AltPlayerName = AltPlayerName;
}
Last edited: