1
0

add VoteTime setting

This commit is contained in:
2022-08-14 14:17:50 +03:00
parent a881c1ef93
commit 3379596de4
6 changed files with 50 additions and 15 deletions

View File

@ -7,6 +7,7 @@ var public config String NegativeColorHex;
var public config bool bChatNotifications;
var public config bool bHudNotifications;
var public config float DefferedClearHUD;
var public config int VoteTime;
public static function InitConfig(int Version, int LatestVersion, E_LogLevel LogLevel)
{
@ -17,6 +18,9 @@ public static function InitConfig(int Version, int LatestVersion, E_LogLevel Log
case `NO_CONFIG:
ApplyDefault(LogLevel);
case 1:
default.VoteTime = class'KFVoteCollector'.default.VoteTime;
default: break;
}
@ -47,6 +51,12 @@ public static function Load(E_LogLevel LogLevel)
`Log_Error("DefferedClearHUD" @ "(" $ default.DefferedClearHUD $ ")" @ "must be greater than 0");
default.DefferedClearHUD = 0.0f;
}
if (default.VoteTime <= 0 || default.VoteTime > 255)
{
`Log_Error("VoteTime" @ "(" $ default.VoteTime $ ")" @ "must be in range 1-255");
default.VoteTime = class'KFVoteCollector'.default.VoteTime;
}
}
protected static function ApplyDefault(E_LogLevel LogLevel)
@ -58,6 +68,7 @@ protected static function ApplyDefault(E_LogLevel LogLevel)
default.PositiveColorHex = class'KFLocalMessage'.default.EventColor;
default.NegativeColorHex = class'KFLocalMessage'.default.InteractionColor;
default.DefferedClearHUD = 1.0f;
default.VoteTime = class'KFVoteCollector'.default.VoteTime;
}
protected static function bool IsValidHexColor(String HexColor, E_LogLevel LogLevel)

View File

@ -2,7 +2,7 @@ class CVC extends Info
dependson(CVC_LocalMessage)
config(CVC);
const LatestVersion = 1;
const LatestVersion = 2;
const CfgKickProtected = class'KickProtected';
const CfgKickVote = class'KickVote';
@ -78,6 +78,8 @@ private function PreInit()
{
case `NO_CONFIG:
`Log_Info("Config created");
case 1:
case MaxInt:
`Log_Info("Config updated to version"@LatestVersion);

View File

@ -15,19 +15,17 @@ public event PreBeginPlay()
foreach WorldInfo.DynamicActors(class'CVC', CVC)
{
`Log_Base("Found 'CVC'");
break;
}
if (CVC == None)
{
`Log_Base("Spawn 'CVC'");
CVC = WorldInfo.Spawn(class'CVC');
}
if (CVC == None)
{
`Log_Base("Can't Spawn 'CVC', Destroy...");
`Log_Base("FATAL: Can't Spawn 'CVC'");
SafeDestroy();
}
}

View File

@ -163,7 +163,7 @@ public function ServerStartVoteKick(PlayerReplicationInfo PRI_Kickee, PlayerRepl
GetKFPRIArray(KFPRIs);
foreach KFPRIs(KFPRI)
{
KFPRI.ShowKickVote(PRI_Kickee, VoteTime, !(KFPRI == PRI_Kicker || KFPRI == PRI_Kickee));
KFPRI.ShowKickVote(PRI_Kickee, CfgKickVote.default.VoteTime, !(KFPRI == PRI_Kicker || KFPRI == PRI_Kickee));
}
if (CfgKickVote.default.bChatNotifications)
@ -197,7 +197,7 @@ public function ServerStartVoteKick(PlayerReplicationInfo PRI_Kickee, PlayerRepl
AllowHudNotification = bTraderIsOpen;
}
SetTimer(VoteTime, false, nameof(ConcludeVoteKick), Self);
SetTimer(CfgKickVote.default.VoteTime, false, nameof(ConcludeVoteKick), Self);
RecieveVoteKick(PRI_Kicker, true);
}
@ -382,7 +382,7 @@ public reliable server function RecieveVoteKick(PlayerReplicationInfo PRI, bool
{
CVC.BroadcastHUDLocalized(
CVC_KickVoteStartedHUD,
float(VoteTime),
float(CfgKickVote.default.VoteTime),
KickerName,
KickeeName,
YesVotesPlayers);
@ -391,7 +391,7 @@ public reliable server function RecieveVoteKick(PlayerReplicationInfo PRI, bool
{
CVC.BroadcastHUDLocalized(
CVC_KickVoteReceivedHUD,
float(VoteTime),
float(CfgKickVote.default.VoteTime),
YesVotesPlayers,
NoVotesPlayers);
}
@ -568,6 +568,17 @@ private function String LogVotePlayer(S_KickVote KV)
return KV.Name @ "(UniqueID:" @ KV.UniqueID $ (KV.SteamID == "" ? "" : (", SteamID:" @ KV.SteamID $ ", Profile:" @ "https://steamcommunity.com/profiles/" $ KV.SteamID)) $ ")" @ "Perk:" @ Repl(String(KV.Perk), "KFPerk_", "", false) @ "Level:" @ String(KV.Level);
}
public function ServerStartVoteSkipTrader(PlayerReplicationInfo PRI)
{
`Log_Trace();
VoteTime = CfgSkipTraderVote.default.VoteTime;
Super.ServerStartVoteSkipTrader(PRI);
VoteTime = default.VoteTime;
}
public reliable server function RecieveVoteSkipTrader(PlayerReplicationInfo PRI, bool bSkip)
{
local bool MustNotify;
@ -592,7 +603,7 @@ public reliable server function RecieveVoteSkipTrader(PlayerReplicationInfo PRI,
{
CVC.BroadcastHUDLocalized(
CVC_VoteProgressHUD,
float(VoteTime),
float(CfgSkipTraderVote.default.VoteTime),
VotedPlayers(),
DidntVotedPlayers());
}
@ -619,6 +630,17 @@ public reliable server function ConcludeVoteSkipTrader()
Super.ConcludeVoteSkipTrader();
}
public function ServerStartVotePauseGame(PlayerReplicationInfo PRI)
{
`Log_Trace();
VoteTime = CfgPauseVote.default.VoteTime;
Super.ServerStartVotePauseGame(PRI);
VoteTime = default.VoteTime;
}
public reliable server function ReceiveVotePauseGame(PlayerReplicationInfo PRI, bool bSkip)
{
local bool MustNotify;
@ -643,7 +665,7 @@ public reliable server function ReceiveVotePauseGame(PlayerReplicationInfo PRI,
{
CVC.BroadcastHUDLocalized(
CVC_VoteProgressHUD,
float(VoteTime),
float(CfgPauseVote.default.VoteTime),
VotedPlayers(),
DidntVotedPlayers());
}