Skip to content

Commit

Permalink
Merge pull request #327 from daffyyyy/main
Browse files Browse the repository at this point in the history
2.9c
  • Loading branch information
daffyyyy authored Oct 19, 2024
2 parents aca68aa + 7724102 commit 5808255
Showing 5 changed files with 22 additions and 44 deletions.
4 changes: 4 additions & 0 deletions Commands.cs
Original file line number Diff line number Diff line change
@@ -682,6 +682,8 @@ private void SetupMusicMenu()
playerMusic[team] = 0;
}
}

GivePlayerMusicKit(player);

if (!string.IsNullOrEmpty(Localizer["wp_music_menu_select"]))
{
@@ -712,6 +714,8 @@ private void SetupMusicMenu()
{
playerMusic[team] = 0;
}

GivePlayerMusicKit(player);

if (!string.IsNullOrEmpty(Localizer["wp_music_menu_select"]))
{
43 changes: 7 additions & 36 deletions Events.cs
Original file line number Diff line number Diff line change
@@ -111,35 +111,6 @@ public HookResult OnPlayerDisconnect(EventPlayerDisconnect @event, GameEventInfo
return HookResult.Continue;
}

[GameEventHandler(HookMode.Pre)]
public HookResult OnPlayerMvp(EventRoundMvp @event, GameEventInfo info)
{
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;
@event.Musickitmvps = 1;
@event.Value = 1;

var newEvent = new EventRoundMvp(true)
{
Musickitid = musicId,
Nomusic = 0,
Musickitmvps = 1,
Value = 1
};

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

private void OnMapStart(string mapName)
{
if (Config.Additional is { KnifeEnabled: false, SkinEnabled: false, GloveEnabled: false }) return;
@@ -171,7 +142,6 @@ private HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
private HookResult OnRoundEnd(EventRoundEnd @event, GameEventInfo info)
{
_gBCommandsAllowed = false;

return HookResult.Continue;
}

@@ -249,9 +219,8 @@ private void OnTick()
if (!Config.Additional.ShowSkinImage) return;

foreach (var player in Utilities.GetPlayers().Where(p =>
p is { IsValid: true, PlayerPawn.IsValid: true } &&
(LifeState_t)p.LifeState == LifeState_t.LIFE_ALIVE
&& !p.IsBot && p is { Connected: PlayerConnectedState.PlayerConnected }
p is { IsValid: true, PlayerPawn.IsValid: true, IsBot: false } and
{ Connected: PlayerConnectedState.PlayerConnected }
)
)
{
@@ -284,18 +253,20 @@ private HookResult OnPlayerDeath(EventPlayerDeath @event, GameEventInfo info)
if (player is null || !player.IsValid)
return HookResult.Continue;

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

if (!GPlayerWeaponsInfo.TryGetValue(player.Slot, out _)) return HookResult.Continue;
if (!GPlayerWeaponsInfo.TryGetValue(player.Slot, out var teamInfo) ||
!teamInfo.TryGetValue(player.Team, out var teamWeapons) )
return HookResult.Continue;

CBasePlayerWeapon? weapon = player.PlayerPawn.Value?.WeaponServices?.ActiveWeapon.Value;

if (weapon == null) return HookResult.Continue;

int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;

if (!GPlayerWeaponsInfo[player.Slot][player.Team].TryGetValue(weaponDefIndex, out var weaponInfo) || weaponInfo.Paint == 0)
if (!teamWeapons.TryGetValue(weaponDefIndex, out var weaponInfo) || weaponInfo.Paint == 0)
return HookResult.Continue;

if (!weaponInfo.StatTrak) return HookResult.Continue;
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.9b
2.9c
15 changes: 9 additions & 6 deletions WeaponAction.cs
Original file line number Diff line number Diff line change
@@ -473,17 +473,20 @@ private static void GivePlayerAgent(CCSPlayerController player)

private static void GivePlayerMusicKit(CCSPlayerController player)
{
if (GPlayersMusic.TryGetValue(player.Slot, out var musicInfo) || musicInfo == null ||
if (player.IsBot) return;
if (!GPlayersMusic.TryGetValue(player.Slot, out var musicInfo) ||
!musicInfo.TryGetValue(player.Team, out var musicId) || musicId == 0) return;

if (player.InventoryServices == null) return;

player.InventoryServices.MusicID = musicId;
Utilities.SetStateChanged(player, "CCSPlayerController", "m_pInventoryServices");

player.MusicKitID = musicId;
// player.MvpNoMusic = false;
player.InventoryServices.MusicID = musicId;
Utilities.SetStateChanged(player, "CCSPlayerController", "m_iMusicKitID");
player.MusicKitMVPs = musicId;
Utilities.SetStateChanged(player, "CCSPlayerController", "m_iMusicKitMVPs");
// Utilities.SetStateChanged(player, "CCSPlayerController", "m_bMvpNoMusic");
Utilities.SetStateChanged(player, "CCSPlayerController", "m_pInventoryServices");
// player.MusicKitMVPs = musicId;
// Utilities.SetStateChanged(player, "CCSPlayerController", "m_iMusicKitMVPs");
}

private static void GivePlayerPin(CCSPlayerController player)
2 changes: 1 addition & 1 deletion WeaponPaints.cs
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
public override string ModuleAuthor => "Nereziel & daffyy";
public override string ModuleDescription => "Skin, gloves, agents and knife selector, standalone and web-based";
public override string ModuleName => "WeaponPaints";
public override string ModuleVersion => "2.9b";
public override string ModuleVersion => "2.9c";

public override void Load(bool hotReload)
{

0 comments on commit 5808255

Please sign in to comment.