1
0

7 Commits

Author SHA1 Message Date
97866c1a55 update description 2022-08-14 14:46:39 +03:00
2461bda5f7 update description 2022-08-14 14:44:31 +03:00
8d02c1e0a3 update description 2022-08-14 14:37:30 +03:00
3379596de4 add VoteTime setting 2022-08-14 14:17:50 +03:00
a881c1ef93 update description 2022-08-13 18:08:18 +03:00
5faba66cb1 update kick vote 2022-08-13 14:13:47 +03:00
51aba2c1a1 update russian localization 2022-08-12 03:38:26 +03:00
9 changed files with 75 additions and 56 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';
@ -79,6 +79,8 @@ private function PreInit()
case `NO_CONFIG:
`Log_Info("Config created");
case 1:
case MaxInt:
`Log_Info("Config updated to version"@LatestVersion);
break;
@ -224,15 +226,10 @@ private function bool PlayerHasRequiredLevel(KFPlayerController KFPC)
return (KFPRI.GetActivePerkLevel() >= CfgStartWaveKickProtection.default.MinLevel);
}
public function bool PlayerCanKickVote(KFPlayerController KFPC, optional KFPlayerController KFPC_Kickee)
public function bool PlayerCanStartKickVote(KFPlayerController KFPC, KFPlayerController KFPC_Kickee)
{
`Log_Trace();
if (KFPC_Kickee == None)
{
KFPC_Kickee = KFPlayerController(KFGRI.VoteCollector.CurrentKickVote.PlayerPRI.Owner);
}
if (KFPC_Kickee != None)
{
if (KFPC == KFPC_Kickee)

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

@ -7,8 +7,8 @@ var private localized String PlayerIsKickProtected;
var const String PlayerIsStartWaveKickProtectedDefault;
var private localized String PlayerIsStartWaveKickProtected;
var const String PlayerCantVoteDefault;
var private localized String PlayerCantVote;
var const String PlayerCantStartKickVoteDefault;
var private localized String PlayerCantStartKickVote;
var const String KickVoteNotEnoughPlayersDefault;
var private localized String KickVoteNotEnoughPlayers;
@ -44,7 +44,7 @@ enum E_CVC_LocalMessageType
{
CVC_PlayerIsKickProtected,
CVC_PlayerIsStartWaveKickProtected,
CVC_PlayerCantVote,
CVC_PlayerCantStartKickVote,
CVC_KickVoteNotEnoughPlayers,
CVC_KickVoteStarted,
@ -97,8 +97,8 @@ public static function String GetLocalizedString(
case CVC_PlayerIsStartWaveKickProtected:
return ReplWaves(ReplKickee(default.PlayerIsStartWaveKickProtected != "" ? default.PlayerIsStartWaveKickProtected : default.PlayerIsStartWaveKickProtectedDefault, String1), String2);
case CVC_PlayerCantVote:
return ReplWaves(default.PlayerCantVote != "" ? default.PlayerCantVote : default.PlayerCantVoteDefault, String1);
case CVC_PlayerCantStartKickVote:
return ReplWaves(default.PlayerCantStartKickVote != "" ? default.PlayerCantStartKickVote : default.PlayerCantStartKickVoteDefault, String1);
case CVC_KickVoteNotEnoughPlayers:
return ReplWaves(default.KickVoteNotEnoughPlayers != "" ? default.KickVoteNotEnoughPlayers : default.KickVoteNotEnoughPlayersDefault, String1);
@ -147,7 +147,7 @@ defaultproperties
{
PlayerIsKickProtectedDefault = "<kickee> is protected from kick"
PlayerIsStartWaveKickProtectedDefault = "You can't kick <kickee> right now. He can be kicked when he plays at least <waves> wave(s)"
PlayerCantVoteDefault = "You can't vote for kick now. You can vote when you play at least <waves> wave(s)"
PlayerCantStartKickVoteDefault = "You can't start kick vote now. You can start kick vote when you play at least <waves> wave(s)"
KickVoteNotEnoughPlayersDefault = "Not enough players to start vote (only players who have played at least <waves> wave(s) can vote)"
KickVoteStartedDefault = "<kicker> has started a vote to kick <kickee>"
KickVoteStartedForPlayerDefault = "<kicker> started voting to kick you"

View File

@ -46,7 +46,6 @@ public function ServerStartVoteKick(PlayerReplicationInfo PRI_Kickee, PlayerRepl
{
local Array<KFPlayerReplicationInfo> KFPRIs;
local KFPlayerReplicationInfo KFPRI;
local KFPlayerController KFPC;
local KFGameInfo KFGI;
`Log_Trace();
@ -70,11 +69,11 @@ public function ServerStartVoteKick(PlayerReplicationInfo PRI_Kickee, PlayerRepl
return;
}
if (!CVC.PlayerCanKickVote(KFPC_Kicker, KFPC_Kickee))
if (!CVC.PlayerCanStartKickVote(KFPC_Kicker, KFPC_Kickee))
{
CVC.WriteToChatLocalized(
KFPC_Kicker,
CVC_PlayerCantVote,
CVC_PlayerCantStartKickVote,
CfgKickVote.default.WarningColorHex,
String(CfgStartWaveKickProtection.default.Waves));
return;
@ -164,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 || !CVC.PlayerCanKickVote(KFPlayerController(KFPRI.Owner))));
KFPRI.ShowKickVote(PRI_Kickee, CfgKickVote.default.VoteTime, !(KFPRI == PRI_Kicker || KFPRI == PRI_Kickee));
}
if (CfgKickVote.default.bChatNotifications)
@ -180,25 +179,7 @@ public function ServerStartVoteKick(PlayerReplicationInfo PRI_Kickee, PlayerRepl
KFPC_Kickee,
CVC_KickVoteStartedForPlayer,
CfgKickVote.default.NegativeColorHex,
KickerName,
KickeeName);
foreach KFPRIs(KFPRI)
{
if (KFPRI == PRI_Kickee)
{
continue;
}
KFPC = KFPlayerController(KFPRI.Owner);
if (!CVC.PlayerCanKickVote(KFPC))
{
CVC.WriteToChatLocalized(
KFPC,
CVC_PlayerCantVote,
CfgKickVote.default.WarningColorHex,
String(CfgStartWaveKickProtection.default.Waves));
}
}
KickerName);
}
else
{
@ -216,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);
}
@ -260,7 +241,7 @@ private function int VotingPlayers(optional PlayerReplicationInfo KickeePRI, opt
foreach KFPRIs(KFPRI)
{
KFPC = KFPlayerController(KFPRI.Owner);
if (KFPC != None && CVC.PlayerCanKickVote(KFPC, KFPC_Kickee))
if (KFPC != None && KFPC != KFPC_Kickee)
{
VotingPlayersNum++;
}
@ -401,7 +382,7 @@ public reliable server function RecieveVoteKick(PlayerReplicationInfo PRI, bool
{
CVC.BroadcastHUDLocalized(
CVC_KickVoteStartedHUD,
float(VoteTime),
float(CfgKickVote.default.VoteTime),
KickerName,
KickeeName,
YesVotesPlayers);
@ -410,7 +391,7 @@ public reliable server function RecieveVoteKick(PlayerReplicationInfo PRI, bool
{
CVC.BroadcastHUDLocalized(
CVC_KickVoteReceivedHUD,
float(VoteTime),
float(CfgKickVote.default.VoteTime),
YesVotesPlayers,
NoVotesPlayers);
}
@ -569,7 +550,7 @@ private function LogKickVotes()
}
`Log_Kick("Kicker:" @ LogVotePlayer(Kicker));
`Log_Kick("Kicked:" @ LogVotePlayer(Kickee) @ String(Kickee.Perk) @ String(Kickee.Level));
`Log_Kick("Kicked:" @ LogVotePlayer(Kickee));
`Log_Kick("Yes voters:");
foreach Yes(KV) `Log_Kick(LogVotePlayer(KV));
@ -584,7 +565,18 @@ private function String LogVotePlayer(S_KickVote KV)
{
`Log_Trace();
return KV.Name @ "(UniqueID:" @ KV.UniqueID $ (KV.SteamID == "" ? "" : (", SteamID:" @ KV.SteamID $ ", Profile:" @ "https://steamcommunity.com/profiles/" $ KV.SteamID)) $ ")";
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)
@ -611,7 +603,7 @@ public reliable server function RecieveVoteSkipTrader(PlayerReplicationInfo PRI,
{
CVC.BroadcastHUDLocalized(
CVC_VoteProgressHUD,
float(VoteTime),
float(CfgSkipTraderVote.default.VoteTime),
VotedPlayers(),
DidntVotedPlayers());
}
@ -638,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;
@ -662,7 +665,7 @@ public reliable server function ReceiveVotePauseGame(PlayerReplicationInfo PRI,
{
CVC.BroadcastHUDLocalized(
CVC_VoteProgressHUD,
float(VoteTime),
float(CfgPauseVote.default.VoteTime),
VotedPlayers(),
DidntVotedPlayers());
}

Binary file not shown.

Binary file not shown.

View File

@ -1,4 +1,4 @@
[img]https://img.shields.io/static/v1?logo=GitHub&labelColor=gray&color=blue&logoColor=white&label=&message=Open Source[/img] [img]https://img.shields.io/github/license/GenZmeY/KF2-ControlledVoteCollector[/img] [img]https://img.shields.io/steam/subscriptions/2847465899[/img] [img]https://img.shields.io/steam/favorites/2847465899[/img] [img]https://img.shields.io/steam/update-date/2847465899[/img] [url=https://steamcommunity.com/sharedfiles/filedetails/changelog/2847465899][img]https://img.shields.io/github/v/tag/GenZmeY/KF2-ControlledVoteCollector[/img][/url]
[img]https://img.shields.io/static/v1?logo=GitHub&labelColor=gray&color=blue&logoColor=white&label=&message=Open Source[/img] [img]https://img.shields.io/github/license/GenZmeY/KF2-ControlledVoteCollector[/img] [img]https://img.shields.io/steam/favorites/2847465899[/img] [img]https://img.shields.io/steam/update-date/2847465899[/img] [url=https://steamcommunity.com/sharedfiles/filedetails/changelog/2847465899][img]https://img.shields.io/github/v/tag/GenZmeY/KF2-ControlledVoteCollector[/img][/url]
[h1]Description[/h1]
New vote collector with improvements and features.
@ -32,7 +32,7 @@ No. This mod is not whitelisted and will de-rank your server. Any XP gained will
[/olist]
[h1]Setup (KFCVC.ini)[/h1]
Config will be created at the first start.
Config will be created at the first start[b]*[/b].
[b][CVC.MapStat][/b]
[list]
@ -69,7 +69,8 @@ This section sets the next map when no one voted for the map.
[*][b]PositiveColorHex[/b] - hex color for yes vote in chat;
[*][b]NegativeColorHex[/b] - hex color for no vote in chat;
[*][b]bHudNotifications[/b] - set to [b]True[/b] to see player votes in HUD;
[*][b]DefferedClearHUD[/b] - HUD notification will remain on the screen for the specified number of seconds after voting ends.
[*][b]DefferedClearHUD[/b] - HUD notification will remain on the screen for the specified number of seconds after voting ends;
[*][b]VoteTime[/b] - time in seconds for voting (will be automatically reduced if it exceeds the trader's remaining time).
[/list]
[b][CVC.PauseVote][/b]
@ -78,7 +79,8 @@ This section sets the next map when no one voted for the map.
[*][b]PositiveColorHex[/b] - hex color for yes vote in chat;
[*][b]NegativeColorHex[/b] - hex color for no vote in chat;
[*][b]bHudNotifications[/b] - set to [b]True[/b] to see player votes in HUD;
[*][b]DefferedClearHUD[/b] - HUD notification will remain on the screen for the specified number of seconds after voting ends.
[*][b]DefferedClearHUD[/b] - HUD notification will remain on the screen for the specified number of seconds after voting ends;
[*][b]VoteTime[/b] - time in seconds for voting (will be automatically reduced if it exceeds the trader's remaining time).
[/list]
[b][CVC.KickVote][/b]
@ -92,7 +94,8 @@ This section sets the next map when no one voted for the map.
[*][b]DefferedClearHUD[/b] - HUD notification will remain on the screen for the specified number of seconds after voting ends.
[*][b]bLogKickVote[/b] - set to [b]True[/b] to log information about every kick vote;
[*][b]MinVotingPlayersToStartKickVote[/b] - minimum number of voting players to start kick voting;
[*][b]MaxKicks[/b] - maximum number of kicks per game.
[*][b]MaxKicks[/b] - maximum number of kicks per game;
[*][b]VoteTime[/b] - time in seconds for voting.
[/list]
[b][CVC.KickProtected][/b]
@ -104,18 +107,26 @@ This section sets the next map when no one voted for the map.
[b][CVC.StartWaveKickProtection][/b]
In this section, the system for preventing early kicks is configured (especially for lazy ass admins like me who don't want to consider player complaints about this).
[list]
[*][b]Waves[/b] - the number of waves during which a new player has kick protection and cannot vote for a kick;
[*][b]Waves[/b] - the number of waves during which a new player has kick protection and cannot start kick vote;
[*][b]MinLevel[/b] - the minimum level that a player needs to have in order to receive protection from a kick after joining the server.
[/list]
[b]How start wave kick protection works:[/b]
When a player joins a server, he is protected from a kick for the specified number of [b]Waves[/b]. This keeps the server from being taken over by players, and it also forces current players to play with the new player for at least a little bit before they can kick him. This solves most of the unfair kicks in the game.
Along with receiving the kick protection, the new player loses the ability to vote for the kick. This eliminates the ability for new players to remove existing players using kick protection for impunity.
Along with receiving the kick protection, the new player loses the ability to start kick vote. This eliminates the ability for new players to remove existing players using kick protection for impunity.
When the player has played the specified number of [b]Waves[/b], he loses the kick protection and gets the opportunity to vote for the kick.
When the player has played the specified number of [b]Waves[/b], he loses the kick protection and gets the opportunity to start kick vote.
The [b]MinLevel[/b] parameter specifies an exception to these rules, giving kick protection only to players above or equal the specified level. All players can vote to exclude players with an unsuitable level, regardless of whether they have played enough [b]Waves[/b] or not. This allows to remove low-level players without waiting for them to screw up in the game.
[h1]Troubleshooting[/h1]
[b](*)[/b] If your config is not created for some reason, create it manually with the following content:
[b][CVC.CVC]
Version=0
[/b]
Then start the server and check the file again - config content should be generated.
[h1]Sources[/h1]
[url=https://github.com/GenZmeY/KF2-ControlledVoteCollector]https://github.com/GenZmeY/KF2-ControlledVoteCollector[/url] [b](GNU GPLv3)[/b]

View File

@ -1,7 +1,6 @@
# Controlled Vote Collector
[![Steam Workshop](https://img.shields.io/static/v1?message=workshop&logo=steam&labelColor=gray&color=blue&logoColor=white&label=steam%20)](https://steamcommunity.com/sharedfiles/filedetails/?id=2847465899)
[![Steam Subscriptions](https://img.shields.io/steam/subscriptions/2847465899)](https://steamcommunity.com/sharedfiles/filedetails/?id=2847465899)
[![Steam Favorites](https://img.shields.io/steam/favorites/2847465899)](https://steamcommunity.com/sharedfiles/filedetails/?id=2847465899)
[![Steam Update Date](https://img.shields.io/steam/update-date/2847465899)](https://steamcommunity.com/sharedfiles/filedetails/?id=2847465899)
[![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/GenZmeY/KF2-ControlledVoteCollector)](https://github.com/GenZmeY/KF2-ControlledVoteCollector/tags)