Skip to content

Commit

Permalink
Merge pull request #344 from daffyyyy/main
Browse files Browse the repository at this point in the history
3.2b
  • Loading branch information
daffyyyy authored Oct 24, 2024
2 parents ea9963b + 9ec64e3 commit b5d7f12
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 23 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1a
3.1b
43 changes: 22 additions & 21 deletions WeaponAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ private void GivePlayerWeaponSkin(CCSPlayerController player, CBasePlayerWeapon

bool isKnife = weapon.DesignerName.Contains("knife") || weapon.DesignerName.Contains("bayonet");

if (isKnife && !GPlayersKnife.ContainsKey(player.Slot) ||
isKnife && GPlayersKnife[player.Slot][player.Team] == "weapon_knife") return;
if (isKnife && (!GPlayersKnife.ContainsKey(player.Slot) ||
!GPlayersKnife[player.Slot].ContainsKey(player.Team) ||
GPlayersKnife[player.Slot][player.Team] == "weapon_knife"))
return;

if (isKnife)
{
Expand Down Expand Up @@ -52,7 +54,9 @@ private void GivePlayerWeaponSkin(CCSPlayerController player, CBasePlayerWeapon
bool isLegacyModel;

if (_config.Additional.GiveRandomSkin &&
!GPlayerWeaponsInfo[player.Slot][player.Team].ContainsKey(weaponDefIndex))
GPlayerWeaponsInfo.ContainsKey(player.Slot) &&
(!GPlayerWeaponsInfo[player.Slot].ContainsKey(player.Team) ||
!GPlayerWeaponsInfo[player.Slot][player.Team].ContainsKey(weaponDefIndex)))
{
// Random skins
weapon.FallbackPaintKit = GetRandomPaint(weaponDefIndex);
Expand Down Expand Up @@ -103,14 +107,7 @@ private void GivePlayerWeaponSkin(CCSPlayerController player, CBasePlayerWeapon
weapon.AttributeManager.Item.CustomName = weaponInfo.Nametag;
weapon.FallbackPaintKit = weaponInfo.Paint;

if (weaponInfo is { Paint: 38, Seed: 0 })
{
weapon.FallbackSeed = _fadeSeed++;
}
else
{
weapon.FallbackSeed = weaponInfo.Seed;
}
weapon.FallbackSeed = weaponInfo is { Paint: 38, Seed: 0 } ? _fadeSeed++ : weaponInfo.Seed;

weapon.FallbackWear = weaponInfo.Wear;
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, "set item texture prefab", weapon.FallbackPaintKit);
Expand Down Expand Up @@ -186,15 +183,13 @@ private void SetStickers(CCSPlayerController? player, CBasePlayerWeapon weapon)

CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle,
$"sticker slot {stickerSlot} id", ViewAsFloat(sticker.Id));
// CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle,
// $"sticker slot {stickerSlot} schema", stickerSlot);
// if (stickerSlot == 5)
// {
if (sticker.OffsetX != 0 || sticker.OffsetY != 0)
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle,
$"sticker slot {stickerSlot} schema", 0);
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle,
$"sticker slot {stickerSlot} offset x", sticker.OffsetX);
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle,
$"sticker slot {stickerSlot} offset y", sticker.OffsetY);
// }
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle,
$"sticker slot {stickerSlot} wear", sticker.Wear);
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle,
Expand All @@ -217,8 +212,11 @@ private void SetKeychain(CCSPlayerController? player, CBasePlayerWeapon weapon)
int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;

if (!GPlayerWeaponsInfo.TryGetValue(player.Slot, out var playerWeaponsInfo) ||
!playerWeaponsInfo[player.Team].TryGetValue(weaponDefIndex, out var value) ||
value.KeyChain == null) return;
!playerWeaponsInfo.TryGetValue(player.Team, out var teamWeaponsInfo) ||
!teamWeaponsInfo.TryGetValue(weaponDefIndex, out var value) ||
value.KeyChain == null)
return;

var keyChain = value.KeyChain;

CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle,
Expand Down Expand Up @@ -406,9 +404,12 @@ private void GivePlayerGloves(CCSPlayerController player)
return;
if (!GPlayersGlove.TryGetValue(player.Slot, out var gloveInfo) ||
!gloveInfo.TryGetValue(player.Team, out var gloveId) || gloveId == 0) return;
WeaponInfo weaponInfo = GPlayerWeaponsInfo[player.Slot][player.Team][gloveId];
!gloveInfo.TryGetValue(player.Team, out var gloveId) ||
gloveId == 0 ||
!GPlayerWeaponsInfo.TryGetValue(player.Slot, out var playerWeaponsInfo) ||
!playerWeaponsInfo.TryGetValue(player.Team, out var teamWeaponsInfo) ||
!teamWeaponsInfo.TryGetValue(gloveId, out var weaponInfo))
return;
item.ItemDefinitionIndex = gloveId;
item.ItemIDLow = 16384 & 0xFFFFFFFF;
Expand Down
2 changes: 1 addition & 1 deletion WeaponPaints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,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 => "3.1a";
public override string ModuleVersion => "3.1b";

public override void Load(bool hotReload)
{
Expand Down

0 comments on commit b5d7f12

Please sign in to comment.