Skip to content

Commit

Permalink
1.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanx111 committed Dec 18, 2023
1 parent d48bed6 commit 08654c7
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 19 deletions.
12 changes: 9 additions & 3 deletions Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ public class ResetScoreConfig : BasePluginConfig
[JsonPropertyName("ResetScoreChatTag")]
public string ResetScoreChatTag { get; set; } = "{Red}[Resetscore]{Default}";

[JsonPropertyName("OnlyAdmins")]
public bool OnlyAdmins { get; set; } = false;
[JsonPropertyName("ResetScoreOnlyVip")]
public bool ResetScoreOnlyVip { get; set; } = false;

[JsonPropertyName("SetScoreAdminFlag")]
public string SetScoreAdminFlag { get; set; } = "@css/cheats";

[JsonPropertyName("ResetScoreVipFlag")]
public string ResetScoreVipFlag { get; set; } = "@css/vip";

public int Version { get; set; } = 3;
public int Version { get; set; } = 4;

Check warning on line 20 in Config.cs

View workflow job for this annotation

GitHub Actions / Build on ubuntu-latest

'ResetScoreConfig.Version' hides inherited member 'BasePluginConfig.Version'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword.

Check warning on line 20 in Config.cs

View workflow job for this annotation

GitHub Actions / Build on ubuntu-latest

'ResetScoreConfig.Version' hides inherited member 'BasePluginConfig.Version'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword.

Check warning on line 20 in Config.cs

View workflow job for this annotation

GitHub Actions / Build on ubuntu-latest

'ResetScoreConfig.Version' hides inherited member 'BasePluginConfig.Version'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword.

Check warning on line 20 in Config.cs

View workflow job for this annotation

GitHub Actions / Build on ubuntu-latest

