Skip to content

Commit

Permalink
update 1.0.2
Browse files Browse the repository at this point in the history
added sound to hit and kill effect
  • Loading branch information
exkludera committed Jul 30, 2024
1 parent f84fd75 commit d18ace8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ public class Impact
public class HitEffect
{
public bool Enable { get; set; } = false;
public string File { get; set; } = "particles/weapons/cs_weapon_fx/weapon_taser_glow.vpcf";
public string File { get; set; } = "particles/ambient_fx/ambient_sparks_glow.vpcf";
public string Permission { get; set; } = "";
public string Team { get; set; } = "";
public float Height { get; set; } = 32;
public string Sound { get; set; } = "";
}

public class KillEffect
Expand All @@ -45,4 +46,5 @@ public class KillEffect
public string Permission { get; set; } = "";
public string Team { get; set; } = "";
public float Height { get; set; } = 0;
public string Sound { get; set; } = "";
}
17 changes: 12 additions & 5 deletions src/main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace BulletEffects;
public partial class Plugin : BasePlugin, IPluginConfig<Config>
{
public override string ModuleName => "Bullet Effects";
public override string ModuleVersion => "1.0.1";
public override string ModuleVersion => "1.0.2";
public override string ModuleAuthor => "exkludera";

public override void Load(bool hotReload)
Expand All @@ -37,20 +37,25 @@ public void OnServerPrecacheResources(ResourceManifest manifest)
PrecacheResource(manifest, Config.KillEffect.File);
}

private void CreateEffect(string effectName, CCSPlayerController player, Vector Position, string effectFile, string colorValue = "", float width = 0, float lifetime = 1.0f)
private void CreateEffect(string effectName, CCSPlayerController player, Vector Pos, string effectFile, string colorValue = "", float width = 0, float lifetime = 1.0f)
{
Vector bulletDestination = new Vector(Position.X, Position.Y, Position.Z);
Vector Position = Pos;
Vector bulletDestination = Pos;

string soundPath = "";

switch (effectName.ToLower())
{
case "impact":
effectName = string.IsNullOrEmpty(effectFile) ? "impact" : "impactparticle";
break;
case "hiteffect":
Position.Z += Config.HitEffect.Height;
bulletDestination.Z += Config.HitEffect.Height;
soundPath = Config.HitEffect.Sound;
break;
case "killeffect":
Position.Z += Config.KillEffect.Height;
bulletDestination.Z += Config.KillEffect.Height;
soundPath = Config.KillEffect.Sound;
break;
}

Expand Down Expand Up @@ -93,6 +98,8 @@ private void CreateEffect(string effectName, CCSPlayerController player, Vector

particle.Teleport(bulletDestination);

player.ExecuteClientCommand($"play {soundPath}");

AddTimer(1.0f, particle.Remove);
}
}
Expand Down

0 comments on commit d18ace8

Please sign in to comment.