Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions Config/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ namespace InfoTop_COFYYE.Config
{
public class Config : BasePluginConfig
{
[JsonPropertyName("prefix")]
public string Prefix { get; init; } = "{lightpurple}[InfoTop] {orange}»» ";

[JsonPropertyName("enable_welcome_msg")]
public bool EnableWelcomeMsg { get; init; } = true;

Expand Down Expand Up @@ -57,9 +60,9 @@ public class Config : BasePluginConfig
["welcome_message_1"] = new()
{
["sr"] =
"{lightpurple}[Info] {orange}★彡 {yellow}Dobrodosli na{orange}【 {lime}{HOSTNAME}{orange} 】彡★",
"{orange}★彡 {yellow}Dobrodosli na{orange}【 {lime}{HOSTNAME}{orange} 】彡★",
["en"] =
"{lightpurple}[Info] {orange}★彡 {yellow}Welcome to{orange}【 {lime}{HOSTNAME}{orange} 】彡★",
"{orange}★彡 {yellow}Welcome to{orange}【 {lime}{HOSTNAME}{orange} 】彡★",
},
};

Expand All @@ -69,10 +72,8 @@ public class Config : BasePluginConfig
{
["addip_message_1"] = new()
{
["sr"] =
"{lightpurple}[Info] {yellow}Dodajte IP u favorites {orange}➤➤ {lime}127.0.0.1:27015",
["en"] =
"{lightpurple}[Info] {yellow}Add IP to favorites {orange}➤➤ {lime}127.0.0.1:27015",
["sr"] = "{yellow}Dodajte IP u favorites {orange}➤➤ {lime}{IP}",
["en"] = "{yellow}Add IP to favorites {orange}➤➤ {lime}{IP}",
},
};

Expand All @@ -83,9 +84,9 @@ public class Config : BasePluginConfig
["infotop_text_message_1"] = new()
{
["sr"] =
"{lightpurple}[Info] {yellow}Runda: {lime}{CURRENT_ROUNDS}{yellow}/{lime}{MAX_ROUNDS} {orange}• {yellow}Mapa: {lime}{CURRENT_MAP} {orange}• {yellow}Igraci: {lime}{CURRENT_PLAYERS}{yellow}/{lime}{MAX_PLAYERS}",
"{yellow}Runda: {lime}{CURRENT_ROUNDS}{yellow}/{lime}{MAX_ROUNDS} {NEXTLINE} {yellow}Mapa: {lime}{CURRENT_MAP} {NEXTLINE} {yellow}Igraci: {lime}{CURRENT_PLAYERS}{yellow}/{lime}{MAX_PLAYERS}",
["en"] =
"{lightpurple}[Info] {yellow}Round: {lime}{CURRENT_ROUNDS}{yellow}/{lime}{MAX_ROUNDS} {orange}• {yellow}Map: {lime}{CURRENT_MAP} {orange}• {yellow}Players: {lime}{CURRENT_PLAYERS}{yellow}/{lime}{MAX_PLAYERS}",
"{yellow}Round: {lime}{CURRENT_ROUNDS}{yellow}/{lime}{MAX_ROUNDS} {NEXTLINE} {yellow}Map: {lime}{CURRENT_MAP} {NEXTLINE} {yellow}Players: {lime}{CURRENT_PLAYERS}{yellow}/{lime}{MAX_PLAYERS}",
},
};

Expand All @@ -95,14 +96,19 @@ public class Config : BasePluginConfig
{
["hud_message_1"] = new()
{
["sr"] = "Dodajte IP u favorites ➤➤ 127.0.0.1:27015",
["en"] = "Add IP to favorites ➤➤ 127.0.0.1:27015",
["sr"] = "Dodajte IP u favorites ➤➤ {IP}",
["en"] = "Add IP to favorites ➤➤ {IP}",
},
["hud_message_2"] = new()
{
["sr"] = "Pridruzite se nasem Discord serveru, kucaj !discord",
["en"] = "Join our Discord server, say !discord",
},
["hud_message_3"] = new()
{
["sr"] = "Zdravo {PLAYER_NAME}, uzivaj u igri!",
["en"] = "Hello {PLAYER_NAME}, enjoy the game!",
},
};
}
}
80 changes: 37 additions & 43 deletions InfoTop-COFYYE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace InfoTop_COFYYE
public class InfoTopCOFYYE : BasePlugin, IPluginConfig<Config.Config>
{
public override string ModuleName => "InfoTop";
public override string ModuleVersion => "1.2";
public override string ModuleVersion => "1.3";
public override string ModuleAuthor => "cofyye";
public override string ModuleDescription => "https://github.com/cofyye";

Expand Down Expand Up @@ -158,66 +158,60 @@ public HookResult RoundStartHandler(EventRoundStart @event, GameEventInfo info)
return HookResult.Continue;
}

