Skip to content

Commit

Permalink
ensure weapons are given by waiting for pawn to fully spawn
Browse files Browse the repository at this point in the history
  • Loading branch information
jithatsonei committed Mar 25, 2024
1 parent 763dc55 commit 3f772a7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
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
13 changes: 9 additions & 4 deletions WeaponsGiver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
using CounterStrikeSharp.API.Modules.Entities.Constants;
using CounterStrikeSharp.API.Modules.Cvars;
using CounterStrikeSharp.API.Modules.Utils;

using System
using System.Timers
namespace WeaponsGiver
{
[MinimumApiVersion(175)]
Expand All @@ -21,7 +22,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 => "build5";

public override void Load(bool hotReload)
{
Expand All @@ -47,6 +48,12 @@ private HookResult Event_RoundPrestart(EventRoundPrestart @event, GameEventInfo
}

private HookResult Event_PlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
{
BasePlugin.AddTimer(1, giveWeapons())
return HookResult.Continue;
}

private void giveWeapons()
{
var player = @event.Userid;

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

return HookResult.Continue;
}
}
}

0 comments on commit 3f772a7

Please sign in to comment.