diff --git a/lang/en.json b/lang/en.json index dbaad45..b3df328 100644 --- a/lang/en.json +++ b/lang/en.json @@ -108,7 +108,7 @@ "menu.format.invitation": "%color.special%{0}%color.default% invited %color.target%{1}%color.default% on %color.emph%{2}%color.default%.", "menu.format.request": "%color.target%{0}%color.default% requested to join on %color.emph%{1}%color.default%.", "raffle.begin": "%prefix%A raffle for %color.currency%{0} %currency%%s%%color.default% has begun. Type %color.command%/raffle %color.default% to enter.", - "raffle.preannounce": "%prefix%Raffle closed! Collected %color.currency%{0} %currency%%s% across %color.number%{1}%color.default% entrant%s%.", + "raffle.preannounce": "%prefix%Raffle closed! Collected %color.currency%{0} %currency%%s%%color.default% across %color.number%{1}%color.default% entrant%s%.", "raffle.winner": "%prefix%%color.target%{0}%color.default% won the raffle with a %color.number%{1}%color.default% chance!", "raffle.notactive": "%prefix%There is no active raffle.", "raffle.notopen": "%prefix%The raffle closed entries and is currently drawing." diff --git a/src/CS2/Raffle/RaffleManager.cs b/src/CS2/Raffle/RaffleManager.cs index e54f342..ccd42ab 100644 --- a/src/CS2/Raffle/RaffleManager.cs +++ b/src/CS2/Raffle/RaffleManager.cs @@ -3,6 +3,8 @@ using CounterStrikeSharp.API.Core.Attributes.Registration; using CounterStrikeSharp.API.Modules.Cvars; using GangsAPI; +using GangsAPI.Data; +using GangsAPI.Services; using GangsAPI.Services.Commands; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Localization; @@ -39,6 +41,8 @@ public class RaffleManager(IServiceProvider provider) private readonly IStringLocalizer locale = provider.GetRequiredService(); + private readonly IEcoManager eco = provider.GetRequiredService(); + public void Start(BasePlugin? plugin, bool hotReload) { Console.WriteLine($"Start called on RaffleManager, plugin: {plugin}"); if (plugin == null) return; @@ -92,6 +96,12 @@ public void DrawWinner() { var name = Utilities.GetPlayerFromSteamId(winner.Value)?.PlayerName ?? winner.ToString() ?? ""; + var wrapper = new PlayerWrapper(winner.Value, name); + + Task.Run(async () => { + await eco.Grant(wrapper, Raffle.Value, true, "Raffle"); + }); + Server.PrintToChatAll(locale.Get(MSG.RAFFLE_WINNER, name, (1.0f / (Raffle.TotalPlayers + 1)).ToString("P1"))); Raffle = null; diff --git a/src/CS2/Raffle/StartRaffleCommand.cs b/src/CS2/Raffle/StartRaffleCommand.cs index 52e06c6..185ed51 100644 --- a/src/CS2/Raffle/StartRaffleCommand.cs +++ b/src/CS2/Raffle/StartRaffleCommand.cs @@ -22,12 +22,7 @@ public async Task Execute(PlayerWrapper? executor, if (!int.TryParse(info.Args[1], out amo)) return CommandResult.PRINT_USAGE; - var result = false; - await Server.NextFrameAsync(() => { result = raffle.StartRaffle(amo); }); - - info.ReplySync(result ? - "Raffle started with a prize of $" + amo : - "Raffle already in progress"); + await Server.NextFrameAsync(() => { raffle.StartRaffle(amo); }); return CommandResult.SUCCESS; } } \ No newline at end of file