var hostname = ConVar.Find("hostname")?.StringValue;
var maxRounds = ConVar.Find("mp_maxrounds")?.GetPrimitiveValue<int>();
var ctScore = 0;
var ttScore = 0;

var teamManagers = Utilities.FindAllEntitiesByDesignerName<CCSTeam>("cs_team_manager");

foreach (var teamManager in teamManagers)
{
if ((CsTeam)teamManager.TeamNum == CsTeam.Terrorist)
{
ttScore += teamManager.Score;
}
if ((CsTeam)teamManager.TeamNum == CsTeam.CounterTerrorist)
{
ctScore += teamManager.Score;
}
}

var prefix = Config?.Prefix ?? "{lightpurple}[InfoTop] {orange}»» ";
var players = Utilities.GetPlayers().Where(p => PlayerUtils.IsValidPlayer(p)).ToList();

foreach (var player in players)
{
if (Config?.EnableWelcomeMsg == true)
{
var localizerWelcome =
GlobalVariables
.WelcomeMessageProvider?.GetWelcomeMessage(
player.GetLanguage().TwoLetterISOLanguageName ?? "en"
)
.Replace("{HOSTNAME}", hostname) ?? "Message not available";

player.PrintToChat(StringExtensions.ReplaceColorTags(localizerWelcome));
var message =
GlobalVariables.WelcomeMessageProvider?.GetWelcomeMessage(
player.GetLanguage().TwoLetterISOLanguageName ?? "en"
) ?? "Message not available";

var processedMessage = MessageUtils.ReplaceMessageParameters(message, player);
var lines = processedMessage.Split(["{NEXTLINE}"], StringSplitOptions.None);

foreach (var line in lines)
{
var fullText = prefix + line;
player.PrintToChat(StringExtensions.ReplaceColorTags(fullText));
}
}

if (Config?.EnableAddIpMsg == true)
{
var localizerAddIP =
var message =
GlobalVariables.AddIpProvider?.GetAddIpMessage(
player.GetLanguage().TwoLetterISOLanguageName ?? "en"
) ?? "Message not available";

player.PrintToChat(StringExtensions.ReplaceColorTags(localizerAddIP));
var processedMessage = MessageUtils.ReplaceMessageParameters(message, player);
var lines = processedMessage.Split(["{NEXTLINE}"], StringSplitOptions.None);

foreach (var line in lines)
{
var fullText = prefix + line;
player.PrintToChat(StringExtensions.ReplaceColorTags(fullText));
}
}

if (Config?.EnableInfoTopText == true)
{
var localizerText =
GlobalVariables
.InfoTopTextProvider?.GetInfoTopTextMessage(
player.GetLanguage().TwoLetterISOLanguageName ?? "en"
)
.Replace("{CURRENT_ROUNDS}", (ttScore + ctScore).ToString())
.Replace("{MAX_ROUNDS}", maxRounds.ToString())
.Replace("{CURRENT_MAP}", Server.MapName)
.Replace("{CURRENT_PLAYERS}", Utilities.GetPlayers().Count.ToString())
.Replace("{MAX_PLAYERS}", Server.MaxPlayers.ToString())
?? "Message not available";

player.PrintToChat(StringExtensions.ReplaceColorTags(localizerText));
var message =
GlobalVariables.InfoTopTextProvider?.GetInfoTopTextMessage(
player.GetLanguage().TwoLetterISOLanguageName ?? "en"
) ?? "Message not available";

var processedMessage = MessageUtils.ReplaceMessageParameters(message, player);
var lines = processedMessage.Split(["{NEXTLINE}"], StringSplitOptions.None);

foreach (var line in lines)
{
var fullText = prefix + line;
player.PrintToChat(StringExtensions.ReplaceColorTags(fullText));
}
}
}

Expand Down
1 change: 1 addition & 0 deletions InfoTop-COFYYE.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<OutDir>./build/$(MSBuildProjectName)</OutDir>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<ItemGroup>
Expand Down
Loading