replication
This commit is contained in:
parent
29abb98b4a
commit
dbe955bd14
@ -43,40 +43,59 @@ private function InitConfig()
|
||||
{
|
||||
local PlayerGroupEntry ExampleGroup;
|
||||
local PlayerInfoEntry ExamplePlayer;
|
||||
local SteamGroupEntry ExampleSteamGroup;
|
||||
|
||||
// Update from config version to current version if needed
|
||||
switch (ConfigVersion)
|
||||
{
|
||||
case 0: // which means there is no config right now
|
||||
// Default admin
|
||||
SaveConfig(); // because I want the main settings to be at the beginning of the config :)
|
||||
|
||||
// Default admin rank
|
||||
class'SystemAdminGroup'.default.Rank = "Admin";
|
||||
class'SystemAdminGroup'.default.Color.R = 250;
|
||||
class'SystemAdminGroup'.default.Color.G = 0;
|
||||
class'SystemAdminGroup'.default.Color.B = 0;
|
||||
class'SystemAdminGroup'.static.StaticSaveConfig();
|
||||
|
||||
// Default player
|
||||
// Default player rank
|
||||
class'SystemPlayerGroup'.default.Rank = "Player";
|
||||
class'SystemPlayerGroup'.default.Color.R = 250;
|
||||
class'SystemPlayerGroup'.default.Color.G = 250;
|
||||
class'SystemPlayerGroup'.default.Color.B = 250;
|
||||
class'SystemPlayerGroup'.static.StaticSaveConfig();
|
||||
|
||||
// Example group
|
||||
// Example rank for player(s)
|
||||
ExampleGroup.ID = 0;
|
||||
ExampleGroup.Rank = "Scoreboard Creator";
|
||||
ExampleGroup.Rank = "SCE Creator";
|
||||
ExampleGroup.Color.R = 130;
|
||||
ExampleGroup.Color.G = 250;
|
||||
ExampleGroup.Color.B = 235;
|
||||
ExampleGroup.OverrideAdminRank = true;
|
||||
class'PlayerGroups'.default.PlayerGroup.AddItem(ExampleGroup);
|
||||
class'PlayerGroups'.static.StaticSaveConfig();
|
||||
|
||||
// Example player
|
||||
ExamplePlayer.PlayerID = "76561198001617867"; // GenZmeY SteamID64
|
||||
ExamplePlayer.GroupID = ExampleGroup.ID;
|
||||
class'PlayerInfos'.default.PlayerInfo.AddItem(ExamplePlayer);
|
||||
|
||||
// Example rank for steam group members
|
||||
ExampleGroup.ID = 1;
|
||||
ExampleGroup.Rank = "[MSK-GS]";
|
||||
ExampleGroup.Color.R = 130;
|
||||
ExampleGroup.Color.G = 250;
|
||||
ExampleGroup.Color.B = 130;
|
||||
ExampleGroup.OverrideAdminRank = false;
|
||||
class'PlayerGroups'.default.PlayerGroup.AddItem(ExampleGroup);
|
||||
|
||||
// Example steam group
|
||||
ExampleSteamGroup.SteamGroupID = "103582791465384046"; // MSK-GS SteamID64
|
||||
ExampleSteamGroup.GroupID = ExampleGroup.ID;
|
||||
class'SteamGroups'.default.SteamGroup.AddItem(ExampleSteamGroup);
|
||||
|
||||
class'SystemAdminGroup'.static.StaticSaveConfig();
|
||||
class'SystemPlayerGroup'.static.StaticSaveConfig();
|
||||
class'PlayerGroups'.static.StaticSaveConfig();
|
||||
class'PlayerInfos'.static.StaticSaveConfig();
|
||||
class'SteamGroups'.static.StaticSaveConfig();
|
||||
|
||||
case 2147483647:
|
||||
`log("[ScoreboardExt] Config updated to version"@CurrentVersion);
|
||||
@ -126,7 +145,7 @@ function AddPlayerInfo(Controller C)
|
||||
local SClient RepClient;
|
||||
|
||||
KFPC = KFPlayerController(C);
|
||||
if (KFPC == None || !KFPC.bIsPlayer)
|
||||
if (KFPC == None)
|
||||
return;
|
||||
|
||||
RepClient.RepInfo = Spawn(class'ScoreboardExtRepInfo', KFPC);
|
||||
@ -134,15 +153,16 @@ function AddPlayerInfo(Controller C)
|
||||
|
||||
RepClients.AddItem(RepClient);
|
||||
|
||||
RepClient.RepInfo.ClientInit(
|
||||
class'PlayerGroups'.default.PlayerGroup,
|
||||
UIDInfos,
|
||||
class'SystemAdminGroup'.default.Rank,
|
||||
class'SystemAdminGroup'.default.Color,
|
||||
class'SystemAdminGroup'.default.ApplyColorToFields,
|
||||
class'SystemPlayerGroup'.default.Rank,
|
||||
class'SystemPlayerGroup'.default.Color,
|
||||
class'SystemPlayerGroup'.default.ApplyColorToFields);
|
||||
RepClient.RepInfo.PlayerInfos = UIDInfos;
|
||||
RepClient.RepInfo.PlayerGroups = class'PlayerGroups'.default.PlayerGroup;
|
||||
RepClient.RepInfo.SystemAdminRank = class'SystemAdminGroup'.default.Rank;
|
||||
RepClient.RepInfo.SystemAdminColor = class'SystemAdminGroup'.default.Color;
|
||||
RepClient.RepInfo.SystemAdminApplyColorToFields = class'SystemAdminGroup'.default.ApplyColorToFields;
|
||||
RepClient.RepInfo.SystemPlayerRank = class'SystemPlayerGroup'.default.Rank;
|
||||
RepClient.RepInfo.SystemPlayerColor = class'SystemPlayerGroup'.default.Color;
|
||||
RepClient.RepInfo.SystemPlayerApplyColorToFields = class'SystemPlayerGroup'.default.ApplyColorToFields;
|
||||
|
||||
RepClient.RepInfo.ClientStartReplication();
|
||||
}
|
||||
|
||||
function RemovePlayerInfo(Controller C)
|
||||
|
@ -1,19 +1,100 @@
|
||||
class ScoreboardExtRepInfo extends ReplicationInfo;
|
||||
|
||||
var private array<UIDInfoEntry> PlayerInfos;
|
||||
var private array<PlayerGroupEntry> PlayerGroups;
|
||||
var public array<UIDInfoEntry> PlayerInfos;
|
||||
var public array<PlayerGroupEntry> PlayerGroups;
|
||||
|
||||
var private string SystemAdminRank;
|
||||
var private TextColor SystemAdminColor;
|
||||
var private Fields SystemAdminApplyColorToFields;
|
||||
var public string SystemAdminRank;
|
||||
var public TextColor SystemAdminColor;
|
||||
var public Fields SystemAdminApplyColorToFields;
|
||||
|
||||
var private string SystemPlayerRank;
|
||||
var private TextColor SystemPlayerColor;
|
||||
var private Fields SystemPlayerApplyColorToFields;
|
||||
var public string SystemPlayerRank;
|
||||
var public TextColor SystemPlayerColor;
|
||||
var public Fields SystemPlayerApplyColorToFields;
|
||||
|
||||
public reliable client final function ClientInit(
|
||||
array<PlayerGroupEntry> _PlayerGroups,
|
||||
array<UIDInfoEntry> _PlayerInfos,
|
||||
var private bool SystemFinished, GroupsFinished, InfosFinished;
|
||||
var private int InfosReplicateProgress, GroupsReplicateProgress;
|
||||
|
||||
var private KFScoreBoard SC;
|
||||
|
||||
public final function ClientStartReplication()
|
||||
{
|
||||
GetScoreboard();
|
||||
|
||||
ClientInitSystem(
|
||||
SystemAdminRank,
|
||||
SystemAdminColor,
|
||||
SystemAdminApplyColorToFields,
|
||||
SystemPlayerRank,
|
||||
SystemPlayerColor,
|
||||
SystemPlayerApplyColorToFields);
|
||||
|
||||
SetTimer(0.01f, true, nameof(ClientReplicateGroups));
|
||||
SetTimer(0.01f, true, nameof(ClientReplicateInfos));
|
||||
}
|
||||
|
||||
public final function ClientReplicateGroups()
|
||||
{
|
||||
if (GroupsReplicateProgress < PlayerGroups.Length)
|
||||
{
|
||||
ClientAddPlayerGroup(PlayerGroups[GroupsReplicateProgress]);
|
||||
++GroupsReplicateProgress;
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearTimer(nameof(ClientReplicateGroups));
|
||||
GroupReplicationFinished();
|
||||
}
|
||||
}
|
||||
|
||||
public final function ClientReplicateInfos()
|
||||
{
|
||||
if (InfosReplicateProgress < PlayerInfos.Length)
|
||||
{
|
||||
ClientAddPlayerInfo(PlayerInfos[InfosReplicateProgress]);
|
||||
++InfosReplicateProgress;
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearTimer(nameof(ClientReplicateInfos));
|
||||
InfosReplicationFinished();
|
||||
}
|
||||
}
|
||||
|
||||
private reliable client final function GetScoreboard()
|
||||
{
|
||||
if (SC != None)
|
||||
{
|
||||
ClearTimer(nameof(GetScoreboard));
|
||||
return;
|
||||
}
|
||||
|
||||
SC = ScoreboardExtHUD(GetALocalPlayerController().myHUD).Scoreboard;
|
||||
SetTimer(0.1f, false, nameof(GetScoreboard));
|
||||
}
|
||||
|
||||
private reliable client final function ClientAddPlayerGroup(PlayerGroupEntry Group)
|
||||
{
|
||||
PlayerGroups.AddItem(Group);
|
||||
}
|
||||
|
||||
private reliable client final function ClientAddPlayerInfo(UIDInfoEntry PlayerInfo)
|
||||
{
|
||||
PlayerInfos.AddItem(PlayerInfo);
|
||||
}
|
||||
|
||||
private reliable client final function GroupReplicationFinished()
|
||||
{
|
||||
GroupsFinished = true;
|
||||
ClientGroupsApply();
|
||||
}
|
||||
|
||||
private reliable client final function InfosReplicationFinished()
|
||||
{
|
||||
InfosFinished = true;
|
||||
ClientInfosApply();
|
||||
}
|
||||
|
||||
private reliable client final function ClientInitSystem(
|
||||
string _SystemAdminRank,
|
||||
TextColor _SystemAdminColor,
|
||||
Fields _SystemAdminApplyColorToFields,
|
||||
@ -21,8 +102,6 @@ public reliable client final function ClientInit(
|
||||
TextColor _SystemPlayerColor,
|
||||
Fields _SystemPlayerApplyColorToFields)
|
||||
{
|
||||
PlayerGroups = _PlayerGroups;
|
||||
PlayerInfos = _PlayerInfos;
|
||||
SystemAdminRank = _SystemAdminRank;
|
||||
SystemAdminColor = _SystemAdminColor;
|
||||
SystemAdminApplyColorToFields = _SystemAdminApplyColorToFields;
|
||||
@ -30,22 +109,17 @@ public reliable client final function ClientInit(
|
||||
SystemPlayerColor = _SystemPlayerColor;
|
||||
SystemPlayerApplyColorToFields = _SystemPlayerApplyColorToFields;
|
||||
|
||||
ClientApply();
|
||||
ClientSystemApply();
|
||||
}
|
||||
|
||||
private reliable client final function ClientApply()
|
||||
private reliable client final function ClientSystemApply()
|
||||
{
|
||||
local KFScoreBoard SC;
|
||||
|
||||
SC = ScoreboardExtHUD(PlayerController(Owner).myHUD).Scoreboard;
|
||||
if (SC == None)
|
||||
{
|
||||
SetTimer(0.5f, false, nameof(ClientApply));
|
||||
SetTimer(0.1f, false, nameof(ClientSystemApply));
|
||||
return;
|
||||
}
|
||||
|
||||
SC.PlayerGroups = PlayerGroups;
|
||||
SC.PlayerInfos = PlayerInfos;
|
||||
SC.SystemAdminRank = SystemAdminRank;
|
||||
SC.SystemAdminColor = SystemAdminColor;
|
||||
SC.SystemAdminApplyColorToFields = SystemAdminApplyColorToFields;
|
||||
@ -53,10 +127,48 @@ private reliable client final function ClientApply()
|
||||
SC.SystemPlayerColor = SystemPlayerColor;
|
||||
SC.SystemPlayerApplyColorToFields = SystemPlayerApplyColorToFields;
|
||||
|
||||
SystemFinished = true;
|
||||
Finished();
|
||||
}
|
||||
|
||||
private reliable client final function ClientGroupsApply()
|
||||
{
|
||||
if (SC == None)
|
||||
{
|
||||
SetTimer(0.1f, false, nameof(ClientGroupsApply));
|
||||
return;
|
||||
}
|
||||
|
||||
SC.PlayerGroups = PlayerGroups;
|
||||
GroupsFinished = true;
|
||||
Finished();
|
||||
}
|
||||
|
||||
private reliable client final function ClientInfosApply()
|
||||
{
|
||||
if (SC == None)
|
||||
{
|
||||
SetTimer(0.1f, false, nameof(ClientInfosApply));
|
||||
return;
|
||||
}
|
||||
|
||||
SC.PlayerInfos = PlayerInfos;
|
||||
GroupsFinished = true;
|
||||
Finished();
|
||||
}
|
||||
|
||||
private reliable client final function Finished()
|
||||
{
|
||||
if (SystemFinished && GroupsFinished && InfosFinished)
|
||||
Destroy();
|
||||
}
|
||||
|
||||
defaultproperties
|
||||
{
|
||||
InfosReplicateProgress=0
|
||||
GroupsReplicateProgress=0
|
||||
|
||||
SystemFinished=false
|
||||
GroupsFinished=false
|
||||
InfosFinished=false
|
||||
}
|
5
ScoreboardExt/Classes/SteamGroups.uc
Normal file
5
ScoreboardExt/Classes/SteamGroups.uc
Normal file
@ -0,0 +1,5 @@
|
||||
class SteamGroups extends Object
|
||||
dependson(Types)
|
||||
config(ScoreboardExt);
|
||||
|
||||
var config array<SteamGroupEntry> SteamGroup;
|
@ -45,6 +45,12 @@ struct PlayerGroupEntry
|
||||
var Fields ApplyColorToFields;
|
||||
};
|
||||
|
||||
struct SteamGroupEntry
|
||||
{
|
||||
var string SteamGroupID;
|
||||
var int GroupID;
|
||||
};
|
||||
|
||||
struct PlayerInfoEntry
|
||||
{
|
||||
var string PlayerID;
|
||||
|
Loading…
Reference in New Issue
Block a user