From c44c5cba5e7c8757fd6b00a281c60618d4ed6c9a Mon Sep 17 00:00:00 2001 From: Kalle Date: Sat, 23 Nov 2024 18:06:21 +0100 Subject: [PATCH] fix: dices do not return a string but parameters for string replacements only --- src/RollTheDice+Commands.cs | 8 ++++++- src/RollTheDice+DiceBigTaserBattery.cs | 11 +++++---- src/RollTheDice+DiceChangeName.cs | 11 +++++---- src/RollTheDice+DiceChickenLeader.cs | 9 ++++--- src/RollTheDice+DiceDecreaseHealth.cs | 11 +++++---- src/RollTheDice+DiceFastBombAction.cs | 24 ++++++++++++------- src/RollTheDice+DiceGiveHealthShot.cs | 11 +++++---- src/RollTheDice+DiceIncreaseHealth.cs | 11 +++++---- src/RollTheDice+DiceIncreaseSpeed.cs | 11 +++++---- src/RollTheDice+DiceNoExplosives.cs | 17 +++++++++---- src/RollTheDice+DicePlayerAsChicken.cs | 16 +++++++++---- src/RollTheDice+DicePlayerCloak.cs | 16 +++++++++---- src/RollTheDice+DicePlayerDisguiseAsPlant.cs | 18 ++++++++++---- src/RollTheDice+DicePlayerHighGravity.cs | 9 ++++--- src/RollTheDice+DicePlayerInvisible.cs | 9 ++++--- src/RollTheDice+DicePlayerLowGravity.cs | 9 ++++--- ...ollTheDice+DicePlayerMakeFakeGunSoundss.cs | 9 ++++--- ...RollTheDice+DicePlayerMakeHostageSounds.cs | 9 ++++--- src/RollTheDice+DicePlayerOneHP.cs | 9 ++++--- src/RollTheDice+DicePlayerRespawn.cs | 9 ++++--- src/RollTheDice+DicePlayerSuicide.cs | 9 ++++--- src/RollTheDice+DicePlayerVampire.cs | 9 ++++--- src/RollTheDice+DiceStripWeapons.cs | 16 +++++++++---- src/RollTheDice.cs | 4 ++-- 24 files changed, 188 insertions(+), 87 deletions(-) diff --git a/src/RollTheDice+Commands.cs b/src/RollTheDice+Commands.cs index b4160e6..adc33d6 100644 --- a/src/RollTheDice+Commands.cs +++ b/src/RollTheDice+Commands.cs @@ -56,7 +56,13 @@ public void CommandRollTheDice(CCSPlayerController player, CommandInfo command) return; } // execute dice function - var message = _dices[dice](player, playerPawn); + Dictionary data = _dices[dice](player, playerPawn); + // send message + string message = Localizer[data["_translation"]].Value; + foreach (var kvp in data) + { + message = message.Replace($"{{{kvp.Key}}}", kvp.Value); + } SendGlobalChatMessage(message); player.ExecuteClientCommand("play sounds/ui/coin_pickup_01.vsnd"); } diff --git a/src/RollTheDice+DiceBigTaserBattery.cs b/src/RollTheDice+DiceBigTaserBattery.cs index a77f892..d7bbfc8 100644 --- a/src/RollTheDice+DiceBigTaserBattery.cs +++ b/src/RollTheDice+DiceBigTaserBattery.cs @@ -6,14 +6,17 @@ public partial class RollTheDice : BasePlugin { private Dictionary _playersWithBigTaserBattery = new(); - private string DiceBigTaserBattery(CCSPlayerController player, CCSPlayerPawn playerPawn) + private Dictionary DiceBigTaserBattery(CCSPlayerController player, CCSPlayerPawn playerPawn) { int battery = _random.Next(2, 10); _playersWithBigTaserBattery.Add(player, battery); player.GiveNamedItem("weapon_taser"); - return Localizer["DiceBigTaserBattery"].Value - .Replace("{playerName}", player.PlayerName) - .Replace("{batterySize}", battery.ToString()); + return new Dictionary + { + {"_translation", "DiceBigTaserBattery"}, + { "playerName", player.PlayerName }, + { "batterySize", battery.ToString() } + }; } private void CreateDiceBigTaserBatteryEventHandler() diff --git a/src/RollTheDice+DiceChangeName.cs b/src/RollTheDice+DiceChangeName.cs index 66e0dcc..5be415b 100644 --- a/src/RollTheDice+DiceChangeName.cs +++ b/src/RollTheDice+DiceChangeName.cs @@ -7,7 +7,7 @@ public partial class RollTheDice : BasePlugin private List _playersWithChangedNames = new(); private Dictionary _playersWithChangedNamesOldNames = new(); - private string DiceChangeName(CCSPlayerController player, CCSPlayerPawn playerPawn) + private Dictionary DiceChangeName(CCSPlayerController player, CCSPlayerPawn playerPawn) { // select random string from list var names = new List @@ -28,9 +28,12 @@ private string DiceChangeName(CCSPlayerController player, CCSPlayerPawn playerPa _playersWithChangedNames.Add(player); _playersWithChangedNamesOldNames[player] = player.PlayerName; player.PlayerName = randomName; - return Localizer["DiceChangeName"].Value - .Replace("{playerName}", _playersWithChangedNamesOldNames[player]) - .Replace("{randomName}", randomName); + return new Dictionary + { + {"_translation", "DiceBigTaserBattery"}, + { "playerName", _playersWithChangedNamesOldNames[player] }, + { "randomName", randomName } + }; } private void ResetDiceChangeName() diff --git a/src/RollTheDice+DiceChickenLeader.cs b/src/RollTheDice+DiceChickenLeader.cs index 1e84344..7aa09d5 100644 --- a/src/RollTheDice+DiceChickenLeader.cs +++ b/src/RollTheDice+DiceChickenLeader.cs @@ -6,7 +6,7 @@ namespace RollTheDice { public partial class RollTheDice : BasePlugin { - private string DiceChickenLeader(CCSPlayerController player, CCSPlayerPawn playerPawn) + private Dictionary DiceChickenLeader(CCSPlayerController player, CCSPlayerPawn playerPawn) { var amountChickens = 16; // spawn chickens @@ -44,8 +44,11 @@ private string DiceChickenLeader(CCSPlayerController player, CCSPlayerPawn playe }); } } - return Localizer["DiceChickenLeader"].Value - .Replace("{playerName}", player.PlayerName); + return new Dictionary + { + {"_translation", "DiceBigTaserBattery"}, + { "playerName", player.PlayerName } + }; } } } diff --git a/src/RollTheDice+DiceDecreaseHealth.cs b/src/RollTheDice+DiceDecreaseHealth.cs index e19d7c1..903d8a5 100644 --- a/src/RollTheDice+DiceDecreaseHealth.cs +++ b/src/RollTheDice+DiceDecreaseHealth.cs @@ -5,14 +5,17 @@ namespace RollTheDice { public partial class RollTheDice : BasePlugin { - private string DiceDecreaseHealth(CCSPlayerController player, CCSPlayerPawn playerPawn) + private Dictionary DiceDecreaseHealth(CCSPlayerController player, CCSPlayerPawn playerPawn) { var healthDecrease = _random.Next(10, 30); playerPawn.Health -= healthDecrease; Utilities.SetStateChanged(playerPawn, "CBaseEntity", "m_iHealth"); - return Localizer["DiceDecreaseHealth"].Value - .Replace("{playerName}", player.PlayerName) - .Replace("{healthDecrease}", healthDecrease.ToString()); + return new Dictionary + { + {"_translation", "DiceBigTaserBattery"}, + { "playerName", player.PlayerName }, + { "healthDecrease", healthDecrease.ToString() } + }; } } } diff --git a/src/RollTheDice+DiceFastBombAction.cs b/src/RollTheDice+DiceFastBombAction.cs index 5ed1263..9b3927d 100644 --- a/src/RollTheDice+DiceFastBombAction.cs +++ b/src/RollTheDice+DiceFastBombAction.cs @@ -9,25 +9,33 @@ public partial class RollTheDice : BasePlugin private List _playersCanInstantDefuse = new(); private List _playersCanInstantPlant = new(); - private string DiceFastBombAction(CCSPlayerController player, CCSPlayerPawn playerPawn) + private Dictionary DiceFastBombAction(CCSPlayerController player, CCSPlayerPawn playerPawn) { if (playerPawn.TeamNum == (int)CsTeam.Terrorist) { _playersCanInstantPlant.Add(player); - return Localizer["DiceFastBombActionT"].Value - .Replace("{playerName}", player.PlayerName); - + return new Dictionary + { + {"_translation", "DiceFastBombActionT"}, + { "playerName", player.PlayerName } + }; } else if (playerPawn.TeamNum == (int)CsTeam.CounterTerrorist) { _playersCanInstantDefuse.Add(player); - return Localizer["DiceFastBombActionCT"].Value - .Replace("{playerName}", player.PlayerName); + return new Dictionary + { + {"_translation", "DiceFastBombActionCT"}, + { "playerName", player.PlayerName } + }; } else { - return Localizer["command.rollthedice.error"].Value - .Replace("{playerName}", player.PlayerName); + return new Dictionary + { + {"_translation", "command.rollthedice.error"}, + { "playerName", player.PlayerName } + }; } } diff --git a/src/RollTheDice+DiceGiveHealthShot.cs b/src/RollTheDice+DiceGiveHealthShot.cs index 9aea393..17eb5d3 100644 --- a/src/RollTheDice+DiceGiveHealthShot.cs +++ b/src/RollTheDice+DiceGiveHealthShot.cs @@ -4,16 +4,19 @@ namespace RollTheDice { public partial class RollTheDice : BasePlugin { - private string DiceGiveHealthShot(CCSPlayerController player, CCSPlayerPawn playerPawn) + private Dictionary DiceGiveHealthShot(CCSPlayerController player, CCSPlayerPawn playerPawn) { int amount = _random.Next(1, 5); for (int i = 0; i < amount; i++) { player.GiveNamedItem("weapon_healthshot"); } - return Localizer["DiceGiveHealthShot"].Value - .Replace("{playerName}", player.PlayerName) - .Replace("{amount}", amount.ToString()); + return new Dictionary + { + {"_translation", "DiceGiveHealthShot"}, + { "playerName", player.PlayerName }, + { "amount", amount.ToString() } + }; } } } diff --git a/src/RollTheDice+DiceIncreaseHealth.cs b/src/RollTheDice+DiceIncreaseHealth.cs index f58d41e..59bbecf 100644 --- a/src/RollTheDice+DiceIncreaseHealth.cs +++ b/src/RollTheDice+DiceIncreaseHealth.cs @@ -5,7 +5,7 @@ namespace RollTheDice { public partial class RollTheDice : BasePlugin { - private string DiceIncreaseHealth(CCSPlayerController player, CCSPlayerPawn playerPawn) + private Dictionary DiceIncreaseHealth(CCSPlayerController player, CCSPlayerPawn playerPawn) { var healthIncrease = _random.Next(10, 30); if (playerPawn.Health + healthIncrease > playerPawn.MaxHealth) @@ -15,9 +15,12 @@ private string DiceIncreaseHealth(CCSPlayerController player, CCSPlayerPawn play playerPawn.Health += healthIncrease; Utilities.SetStateChanged(playerPawn, "CBaseEntity", "m_iHealth"); Utilities.SetStateChanged(playerPawn, "CBaseEntity", "m_iMaxHealth"); - return Localizer["DiceIncreaseHealth"].Value - .Replace("{playerName}", player.PlayerName) - .Replace("{healthIncrease}", healthIncrease.ToString()); + return new Dictionary + { + {"_translation", "DiceIncreaseHealth"}, + { "playerName", player.PlayerName }, + { "healthIncrease", healthIncrease.ToString() } + }; } } } diff --git a/src/RollTheDice+DiceIncreaseSpeed.cs b/src/RollTheDice+DiceIncreaseSpeed.cs index abfdc0b..0d5201b 100644 --- a/src/RollTheDice+DiceIncreaseSpeed.cs +++ b/src/RollTheDice+DiceIncreaseSpeed.cs @@ -7,16 +7,19 @@ public partial class RollTheDice : BasePlugin { private List _playersWithIncreasedSpeed = new(); - private string DiceIncreaseSpeed(CCSPlayerController player, CCSPlayerPawn playerPawn) + private Dictionary DiceIncreaseSpeed(CCSPlayerController player, CCSPlayerPawn playerPawn) { _playersWithIncreasedSpeed.Add(player); var speedIncrease = _random.NextDouble() * (2.0 - 1.5) + 1.5; playerPawn.VelocityModifier *= (float)speedIncrease; Utilities.SetStateChanged(playerPawn, "CCSPlayerPawn", "m_flVelocityModifier"); var percentageIncrease = (speedIncrease - 1.0) * 100; - return Localizer["DiceIncreaseSpeed"].Value - .Replace("{playerName}", player.PlayerName) - .Replace("{percentageIncrease}", Math.Round(percentageIncrease, 2).ToString()); + return new Dictionary + { + {"_translation", "DiceIncreaseSpeed"}, + { "playerName", player.PlayerName }, + { "percentageIncrease", Math.Round(percentageIncrease, 2).ToString() } + }; } private void ResetDiceIncreaseSpeed() diff --git a/src/RollTheDice+DiceNoExplosives.cs b/src/RollTheDice+DiceNoExplosives.cs index d2b64af..03d2cf6 100644 --- a/src/RollTheDice+DiceNoExplosives.cs +++ b/src/RollTheDice+DiceNoExplosives.cs @@ -17,15 +17,22 @@ public partial class RollTheDice : BasePlugin ("models/food/vegetables/zucchini01a.vmdl", 1.0f), }; - private string DiceNoExplosives(CCSPlayerController player, CCSPlayerPawn playerPawn) + private Dictionary DiceNoExplosives(CCSPlayerController player, CCSPlayerPawn playerPawn) { - if (_playersWithoutExplosives.Contains(playerPawn)) return Localizer["DiceNoExplosives"].Value - .Replace("{playerName}", player.PlayerName); + if (_playersWithoutExplosives.Contains(playerPawn)) + return new Dictionary + { + {"_translation", "DiceNoExplosives"}, + { "playerName", player.PlayerName } + }; // register listener if (_playersWithoutExplosives.Count == 0) RegisterListener(DiceNoExplosivesOnEntitySpawned); _playersWithoutExplosives.Add(playerPawn); - return Localizer["DiceNoExplosives"].Value - .Replace("{playerName}", player.PlayerName); + return new Dictionary + { + {"_translation", "DiceNoExplosives"}, + { "playerName", player.PlayerName } + }; } private void ResetDiceNoExplosives() diff --git a/src/RollTheDice+DicePlayerAsChicken.cs b/src/RollTheDice+DicePlayerAsChicken.cs index f13134c..18783b0 100644 --- a/src/RollTheDice+DicePlayerAsChicken.cs +++ b/src/RollTheDice+DicePlayerAsChicken.cs @@ -13,9 +13,14 @@ public partial class RollTheDice : BasePlugin "Chicken.Panic", }; - private string DicePlayerAsChicken(CCSPlayerController player, CCSPlayerPawn playerPawn) + private Dictionary DicePlayerAsChicken(CCSPlayerController player, CCSPlayerPawn playerPawn) { - if (_playersAsChicken.ContainsKey(player)) return Localizer["command.rollthedice.error"].Value.Replace("{playerName}", player.PlayerName); + if (_playersAsChicken.ContainsKey(player)) + return new Dictionary + { + {"_translation", "command.rollthedice.error"}, + { "playerName", player.PlayerName } + }; // create listener if not exists if (_playersAsChicken.Count() == 0) { @@ -28,8 +33,11 @@ private string DicePlayerAsChicken(CCSPlayerController player, CCSPlayerPawn pla _playersAsChicken[player]["next_sound"] = $"{(int)Server.CurrentTime + 2}"; _playersAsChicken[player]["prop"] = SpawnProp(player, _playersAsChickenModel, 5.2f).ToString(); MakePlayerInvisible(player); - return Localizer["DicePlayerAsChicken"].Value - .Replace("{playerName}", player.PlayerName); + return new Dictionary + { + {"_translation", "DicePlayerAsChicken"}, + { "playerName", player.PlayerName } + }; } private void ResetDicePlayerAsChicken() diff --git a/src/RollTheDice+DicePlayerCloak.cs b/src/RollTheDice+DicePlayerCloak.cs index ed76678..cb2fb44 100644 --- a/src/RollTheDice+DicePlayerCloak.cs +++ b/src/RollTheDice+DicePlayerCloak.cs @@ -8,9 +8,14 @@ public partial class RollTheDice : BasePlugin { private Dictionary _playersWithCloak = new(); - private string DicePlayerCloak(CCSPlayerController player, CCSPlayerPawn playerPawn) + private Dictionary DicePlayerCloak(CCSPlayerController player, CCSPlayerPawn playerPawn) { - if (_playersWithCloak.ContainsKey(player)) return Localizer["command.rollthedice.error"].Value.Replace("{playerName}", player.PlayerName); + if (_playersWithCloak.ContainsKey(player)) + return new Dictionary + { + {"_translation", "command.rollthedice.error"}, + { "playerName", player.PlayerName } + }; // create listener if not exists if (_playersWithCloak.Count() == 0) { @@ -18,8 +23,11 @@ private string DicePlayerCloak(CCSPlayerController player, CCSPlayerPawn playerP } // add player to list _playersWithCloak.Add(player, 255); - return Localizer["DicePlayerCloak"].Value - .Replace("{playerName}", player.PlayerName); + return new Dictionary + { + {"_translation", "DicePlayerCloak"}, + { "playerName", player.PlayerName } + }; } private void RemoveDicePlayerCloakListeners() diff --git a/src/RollTheDice+DicePlayerDisguiseAsPlant.cs b/src/RollTheDice+DicePlayerDisguiseAsPlant.cs index 7c0e841..31f7512 100644 --- a/src/RollTheDice+DicePlayerDisguiseAsPlant.cs +++ b/src/RollTheDice+DicePlayerDisguiseAsPlant.cs @@ -20,9 +20,14 @@ public partial class RollTheDice : BasePlugin { "Airport/Plant", new Dictionary { { "model", "models/props_plants/plantairport01.vmdl" } } }, { "MailDropbox", new Dictionary { { "model", "models/props_street/mail_dropbox.vmdl" } } }, }; - private string DicePlayerDisguiseAsPlant(CCSPlayerController player, CCSPlayerPawn playerPawn) + private Dictionary DicePlayerDisguiseAsPlant(CCSPlayerController player, CCSPlayerPawn playerPawn) { - if (_playersDisguisedAsPlants.ContainsKey(player)) return Localizer["command.rollthedice.error"].Value.Replace("{playerName}", player.PlayerName); + if (_playersDisguisedAsPlants.ContainsKey(player)) + return new Dictionary + { + {"_translation", "command.rollthedice.error"}, + { "playerName", player.PlayerName } + }; // create listener if not exists if (_playersDisguisedAsPlants.Count == 0) RegisterListener(EventDicePlayerDisguiseAsPlantOnTick); // add player to list @@ -35,9 +40,12 @@ private string DicePlayerDisguiseAsPlant(CCSPlayerController player, CCSPlayerPa ).ToString(); _playersDisguisedAsPlants[player]["offset_z"] = _playersDisguisedAsPlantsModels[randomKey].ContainsKey("offset_z") ? (string)_playersDisguisedAsPlantsModels[randomKey]["offset_z"] : "0"; _playersDisguisedAsPlants[player]["offset_angle"] = _playersDisguisedAsPlantsModels[randomKey].ContainsKey("offset_angle") ? (string)_playersDisguisedAsPlantsModels[randomKey]["offset_angle"] : "0"; - return Localizer["DicePlayerDisguiseAsPlant"].Value - .Replace("{playerName}", player.PlayerName) - .Replace("{model}", randomKey); + return new Dictionary + { + {"_translation", "DicePlayerDisguiseAsPlant"}, + { "playerName", player.PlayerName }, + { "model", randomKey } + }; } private void ResetDicePlayerDisguiseAsPlant() diff --git a/src/RollTheDice+DicePlayerHighGravity.cs b/src/RollTheDice+DicePlayerHighGravity.cs index a2e5dde..22e545c 100644 --- a/src/RollTheDice+DicePlayerHighGravity.cs +++ b/src/RollTheDice+DicePlayerHighGravity.cs @@ -4,11 +4,14 @@ namespace RollTheDice { public partial class RollTheDice : BasePlugin { - private string DicePlayerHighGravity(CCSPlayerController player, CCSPlayerPawn playerPawn) + private Dictionary DicePlayerHighGravity(CCSPlayerController player, CCSPlayerPawn playerPawn) { playerPawn.GravityScale = 4f; - return Localizer["DicePlayerHighGravity"].Value - .Replace("{playerName}", player.PlayerName); + return new Dictionary + { + {"_translation", "DicePlayerHighGravity"}, + { "playerName", player.PlayerName } + }; } } } \ No newline at end of file diff --git a/src/RollTheDice+DicePlayerInvisible.cs b/src/RollTheDice+DicePlayerInvisible.cs index 522e63d..3c9da00 100644 --- a/src/RollTheDice+DicePlayerInvisible.cs +++ b/src/RollTheDice+DicePlayerInvisible.cs @@ -8,13 +8,16 @@ public partial class RollTheDice : BasePlugin { private List _playersThatAreInvisible = new(); - private string DicePlayerInvisible(CCSPlayerController player, CCSPlayerPawn playerPawn) + private Dictionary DicePlayerInvisible(CCSPlayerController player, CCSPlayerPawn playerPawn) { _playersThatAreInvisible.Add(player); playerPawn.Render = Color.FromArgb(125, 255, 255, 255); Utilities.SetStateChanged(playerPawn, "CBaseModelEntity", "m_clrRender"); - return Localizer["DicePlayerInvisible"].Value - .Replace("{playerName}", player.PlayerName); + return new Dictionary + { + {"_translation", "DicePlayerInvisible"}, + { "playerName", player.PlayerName } + }; } private void ResetDicePlayerInvisible() diff --git a/src/RollTheDice+DicePlayerLowGravity.cs b/src/RollTheDice+DicePlayerLowGravity.cs index 40e3783..1ba9008 100644 --- a/src/RollTheDice+DicePlayerLowGravity.cs +++ b/src/RollTheDice+DicePlayerLowGravity.cs @@ -4,11 +4,14 @@ namespace RollTheDice { public partial class RollTheDice : BasePlugin { - private string DicePlayerLowGravity(CCSPlayerController player, CCSPlayerPawn playerPawn) + private Dictionary DicePlayerLowGravity(CCSPlayerController player, CCSPlayerPawn playerPawn) { playerPawn.GravityScale = 0.4f; - return Localizer["DicePlayerLowGravity"].Value - .Replace("{playerName}", player.PlayerName); + return new Dictionary + { + {"_translation", "DicePlayerLowGravity"}, + { "playerName", player.PlayerName } + }; } } } diff --git a/src/RollTheDice+DicePlayerMakeFakeGunSoundss.cs b/src/RollTheDice+DicePlayerMakeFakeGunSoundss.cs index 2b85d73..f3279b0 100644 --- a/src/RollTheDice+DicePlayerMakeFakeGunSoundss.cs +++ b/src/RollTheDice+DicePlayerMakeFakeGunSoundss.cs @@ -20,14 +20,17 @@ public partial class RollTheDice : BasePlugin ("M4A1", "Weapon_M4A1.Single", 25, 0.9f) }; - private string DicePlayerMakeFakeGunSounds(CCSPlayerController player, CCSPlayerPawn playerPawn) + private Dictionary DicePlayerMakeFakeGunSounds(CCSPlayerController player, CCSPlayerPawn playerPawn) { // create listener if not exists if (_playersWithFakeGunSounds.Count() == 0) RegisterListener(EventDicePlayerMakeFakeGunSoundsOnTick); // add player to list _playersWithFakeGunSounds.Add(player, (int)Server.CurrentTime + _random.Next(3, 10)); - return Localizer["DicePlayerMakeFakeGunSounds"].Value - .Replace("{playerName}", player.PlayerName); + return new Dictionary + { + {"_translation", "DicePlayerMakeFakeGunSounds"}, + { "playerName", player.PlayerName } + }; } private void ResetDicePlayerMakeFakeGunSounds() diff --git a/src/RollTheDice+DicePlayerMakeHostageSounds.cs b/src/RollTheDice+DicePlayerMakeHostageSounds.cs index 79e0a32..cb71bc6 100644 --- a/src/RollTheDice+DicePlayerMakeHostageSounds.cs +++ b/src/RollTheDice+DicePlayerMakeHostageSounds.cs @@ -13,14 +13,17 @@ public partial class RollTheDice : BasePlugin "Hostage.Pain" }; - private string DicePlayerMakeHostageSounds(CCSPlayerController player, CCSPlayerPawn playerPawn) + private Dictionary DicePlayerMakeHostageSounds(CCSPlayerController player, CCSPlayerPawn playerPawn) { // create listener if not exists if (_playersWithHostageSounds.Count() == 0) RegisterListener(EventDicePlayerMakeHostageSoundsOnTick); // add player to list _playersWithHostageSounds.Add(player, 0); - return Localizer["DicePlayerMakeHostageSounds"].Value - .Replace("{playerName}", player.PlayerName); + return new Dictionary + { + {"_translation", "DicePlayerMakeHostageSounds"}, + { "playerName", player.PlayerName } + }; } private void ResetDicePlayerMakeHostageSounds() diff --git a/src/RollTheDice+DicePlayerOneHP.cs b/src/RollTheDice+DicePlayerOneHP.cs index 570f72e..c4cbef4 100644 --- a/src/RollTheDice+DicePlayerOneHP.cs +++ b/src/RollTheDice+DicePlayerOneHP.cs @@ -5,12 +5,15 @@ namespace RollTheDice { public partial class RollTheDice : BasePlugin { - private string DicePlayerOneHP(CCSPlayerController player, CCSPlayerPawn playerPawn) + private Dictionary DicePlayerOneHP(CCSPlayerController player, CCSPlayerPawn playerPawn) { playerPawn.Health = 1; Utilities.SetStateChanged(playerPawn, "CBaseEntity", "m_iHealth"); - return Localizer["DicePlayerOneHP"].Value - .Replace("{playerName}", player.PlayerName); + return new Dictionary + { + {"_translation", "DicePlayerOneHP"}, + { "playerName", player.PlayerName } + }; } } } diff --git a/src/RollTheDice+DicePlayerRespawn.cs b/src/RollTheDice+DicePlayerRespawn.cs index c73e821..dd0fed2 100644 --- a/src/RollTheDice+DicePlayerRespawn.cs +++ b/src/RollTheDice+DicePlayerRespawn.cs @@ -8,14 +8,17 @@ public partial class RollTheDice : BasePlugin { private Dictionary> _playersWithRespawnAbility = new(); - private string DicePlayerRespawn(CCSPlayerController player, CCSPlayerPawn playerPawn) + private Dictionary DicePlayerRespawn(CCSPlayerController player, CCSPlayerPawn playerPawn) { // create listener if not exists if (_playersWithRespawnAbility.Count() == 0) RegisterListener(EventDicePlayerRespawnOnTick); // add player to list _playersWithRespawnAbility.Add(player, new Dictionary()); - return Localizer["DicePlayerRespawn"].Value - .Replace("{playerName}", player.PlayerName); + return new Dictionary + { + {"_translation", "DicePlayerRespawn"}, + { "playerName", player.PlayerName } + }; } private void ResetDicePlayerRespawn() diff --git a/src/RollTheDice+DicePlayerSuicide.cs b/src/RollTheDice+DicePlayerSuicide.cs index 43cf733..de6a76c 100644 --- a/src/RollTheDice+DicePlayerSuicide.cs +++ b/src/RollTheDice+DicePlayerSuicide.cs @@ -4,11 +4,14 @@ namespace RollTheDice { public partial class RollTheDice : BasePlugin { - private string DicePlayerSuicide(CCSPlayerController player, CCSPlayerPawn playerPawn) + private Dictionary DicePlayerSuicide(CCSPlayerController player, CCSPlayerPawn playerPawn) { playerPawn.CommitSuicide(true, true); - return Localizer["DicePlayerSuicide"].Value - .Replace("{playerName}", player.PlayerName); + return new Dictionary + { + {"_translation", "DicePlayerSuicide"}, + { "playerName", player.PlayerName } + }; } } } diff --git a/src/RollTheDice+DicePlayerVampire.cs b/src/RollTheDice+DicePlayerVampire.cs index 3d93d55..e00d276 100644 --- a/src/RollTheDice+DicePlayerVampire.cs +++ b/src/RollTheDice+DicePlayerVampire.cs @@ -7,11 +7,14 @@ public partial class RollTheDice : BasePlugin { private List _playerVampires = new(); - private string DicePlayerVampire(CCSPlayerController player, CCSPlayerPawn playerPawn) + private Dictionary DicePlayerVampire(CCSPlayerController player, CCSPlayerPawn playerPawn) { _playerVampires.Add(player); - return Localizer["DicePlayerVampire"].Value - .Replace("{playerName}", player.PlayerName); + return new Dictionary + { + {"_translation", "DicePlayerVampire"}, + { "playerName", player.PlayerName } + }; } private void ResetDicePlayerVampire() diff --git a/src/RollTheDice+DiceStripWeapons.cs b/src/RollTheDice+DiceStripWeapons.cs index ed866c6..4dfc7bb 100644 --- a/src/RollTheDice+DiceStripWeapons.cs +++ b/src/RollTheDice+DiceStripWeapons.cs @@ -5,9 +5,14 @@ namespace RollTheDice { public partial class RollTheDice : BasePlugin { - private string DiceStripWeapons(CCSPlayerController player, CCSPlayerPawn playerPawn) + private Dictionary DiceStripWeapons(CCSPlayerController player, CCSPlayerPawn playerPawn) { - if (playerPawn.WeaponServices == null) return Localizer["command.rollthedice.error"].Value.Replace("{playerName}", player.PlayerName); + if (playerPawn.WeaponServices == null) + return new Dictionary + { + {"_translation", "command.rollthedice.error"}, + { "playerName", player.PlayerName } + }; var playerWeapons = playerPawn.WeaponServices!; foreach (var weapon in playerWeapons.MyWeapons) { @@ -29,8 +34,11 @@ private string DiceStripWeapons(CCSPlayerController player, CCSPlayerPawn player player.GiveNamedItem("weapon_knife"); }); - return Localizer["DiceStripWeapons"].Value - .Replace("{playerName}", player.PlayerName); + return new Dictionary + { + {"_translation", "DiceStripWeapons"}, + { "playerName", player.PlayerName } + }; } } } diff --git a/src/RollTheDice.cs b/src/RollTheDice.cs index 3b92bc1..66def32 100644 --- a/src/RollTheDice.cs +++ b/src/RollTheDice.cs @@ -10,7 +10,7 @@ public partial class RollTheDice : BasePlugin, IPluginConfig private string _currentMap = ""; private List _playersThatRolledTheDice = new(); - private List> _dices = new(); + private List>> _dices = new(); private bool _isDuringRound = false; Random _random = new Random(Guid.NewGuid().GetHashCode()); @@ -116,7 +116,7 @@ private void OnMapEnd() private void InitializeDices() { // create dynamic list containing functions to execute for each dice - _dices = new List> + _dices = new List>> { DiceIncreaseHealth, DiceDecreaseHealth,