replication

This commit is contained in:
GenZmeY 2021-05-31 07:04:26 +03:00
parent 29abb98b4a
commit dbe955bd14
4 changed files with 183 additions and 40 deletions

View File

@ -43,40 +43,59 @@ private function InitConfig()
{ {
local PlayerGroupEntry ExampleGroup; local PlayerGroupEntry ExampleGroup;
local PlayerInfoEntry ExamplePlayer; local PlayerInfoEntry ExamplePlayer;
local SteamGroupEntry ExampleSteamGroup;
// Update from config version to current version if needed // Update from config version to current version if needed
switch (ConfigVersion) switch (ConfigVersion)
{ {
case 0: // which means there is no config right now 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.Rank = "Admin";
class'SystemAdminGroup'.default.Color.R = 250; class'SystemAdminGroup'.default.Color.R = 250;
class'SystemAdminGroup'.default.Color.G = 0; class'SystemAdminGroup'.default.Color.G = 0;
class'SystemAdminGroup'.default.Color.B = 0; class'SystemAdminGroup'.default.Color.B = 0;
class'SystemAdminGroup'.static.StaticSaveConfig();
// Default player // Default player rank
class'SystemPlayerGroup'.default.Rank = "Player"; class'SystemPlayerGroup'.default.Rank = "Player";
class'SystemPlayerGroup'.default.Color.R = 250; class'SystemPlayerGroup'.default.Color.R = 250;
class'SystemPlayerGroup'.default.Color.G = 250; class'SystemPlayerGroup'.default.Color.G = 250;
class'SystemPlayerGroup'.default.Color.B = 250; class'SystemPlayerGroup'.default.Color.B = 250;
class'SystemPlayerGroup'.static.StaticSaveConfig();
// Example group // Example rank for player(s)
ExampleGroup.ID = 0; ExampleGroup.ID = 0;
ExampleGroup.Rank = "Scoreboard Creator"; ExampleGroup.Rank = "SCE Creator";
ExampleGroup.Color.R = 130; ExampleGroup.Color.R = 130;
ExampleGroup.Color.G = 250; ExampleGroup.Color.G = 250;
ExampleGroup.Color.B = 235; ExampleGroup.Color.B = 235;
ExampleGroup.OverrideAdminRank = true; ExampleGroup.OverrideAdminRank = true;
class'PlayerGroups'.default.PlayerGroup.AddItem(ExampleGroup); class'PlayerGroups'.default.PlayerGroup.AddItem(ExampleGroup);
class'PlayerGroups'.static.StaticSaveConfig();
// Example player // Example player
ExamplePlayer.PlayerID = "76561198001617867"; // GenZmeY SteamID64 ExamplePlayer.PlayerID = "76561198001617867"; // GenZmeY SteamID64
ExamplePlayer.GroupID = ExampleGroup.ID; ExamplePlayer.GroupID = ExampleGroup.ID;
class'PlayerInfos'.default.PlayerInfo.AddItem(ExamplePlayer); 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'PlayerInfos'.static.StaticSaveConfig();
class'SteamGroups'.static.StaticSaveConfig();
case 2147483647: case 2147483647:
`log("[ScoreboardExt] Config updated to version"@CurrentVersion); `log("[ScoreboardExt] Config updated to version"@CurrentVersion);
@ -126,7 +145,7 @@ function AddPlayerInfo(Controller C)
local SClient RepClient; local SClient RepClient;
KFPC = KFPlayerController(C); KFPC = KFPlayerController(C);
if (KFPC == None || !KFPC.bIsPlayer) if (KFPC == None)
return; return;
RepClient.RepInfo = Spawn(class'ScoreboardExtRepInfo', KFPC); RepClient.RepInfo = Spawn(class'ScoreboardExtRepInfo', KFPC);
@ -134,15 +153,16 @@ function AddPlayerInfo(Controller C)
RepClients.AddItem(RepClient); RepClients.AddItem(RepClient);
RepClient.RepInfo.ClientInit( RepClient.RepInfo.PlayerInfos = UIDInfos;
class'PlayerGroups'.default.PlayerGroup, RepClient.RepInfo.PlayerGroups = class'PlayerGroups'.default.PlayerGroup;
UIDInfos, RepClient.RepInfo.SystemAdminRank = class'SystemAdminGroup'.default.Rank;
class'SystemAdminGroup'.default.Rank, RepClient.RepInfo.SystemAdminColor = class'SystemAdminGroup'.default.Color;
class'SystemAdminGroup'.default.Color, RepClient.RepInfo.SystemAdminApplyColorToFields = class'SystemAdminGroup'.default.ApplyColorToFields;
class'SystemAdminGroup'.default.ApplyColorToFields, RepClient.RepInfo.SystemPlayerRank = class'SystemPlayerGroup'.default.Rank;
class'SystemPlayerGroup'.default.Rank, RepClient.RepInfo.SystemPlayerColor = class'SystemPlayerGroup'.default.Color;
class'SystemPlayerGroup'.default.Color, RepClient.RepInfo.SystemPlayerApplyColorToFields = class'SystemPlayerGroup'.default.ApplyColorToFields;
class'SystemPlayerGroup'.default.ApplyColorToFields);
RepClient.RepInfo.ClientStartReplication();
} }
function RemovePlayerInfo(Controller C) function RemovePlayerInfo(Controller C)

View File

@ -1,19 +1,100 @@
class ScoreboardExtRepInfo extends ReplicationInfo; class ScoreboardExtRepInfo extends ReplicationInfo;
var private array<UIDInfoEntry> PlayerInfos; var public array<UIDInfoEntry> PlayerInfos;
var private array<PlayerGroupEntry> PlayerGroups; var public array<PlayerGroupEntry> PlayerGroups;
var private string SystemAdminRank; var public string SystemAdminRank;
var private TextColor SystemAdminColor; var public TextColor SystemAdminColor;
var private Fields SystemAdminApplyColorToFields; var public Fields SystemAdminApplyColorToFields;
var private string SystemPlayerRank; var public string SystemPlayerRank;
var private TextColor SystemPlayerColor; var public TextColor SystemPlayerColor;
var private Fields SystemPlayerApplyColorToFields; var public Fields SystemPlayerApplyColorToFields;
public reliable client final function ClientInit( var private bool SystemFinished, GroupsFinished, InfosFinished;
array<PlayerGroupEntry> _PlayerGroups, var private int InfosReplicateProgress, GroupsReplicateProgress;
array<UIDInfoEntry> _PlayerInfos,
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, string _SystemAdminRank,
TextColor _SystemAdminColor, TextColor _SystemAdminColor,
Fields _SystemAdminApplyColorToFields, Fields _SystemAdminApplyColorToFields,
@ -21,8 +102,6 @@ public reliable client final function ClientInit(
TextColor _SystemPlayerColor, TextColor _SystemPlayerColor,
Fields _SystemPlayerApplyColorToFields) Fields _SystemPlayerApplyColorToFields)
{ {
PlayerGroups = _PlayerGroups;
PlayerInfos = _PlayerInfos;
SystemAdminRank = _SystemAdminRank; SystemAdminRank = _SystemAdminRank;
SystemAdminColor = _SystemAdminColor; SystemAdminColor = _SystemAdminColor;
SystemAdminApplyColorToFields = _SystemAdminApplyColorToFields; SystemAdminApplyColorToFields = _SystemAdminApplyColorToFields;
@ -30,22 +109,17 @@ public reliable client final function ClientInit(
SystemPlayerColor = _SystemPlayerColor; SystemPlayerColor = _SystemPlayerColor;
SystemPlayerApplyColorToFields = _SystemPlayerApplyColorToFields; 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) if (SC == None)
{ {
SetTimer(0.5f, false, nameof(ClientApply)); SetTimer(0.1f, false, nameof(ClientSystemApply));
return; return;
} }
SC.PlayerGroups = PlayerGroups;
SC.PlayerInfos = PlayerInfos;
SC.SystemAdminRank = SystemAdminRank; SC.SystemAdminRank = SystemAdminRank;
SC.SystemAdminColor = SystemAdminColor; SC.SystemAdminColor = SystemAdminColor;
SC.SystemAdminApplyColorToFields = SystemAdminApplyColorToFields; SC.SystemAdminApplyColorToFields = SystemAdminApplyColorToFields;
@ -53,10 +127,48 @@ private reliable client final function ClientApply()
SC.SystemPlayerColor = SystemPlayerColor; SC.SystemPlayerColor = SystemPlayerColor;
SC.SystemPlayerApplyColorToFields = SystemPlayerApplyColorToFields; 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(); Destroy();
} }
defaultproperties defaultproperties
{ {
InfosReplicateProgress=0
GroupsReplicateProgress=0
SystemFinished=false
GroupsFinished=false
InfosFinished=false
} }

View File

@ -0,0 +1,5 @@
class SteamGroups extends Object
dependson(Types)
config(ScoreboardExt);
var config array<SteamGroupEntry> SteamGroup;

View File

@ -45,6 +45,12 @@ struct PlayerGroupEntry
var Fields ApplyColorToFields; var Fields ApplyColorToFields;
}; };
struct SteamGroupEntry
{
var string SteamGroupID;
var int GroupID;
};
struct PlayerInfoEntry struct PlayerInfoEntry
{ {
var string PlayerID; var string PlayerID;