mirror of
https://github.com/Nereziel/cs2-WeaponPaints.git
synced 2026-02-28 21:44:40 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a6d4108ca7 | ||
|
|
7b45169d8d | ||
|
|
42bd45c3f0 |
@@ -195,37 +195,39 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
|||||||
}
|
}
|
||||||
Server.NextFrame(() =>
|
Server.NextFrame(() =>
|
||||||
{
|
{
|
||||||
if (!weapon.IsValid) return;
|
try {
|
||||||
if (weapon.OwnerEntity.Value == null) return;
|
if (!weapon.IsValid) return;
|
||||||
if (!weapon.OwnerEntity.Value.EntityIndex.HasValue) return;
|
if (weapon.OwnerEntity.Value == null) return;
|
||||||
int weaponOwner = (int)weapon.OwnerEntity.Value.EntityIndex.Value.Value;
|
if (!weapon.OwnerEntity.Value.EntityIndex.HasValue) return;
|
||||||
var pawn = new CBasePlayerPawn(NativeAPI.GetEntityFromIndex(weaponOwner));
|
int weaponOwner = (int)weapon.OwnerEntity.Value.EntityIndex.Value.Value;
|
||||||
if (!pawn.IsValid) return;
|
var pawn = new CBasePlayerPawn(NativeAPI.GetEntityFromIndex(weaponOwner));
|
||||||
var playerIndex = (int)pawn.Controller.Value.EntityIndex!.Value.Value;
|
if (!pawn.IsValid) return;
|
||||||
var player = Utilities.GetPlayerFromIndex(playerIndex);
|
var playerIndex = (int)pawn.Controller.Value.EntityIndex!.Value.Value;
|
||||||
if (player == null || !player.IsValid || player.IsBot) return;
|
var player = Utilities.GetPlayerFromIndex(playerIndex);
|
||||||
// TODO: Remove knife crashes here, needs another solution
|
if (player == null || !player.IsValid || player.IsBot) return;
|
||||||
/*if (isKnife && g_playersKnife[(int)player.EntityIndex!.Value.Value] != "weapon_knife" && (weapon.AttributeManager.Item.ItemDefinitionIndex == 42 || weapon.AttributeManager.Item.ItemDefinitionIndex == 59))
|
// TODO: Remove knife crashes here, needs another solution
|
||||||
{
|
/*if (isKnife && g_playersKnife[(int)player.EntityIndex!.Value.Value] != "weapon_knife" && (weapon.AttributeManager.Item.ItemDefinitionIndex == 42 || weapon.AttributeManager.Item.ItemDefinitionIndex == 59))
|
||||||
RemoveKnifeFromPlayer(player);
|
{
|
||||||
return;
|
RemoveKnifeFromPlayer(player);
|
||||||
}*/
|
return;
|
||||||
var steamId = new SteamID(player.SteamID);
|
}*/
|
||||||
if (!gPlayerWeaponPaints.ContainsKey(steamId.SteamId64)) return;
|
var steamId = new SteamID(player.SteamID);
|
||||||
if (!gPlayerWeaponPaints[steamId.SteamId64].ContainsKey(weapon.AttributeManager.Item.ItemDefinitionIndex)) return;
|
if (!gPlayerWeaponPaints.ContainsKey(steamId.SteamId64)) return;
|
||||||
//Log($"Apply on {weapon.DesignerName}({weapon.AttributeManager.Item.ItemDefinitionIndex}) paint {gPlayerWeaponPaints[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex]} seed {gPlayerWeaponSeed[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex]} wear {gPlayerWeaponWear[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex]}");
|
if (!gPlayerWeaponPaints[steamId.SteamId64].ContainsKey(weapon.AttributeManager.Item.ItemDefinitionIndex)) return;
|
||||||
weapon.AttributeManager.Item.ItemID = 16384;
|
//Log($"Apply on {weapon.DesignerName}({weapon.AttributeManager.Item.ItemDefinitionIndex}) paint {gPlayerWeaponPaints[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex]} seed {gPlayerWeaponSeed[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex]} wear {gPlayerWeaponWear[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex]}");
|
||||||
weapon.AttributeManager.Item.ItemIDLow = 16384 & 0xFFFFFFFF;
|
weapon.AttributeManager.Item.ItemID = 16384;
|
||||||
weapon.AttributeManager.Item.ItemIDHigh = weapon.AttributeManager.Item.ItemIDLow >> 32;
|
weapon.AttributeManager.Item.ItemIDLow = 16384 & 0xFFFFFFFF;
|
||||||
weapon.FallbackPaintKit = gPlayerWeaponPaints[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex];
|
weapon.AttributeManager.Item.ItemIDHigh = weapon.AttributeManager.Item.ItemIDLow >> 32;
|
||||||
weapon.FallbackSeed = gPlayerWeaponSeed[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex];
|
weapon.FallbackPaintKit = gPlayerWeaponPaints[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex];
|
||||||
weapon.FallbackWear = gPlayerWeaponWear[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex];
|
weapon.FallbackSeed = gPlayerWeaponSeed[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex];
|
||||||
if (!isKnife && weapon.CBodyComponent != null && weapon.CBodyComponent.SceneNode != null)
|
weapon.FallbackWear = gPlayerWeaponWear[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex];
|
||||||
{
|
if (!isKnife && weapon.CBodyComponent != null && weapon.CBodyComponent.SceneNode != null)
|
||||||
var skeleton = GetSkeletonInstance(weapon.CBodyComponent.SceneNode);
|
{
|
||||||
skeleton.ModelState.MeshGroupMask = 2;
|
var skeleton = GetSkeletonInstance(weapon.CBodyComponent.SceneNode);
|
||||||
}
|
skeleton.ModelState.MeshGroupMask = 2;
|
||||||
});
|
}
|
||||||
|
} catch(Exception) {}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
public void GiveKnifeToPlayer(CCSPlayerController player)
|
public void GiveKnifeToPlayer(CCSPlayerController player)
|
||||||
{
|
{
|
||||||
@@ -267,6 +269,7 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
|||||||
}
|
}
|
||||||
public void RefreshPlayerKnife(CCSPlayerController player)
|
public void RefreshPlayerKnife(CCSPlayerController player)
|
||||||
{
|
{
|
||||||
|
if (!player.IsValid || !player.PawnIsAlive) return;
|
||||||
if (!PlayerHasKnife(player))
|
if (!PlayerHasKnife(player))
|
||||||
GiveKnifeToPlayer(player);
|
GiveKnifeToPlayer(player);
|
||||||
}
|
}
|
||||||
@@ -320,11 +323,11 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
|||||||
|
|
||||||
public bool PlayerHasKnife(CCSPlayerController player)
|
public bool PlayerHasKnife(CCSPlayerController player)
|
||||||
{
|
{
|
||||||
if (!Config.Additional.KnifeEnabled) return true;
|
if (!Config.Additional.KnifeEnabled) return false;
|
||||||
|
|
||||||
if (!player.IsValid || !player.PlayerPawn.IsValid)
|
if (!player.IsValid || !player.PawnIsAlive)
|
||||||
{
|
{
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var weapons = player.PlayerPawn.Value.WeaponServices!.MyWeapons;
|
var weapons = player.PlayerPawn.Value.WeaponServices!.MyWeapons;
|
||||||
|
|||||||
Reference in New Issue
Block a user