Skip to content

Commit

Permalink
Version 1.4
Browse files Browse the repository at this point in the history
-Added model path to json configuration for change it.
-Remove parachute on death.
  • Loading branch information
Franc1sco committed Feb 6, 2024
1 parent cdf816f commit 08fe1b7
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions src/Parachute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -16,14 +17,17 @@ 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)]
public class Parachute : BasePlugin, IPluginConfig<ConfigGen>
{
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; }

Expand All @@ -49,6 +53,14 @@ public override void Load(bool hotReload)
});
}

if (Config.ParachuteModelEnabled)
{
RegisterListener<Listeners.OnMapStart>(map =>
{
Server.PrecacheModel(Config.ParachuteModel);
});
}

RegisterEventHandler<EventPlayerConnectFull>((@event, info) =>
{
var player = @event.Userid;
Expand Down Expand Up @@ -121,6 +133,19 @@ public override void Load(bool hotReload)
}
}
});

RegisterEventHandler<EventPlayerDeath>((@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)
Expand All @@ -145,7 +170,7 @@ private void StartPara(CCSPlayerController player)
var entity = Utilities.CreateEntityByName<CBaseProp>("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;
Expand Down

0 comments on commit 08fe1b7

Please sign in to comment.