diff --git a/src/Parachute.cs b/src/Parachute.cs index 63afa45..2b91848 100644 --- a/src/Parachute.cs +++ b/src/Parachute.cs @@ -2,6 +2,7 @@ using CounterStrikeSharp.API.Core; using CounterStrikeSharp.API.Core.Attributes; using CounterStrikeSharp.API.Modules.Admin; +using CounterStrikeSharp.API.Modules.Entities; using CounterStrikeSharp.API.Modules.Entities.Constants; using System.Text.Json.Serialization; @@ -16,6 +17,7 @@ public class ConfigGen : BasePluginConfig [JsonPropertyName("AccessFlag")] public string AccessFlag { get; set; } = ""; [JsonPropertyName("TeleportTicks")] public int TeleportTicks { get; set; } = 300; [JsonPropertyName("ParachuteModelEnabled")] public bool ParachuteModelEnabled { get; set; } = false; + [JsonPropertyName("ParachuteModel")] public string ParachuteModel { get; set; } = "models/props_survival/parachute/chute.vmdl"; } [MinimumApiVersion(139)] @@ -23,7 +25,9 @@ public class Parachute : BasePlugin, IPluginConfig { public override string ModuleName => "CS2 Parachute"; public override string ModuleAuthor => "Franc1sco Franug"; - public override string ModuleVersion => "1.3"; + public override string ModuleVersion => "1.4"; + + public ConfigGen Config { get; set; } = null!; public void OnConfigParsed(ConfigGen config) { Config = config; } @@ -49,6 +53,14 @@ public override void Load(bool hotReload) }); } + if (Config.ParachuteModelEnabled) + { + RegisterListener(map => + { + Server.PrecacheModel(Config.ParachuteModel); + }); + } + RegisterEventHandler((@event, info) => { var player = @event.Userid; @@ -121,6 +133,19 @@ public override void Load(bool hotReload) } } }); + + RegisterEventHandler((@event, info) => + { + var player = @event.Userid; + + if (bUsingPara[player.UserId]) + { + bUsingPara[player.UserId] = false; + StopPara(player); + } + return HookResult.Continue; + }, HookMode.Pre); + } private void StopPara(CCSPlayerController player) @@ -145,7 +170,7 @@ private void StartPara(CCSPlayerController player) var entity = Utilities.CreateEntityByName("prop_dynamic_override"); if (entity != null && entity.IsValid) { - entity.SetModel("models/props_survival/parachute/chute.vmdl"); + entity.SetModel(Config.ParachuteModel); entity.MoveType = MoveType_t.MOVETYPE_NOCLIP; entity.Collision.CollisionGroup = (byte)CollisionGroup.COLLISION_GROUP_NONE; entity.Collision.CollisionAttribute.CollisionGroup = (byte)CollisionGroup.COLLISION_GROUP_NONE;