Skip to content

Commit

Permalink
1.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
oqyh authored Jul 6, 2024
1 parent f2aa440 commit 91655f9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
26 changes: 25 additions & 1 deletion Config/Helper.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Runtime.InteropServices;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Admin;
using CounterStrikeSharp.API;
Expand Down Expand Up @@ -84,7 +85,26 @@ public static void ClearGroundWeapons()
}
}

public static void DropAllWeaponsAndDelete(CCSPlayerController player)
public static void DropAllWeaponsAndDeleteLunix(CCSPlayerController player)
{
if(player == null || !player.IsValid)return;
if(player.PlayerPawn == null || !player.PlayerPawn.IsValid)return;
if(!player.PawnIsAlive)return;
if(player.PlayerPawn.Value == null || !player.PlayerPawn.Value.IsValid)return;
if(player.PlayerPawn.Value.WeaponServices == null || player.PlayerPawn.Value.WeaponServices.MyWeapons == null)return;

foreach (var weapon in player.PlayerPawn.Value.WeaponServices.MyWeapons)
{
if (weapon == null || !weapon.IsValid) continue;
var weaponValue = weapon.Value;
if (weaponValue == null || !weaponValue.IsValid) continue;
if (weaponValue.DesignerName != null && weaponValue.DesignerName.Contains("weapon_knife") || weaponValue.DesignerName != null && weaponValue.DesignerName.Contains("weapon_c4"))continue;
if(weaponValue.DesignerName == null)continue;
player.ExecuteClientCommand("slot3");
Utilities.RemoveItemByDesignerName(player, weaponValue.DesignerName);
}
}
public static void DropAllWeaponsAndDeleteWin(CCSPlayerController player)
{
if(player == null || !player.IsValid)return;
if(player.PlayerPawn == null || !player.PlayerPawn.IsValid)return;
Expand Down Expand Up @@ -179,4 +199,8 @@ public static void CreateDefaultWeaponsJson()
File.WriteAllText(configcfg, jsonContent);
}
}
public static bool IsWindows()
{
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
}
}
Binary file modified CounterStrikeSharp.API.dll
Binary file not shown.
14 changes: 10 additions & 4 deletions Spawn-Loadout-GoldKingZ.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
using CounterStrikeSharp.API.Modules.Timers;
using Spawn_Loadout_GoldKingZ.Config;
using Newtonsoft.Json.Linq;
using System.Net;
using CounterStrikeSharp.API.Modules.Entities;

namespace Spawn_Loadout_GoldKingZ;

public class SpawnLoadoutGoldKingZ : BasePlugin
{
public override string ModuleName => "Give Weapons On Spawn (Depend The Map Name + Team Side)";
public override string ModuleVersion => "1.0.4";
public override string ModuleVersion => "1.0.5";
public override string ModuleAuthor => "Gold KingZ";
public override string ModuleDescription => "https://github.com/oqyh";

Expand All @@ -29,6 +27,7 @@ public override void Load(bool hotReload)
RegisterListener<Listeners.OnMapEnd>(OnMapEnd);
RegisterEventHandler<EventRoundStart>(OnEventRoundStart);
}

public HookResult OnEventGrenadeThrown(EventGrenadeThrown @event, GameEventInfo info)
{
if (@event == null) return HookResult.Continue;
Expand Down Expand Up @@ -213,7 +212,14 @@ private HookResult OnEventPlayerSpawn(EventPlayerSpawn @event, GameEventInfo inf
{
AddTimer(0.1f, () =>
{
Helper.DropAllWeaponsAndDelete(player);
if(Helper.IsWindows())
{
Helper.DropAllWeaponsAndDeleteWin(player);
}else
{
Helper.DropAllWeaponsAndDeleteLunix(player);
}

});
}

Expand Down

0 comments on commit 91655f9

Please sign in to comment.