'ResetScoreConfig.Version' hides inherited member 'BasePluginConfig.Version'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword.
}
}
30 changes: 20 additions & 10 deletions ResetScore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ public class ResetScore : BasePlugin, IPluginConfig<ResetScoreConfig>
{
public override string ModuleAuthor => "StefanX";
public override string ModuleName => "ResetScore";
public override string ModuleVersion => "1.0.3";
public override string ModuleVersion => "1.0.4";

public ResetScoreConfig Config { get; set; } = new();

public override void Load(bool hotReload)
{
Logger.LogInformation("ResetScore loaded!");
Logger.LogInformation($"ResetScore loaded {ModuleVersion} !");
}

public void OnConfigParsed(ResetScoreConfig config)
Expand All @@ -36,9 +36,8 @@ public void OnConfigParsed(ResetScoreConfig config)
[ConsoleCommand("rs", "ResetScore")]
public void OnResetScoreCommand(CCSPlayerController? player, CommandInfo command)
{
if(!IsAdmin(player) && Config.OnlyAdmins){
player!.PrintToChat($" {Config.ResetScoreChatTag} " + Localizer["resetscore.onlyadmins"]);

if(!ResetScoreVipFlag(player) && Config.ResetScoreOnlyVip){
player!.PrintToChat($" {Config.ResetScoreChatTag} " + Localizer["resetscore.resetscore.onlyvips"]);
return;
}

Expand All @@ -48,9 +47,14 @@ public void OnResetScoreCommand(CCSPlayerController? player, CommandInfo command

[ConsoleCommand("setscore", "ResetScore")]
[CommandHelper(minArgs: 7, usage: "<target> <kiils> <deaths> <assists> <damage> <mvps> <score>", whoCanExecute: CommandUsage.CLIENT_ONLY)]
[RequiresPermissions("@resetscore/admin")]
public void OnSetScoreCommand(CCSPlayerController? player, CommandInfo command)
{
if(!SetScoreAdminFlag(player))
{
player!.PrintToChat($" {Config.ResetScoreChatTag} " + Localizer["resetscore.setscore.onlyadmins"]);
return;
}

var arg = command.GetCommandString;
var splitCmdArgs = Regex.Matches(command.ArgByIndex(1), @"[\""].+?[\""]|[^ ]+").Select(m => m.Value).ToArray();

Expand All @@ -65,8 +69,9 @@ public void OnSetScoreCommand(CCSPlayerController? player, CommandInfo command)
player!.PrintToChat($" {Config.ResetScoreChatTag} " + Localizer["resetscore.setscore.message", target.PlayerName]);
}
}

}

private void SetScore(CCSPlayerController? player, int kills, int deaths, int assists, int damage, int mvps, int score)
{
player!.ActionTrackingServices!.MatchStats.Kills = kills;
Expand Down Expand Up @@ -96,9 +101,14 @@ private string ModifyColorValue(string msg)
return string.IsNullOrEmpty(msg) ? $"{ChatColors.Red}[ResetScore]{ChatColors.Default} " : msg;
}

private bool IsAdmin(CCSPlayerController? playerController)
private bool SetScoreAdminFlag(CCSPlayerController? playerController)
{
return AdminManager.PlayerHasPermissions(playerController, Config.SetScoreAdminFlag);
}

private bool ResetScoreVipFlag(CCSPlayerController? playerController)
{
return AdminManager.PlayerHasPermissions(playerController, "@resetscore/admin");
return AdminManager.PlayerHasPermissions(playerController, Config.ResetScoreVipFlag);
}
}
}
3 changes: 2 additions & 1 deletion lang/de.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"resetscore.onlyadmins": "Dieser Befehl ist nur für Administratoren !",
"resetscore.resetscore.onlyvips": "Dieser Befehl ist nur für vips !",
"resetscore.setscore.onlyadmins": "Dieser Befehl ist nur für Administratoren !",
"resetscore.resetscore.message": "Dein Punktestand wurde zurückgesetzt !",
"resetscore.setscore.message": "{Gold}{0:s}{Default} Punktestand wurde festgelegt !"
}
3 changes: 2 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"resetscore.onlyadmins": "This command is only for admins !",
"resetscore.resetscore.onlyvips": "This command is only for vips !",
"resetscore.setscore.onlyadmins": "This command is only for admins !",
"resetscore.resetscore.message": "Your score has been reset !",
"resetscore.setscore.message": "{Gold}{0:s}{Default} score has been set !"
}
3 changes: 2 additions & 1 deletion lang/fr.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"resetscore.onlyadmins": "Cette commande est réservée aux administrateurs !",
"resetscore.resetscore.onlyvips": "Cette commande est réservée aux vips !",
"resetscore.setscore.onlyadmins": "Cette commande est réservée aux administrateurs !",
"resetscore.resetscore.message": "Votre score a été réinitialisé !",
"resetscore.setscore.message": "{Gold}{0:s}{Default} score a été défini !"
}
3 changes: 2 additions & 1 deletion lang/lv.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"resetscore.onlyadmins": "Šī komanda ir pieejama tikai adminiem !",
"resetscore.resetscore.onlyvips": "Šī komanda ir pieejama tikai vipi !",
"resetscore.setscore.onlyadmins": "Šī komanda ir pieejama tikai adminiem !",
"resetscore.resetscore.message": "Tavs rekords tika izdzēsts !",
"resetscore.setscore.message": "{Gold}{0:s}{Default} Tavs rekords tika nomainīts !"
}
3 changes: 2 additions & 1 deletion lang/pt-BR.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"resetscore.onlyadmins": "Este comando é apenas para administradores !",
"resetscore.resetscore.onlyvips": "Este comando é apenas para vips !",
"resetscore.setscore.onlyadmins": "Este comando é apenas para administradores !",
"resetscore.resetscore.message": "Seu score foi zerado !",
"resetscore.setscore.message": "{Gold}{0:s}{Default} score foi definido !"
}
3 changes: 2 additions & 1 deletion lang/ro.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"resetscore.onlyadmins": "Aceasta comanda este doar pentru admini !",
"resetscore.resetscore.onlyvips": "Aceasta comanda este doar pentru vipi !",
"resetscore.setscore.onlyadmins": "Aceasta comanda este doar pentru admini !",
"resetscore.resetscore.message": "Scorul tau a fost resetat !",
"resetscore.setscore.message": "Scorul jucatorului {Gold}{0:s}{Default} a fost setat !"
}

0 comments on commit 08654c7

Please sign in to comment.