Skip to content

Commit

Permalink
Merge pull request #329 from daffyyyy/main
Browse files Browse the repository at this point in the history
Music kit fix
  • Loading branch information
daffyyyy authored Oct 20, 2024
2 parents 5808255 + 7d33693 commit ccee3e5
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ namespace WeaponPaints
{
public partial class WeaponPaints
{
private bool _mvpPlayed;

[GameEventHandler]
public HookResult OnClientFullConnect(EventPlayerConnectFull @event, GameEventInfo info)
{
Expand Down Expand Up @@ -148,6 +150,39 @@ private HookResult OnRoundEnd(EventRoundEnd @event, GameEventInfo info)
private HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info)
{
_gBCommandsAllowed = true;
_mvpPlayed = false;
return HookResult.Continue;
}

private HookResult OnRoundMvp(EventRoundMvp @event, GameEventInfo info)
{
if (_mvpPlayed)
return HookResult.Continue;

var player = @event.Userid;

if (player == null || !player.IsValid || player.IsBot)
return HookResult.Continue;

if (!(GPlayersMusic.TryGetValue(player.Slot, out var musicInfo)
&& musicInfo.TryGetValue(player.Team, out var musicId)
&& musicId != 0))
return HookResult.Continue;

@event.Musickitid = musicId;
@event.Nomusic = 0;
info.DontBroadcast = true;

var newEvent = new EventRoundMvp(true)
{
Userid = player,
Musickitid = musicId,
Nomusic = 0,
};

_mvpPlayed = true;

newEvent.FireEvent(false);
return HookResult.Continue;
}

Expand Down Expand Up @@ -289,6 +324,7 @@ private void RegisterListeners()
RegisterEventHandler<EventPlayerSpawn>(OnPlayerSpawn);
RegisterEventHandler<EventRoundStart>(OnRoundStart);
RegisterEventHandler<EventRoundEnd>(OnRoundEnd);
RegisterEventHandler<EventRoundMvp>(OnRoundMvp);
RegisterListener<Listeners.OnEntityCreated>(OnEntityCreated);
RegisterEventHandler<EventPlayerDeath>(OnPlayerDeath);

Expand Down

0 comments on commit ccee3e5

Please sign in to comment.