Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dev #3

Merged
merged 7 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: .NET Build and Release

permissions:
contents: write
on: push

jobs:
Expand Down
19 changes: 10 additions & 9 deletions WeaponsGiver.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes;
using CounterStrikeSharp.API.Modules.Memory;
using CounterStrikeSharp.API.Modules.Entities.Constants;
using CounterStrikeSharp.API.Modules.Cvars;
using CounterStrikeSharp.API.Modules.Utils;

namespace WeaponsGiver
{
[MinimumApiVersion(175)]
[MinimumApiVersion(198)]
public class WeaponsGiver : BasePlugin
{
private string tPrimary;
Expand All @@ -21,7 +19,7 @@ public class WeaponsGiver : BasePlugin
public override string ModuleName => "WeaponsGiver";
public override string ModuleAuthor => "ji";
public override string ModuleDescription => "Ensures players in custom gamemodes spawn with starting weapons.";
public override string ModuleVersion => "build4";
public override string ModuleVersion => "build6";

public override void Load(bool hotReload)
{
Expand All @@ -48,9 +46,14 @@ private HookResult Event_RoundPrestart(EventRoundPrestart @event, GameEventInfo

private HookResult Event_PlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
{
var player = @event.Userid;

if(!player.IsValid || !player.PlayerPawn.IsValid) return HookResult.Continue;
Server.RunOnTick(Server.TickCount + 1, () => GiveWeapons(@event.Userid));
return HookResult.Continue;
}

private void GiveWeapons(CCSPlayerController player)
{
if(!player.IsValid || !player.PlayerPawn.IsValid) return;
if (player.Connected != PlayerConnectedState.PlayerConnected) return;

switch((CsTeam)player.TeamNum)
{
Expand All @@ -66,8 +69,6 @@ private HookResult Event_PlayerSpawn(EventPlayerSpawn @event, GameEventInfo info
if(!String.IsNullOrEmpty(ctMelee)) player.GiveNamedItem(ctMelee);
break;
}

return HookResult.Continue;
}
}
}
2 changes: 1 addition & 1 deletion WeaponsGiver.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.175" />
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.198" />
</ItemGroup>
</Project>
Loading