mirror of
https://github.com/MSWS/TTT.git
synced 2025-12-06 06:22:44 -08:00
feat: Add tripwire defuse reward
This commit is contained in:
@@ -78,6 +78,11 @@ public class CS2TripwireConfig : IStorage<TripwireConfig>, IPluginModule {
|
||||
"Rate at which Tripwire defuses are processed (in seconds)", 0.5f,
|
||||
ConVarFlags.FCVAR_NONE, new RangeValidator<float>(0.01f, 5f));
|
||||
|
||||
public static readonly FakeConVar<int> CV_DEFUSE_REWARD = new(
|
||||
"css_ttt_shop_tripwire_defuse_reward",
|
||||
"Amount of money rewarded to a player for successfully defusing a tripwire",
|
||||
20, ConVarFlags.FCVAR_NONE, new RangeValidator<int>(0, 10000));
|
||||
|
||||
public void Dispose() { }
|
||||
|
||||
public void Start() { }
|
||||
@@ -102,7 +107,8 @@ public class CS2TripwireConfig : IStorage<TripwireConfig>, IPluginModule {
|
||||
CV_COLOR_B.Value),
|
||||
TripwireThickness = CV_THICKNESS.Value,
|
||||
DefuseTime = TimeSpan.FromSeconds(CV_DEFUSE_TIME.Value),
|
||||
DefuseRate = TimeSpan.FromSeconds(CV_DEFUSE_RATE.Value)
|
||||
DefuseRate = TimeSpan.FromSeconds(CV_DEFUSE_RATE.Value),
|
||||
DefuseReward = CV_DEFUSE_REWARD.Value
|
||||
};
|
||||
|
||||
return Task.FromResult<TripwireConfig?>(cfg);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ShopAPI;
|
||||
using ShopAPI.Configs.Traitor;
|
||||
using TTT.API;
|
||||
using TTT.API.Messages;
|
||||
@@ -99,11 +100,14 @@ public class TripwireDefuserListener(IServiceProvider provider)
|
||||
}
|
||||
|
||||
var progress = (DateTime.Now - startTime) / config.DefuseTime;
|
||||
var timeLeft = config.DefuseTime - (config.DefuseTime * progress);
|
||||
var timeLeft = config.DefuseTime - config.DefuseTime * progress;
|
||||
|
||||
if (progress >= 1) {
|
||||
instance.TripwireProp.EmitSound("c4.disarmfinish", null, 0.2f, 1.5f);
|
||||
tripwireTracker?.RemoveTripwire(instance);
|
||||
if (apiPlayer is IOnlinePlayer online)
|
||||
provider.GetService<IShop>()
|
||||
?.AddBalance(online, config.DefuseReward, "Tripwire Defusal");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,4 +19,6 @@ public record TripwireConfig : ShopItemConfig {
|
||||
|
||||
public TimeSpan DefuseTime { get; init; } = TimeSpan.FromSeconds(5);
|
||||
public TimeSpan DefuseRate { get; init; } = TimeSpan.FromMilliseconds(500);
|
||||
|
||||
public int DefuseReward { get; init; } = 20;
|
||||
}
|
||||
Reference in New Issue
Block a user