mirror of
https://github.com/Nereziel/cs2-WeaponPaints.git
synced 2026-02-25 20:58:05 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fb4340cc1d | ||
|
|
bbbf27a751 | ||
|
|
c9d8bb9b5f | ||
|
|
1109c0cf56 | ||
|
|
63869f4c94 | ||
|
|
fa284678e8 | ||
|
|
558f3178f2 |
44
Commands.cs
44
Commands.cs
@@ -207,6 +207,7 @@ namespace WeaponPaints
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
string selectedSkin = opt.Text;
|
string selectedSkin = opt.Text;
|
||||||
string selectedPaintID = selectedSkin.Split('(')[1].Trim(')').Trim();
|
string selectedPaintID = selectedSkin.Split('(')[1].Trim(')').Trim();
|
||||||
|
|
||||||
@@ -216,7 +217,19 @@ namespace WeaponPaints
|
|||||||
int.TryParse(weaponDefIndexObj.ToString(), out var weaponDefIndex) &&
|
int.TryParse(weaponDefIndexObj.ToString(), out var weaponDefIndex) &&
|
||||||
int.TryParse(selectedPaintID, out var paintID))
|
int.TryParse(selectedPaintID, out var paintID))
|
||||||
{
|
{
|
||||||
p!.Print(Localizer["wp_skin_menu_select", selectedSkin]);
|
if (Config.Additional.ShowSkinImage && skinsList != null)
|
||||||
|
{
|
||||||
|
var foundSkin = skinsList.FirstOrDefault(skin =>
|
||||||
|
((int?)skin?["weapon_defindex"] ?? 0) == weaponDefIndex &&
|
||||||
|
((int?)skin?["paint"] ?? 0) == paintID &&
|
||||||
|
skin?["image"] != null
|
||||||
|
);
|
||||||
|
string image = foundSkin?["image"]?.ToString() ?? "";
|
||||||
|
PlayerWeaponImage[p.Slot] = image;
|
||||||
|
AddTimer(2.0f, () => PlayerWeaponImage.Remove(p.Slot));
|
||||||
|
}
|
||||||
|
|
||||||
|
p.Print(Localizer["wp_skin_menu_select", selectedSkin]);
|
||||||
|
|
||||||
if (!gPlayerWeaponsInfo[playerIndex].ContainsKey(weaponDefIndex))
|
if (!gPlayerWeaponsInfo[playerIndex].ContainsKey(weaponDefIndex))
|
||||||
{
|
{
|
||||||
@@ -278,24 +291,23 @@ namespace WeaponPaints
|
|||||||
}
|
}
|
||||||
// Command to open the weapon selection menu for players
|
// Command to open the weapon selection menu for players
|
||||||
AddCommand($"css_{Config.Additional.CommandSkinSelection}", "Skins selection menu", (player, info) =>
|
AddCommand($"css_{Config.Additional.CommandSkinSelection}", "Skins selection menu", (player, info) =>
|
||||||
{
|
{
|
||||||
if (!Utility.IsPlayerValid(player)) return;
|
if (!Utility.IsPlayerValid(player)) return;
|
||||||
|
|
||||||
if (player == null || player.UserId == null) return;
|
if (player == null || player.UserId == null) return;
|
||||||
|
|
||||||
if (!commandsCooldown.TryGetValue((int)player.UserId, out DateTime cooldownEndTime) ||
|
if (!commandsCooldown.TryGetValue((int)player.UserId, out DateTime cooldownEndTime) ||
|
||||||
DateTime.UtcNow >= (commandsCooldown.TryGetValue((int)player.UserId, out cooldownEndTime) ? cooldownEndTime : DateTime.UtcNow))
|
DateTime.UtcNow >= (commandsCooldown.TryGetValue((int)player.UserId, out cooldownEndTime) ? cooldownEndTime : DateTime.UtcNow))
|
||||||
{
|
{
|
||||||
commandsCooldown[(int)player.UserId] = DateTime.UtcNow.AddSeconds(Config.CmdRefreshCooldownSeconds);
|
commandsCooldown[(int)player.UserId] = DateTime.UtcNow.AddSeconds(Config.CmdRefreshCooldownSeconds);
|
||||||
MenuManager.OpenChatMenu(player, weaponSelectionMenu);
|
MenuManager.OpenChatMenu(player, weaponSelectionMenu);
|
||||||
weaponSelectionMenu.PostSelectAction = PostSelectAction.Close;
|
return;
|
||||||
return;
|
}
|
||||||
}
|
if (!string.IsNullOrEmpty(Localizer["wp_command_cooldown"]))
|
||||||
if (!string.IsNullOrEmpty(Localizer["wp_command_cooldown"]))
|
{
|
||||||
{
|
player!.Print(Localizer["wp_command_cooldown"]);
|
||||||
player!.Print(Localizer["wp_command_cooldown"]);
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -43,6 +43,9 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
[JsonPropertyName("GiveKnifeAfterRemove")]
|
[JsonPropertyName("GiveKnifeAfterRemove")]
|
||||||
public bool GiveKnifeAfterRemove { get; set; } = false;
|
public bool GiveKnifeAfterRemove { get; set; } = false;
|
||||||
|
|
||||||
|
[JsonPropertyName("ShowSkinImage")]
|
||||||
|
public bool ShowSkinImage { get; set; } = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class WeaponPaintsConfig : BasePluginConfig
|
public class WeaponPaintsConfig : BasePluginConfig
|
||||||
|
|||||||
166
Events.cs
166
Events.cs
@@ -9,7 +9,8 @@ namespace WeaponPaints
|
|||||||
{
|
{
|
||||||
CCSPlayerController? player = Utilities.GetPlayerFromSlot(playerSlot);
|
CCSPlayerController? player = Utilities.GetPlayerFromSlot(playerSlot);
|
||||||
|
|
||||||
if (player == null || !player.IsValid || player.IsBot || player.IsHLTV || weaponSync == null || player.Connected == PlayerConnectedState.PlayerDisconnecting) return;
|
if (player is null || !player.IsValid || player.IsBot || player.IsHLTV || player.SteamID.ToString().Length != 17 ||
|
||||||
|
weaponSync == null || player.Connected == PlayerConnectedState.PlayerDisconnecting) return;
|
||||||
|
|
||||||
PlayerInfo playerInfo = new PlayerInfo
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
{
|
{
|
||||||
@@ -37,8 +38,7 @@ namespace WeaponPaints
|
|||||||
{
|
{
|
||||||
CCSPlayerController player = Utilities.GetPlayerFromSlot(playerSlot);
|
CCSPlayerController player = Utilities.GetPlayerFromSlot(playerSlot);
|
||||||
|
|
||||||
if (player == null || !player.IsValid || player.IsBot || player.IsHLTV || player.UserId == null)
|
if (player is null || !player.IsValid || !player.UserId.HasValue || player.IsBot || player.IsHLTV || player.SteamID.ToString().Length != 17) return;
|
||||||
return;
|
|
||||||
|
|
||||||
if (Config.Additional.KnifeEnabled)
|
if (Config.Additional.KnifeEnabled)
|
||||||
g_playersKnife.TryRemove((int)player.Index, out _);
|
g_playersKnife.TryRemove((int)player.Index, out _);
|
||||||
@@ -88,53 +88,12 @@ namespace WeaponPaints
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private HookResult OnEventItemPurchasePost(EventItemPurchase @event, GameEventInfo info)
|
|
||||||
{
|
|
||||||
CCSPlayerController? player = @event.Userid;
|
|
||||||
|
|
||||||
if (player == null || !player.IsValid) return HookResult.Continue;
|
|
||||||
|
|
||||||
/*
|
|
||||||
if (Config.Additional.SkinVisibilityFix)
|
|
||||||
AddTimer(0.2f, () => RefreshSkins(player));
|
|
||||||
*/
|
|
||||||
|
|
||||||
return HookResult.Continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
private HookResult OnItemPickup(EventItemPickup @event, GameEventInfo info)
|
|
||||||
{
|
|
||||||
if (@event.Defindex == 42 || @event.Defindex == 59)
|
|
||||||
{
|
|
||||||
CCSPlayerController? player = @event.Userid;
|
|
||||||
if (player == null || !player.IsValid || !g_knifePickupCount.ContainsKey((int)player.Index) || player.IsBot || !g_playersKnife.ContainsKey((int)player.Index))
|
|
||||||
return HookResult.Continue;
|
|
||||||
|
|
||||||
if (g_knifePickupCount[(int)player.Index] >= 2) return HookResult.Continue;
|
|
||||||
|
|
||||||
if (g_playersKnife.ContainsKey((int)player.Index)
|
|
||||||
&&
|
|
||||||
g_playersKnife[(int)player.Index] != "weapon_knife")
|
|
||||||
{
|
|
||||||
g_knifePickupCount[(int)player.Index]++;
|
|
||||||
|
|
||||||
RemovePlayerKnife(player, true);
|
|
||||||
|
|
||||||
if (!PlayerHasKnife(player) && Config.Additional.GiveKnifeAfterRemove)
|
|
||||||
AddTimer(0.3f, () => GiveKnifeToPlayer(player));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return HookResult.Continue;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
public HookResult OnPickup(CEntityIOOutput output, string name, CEntityInstance activator, CEntityInstance caller, CVariant value, float delay)
|
public HookResult OnPickup(CEntityIOOutput output, string name, CEntityInstance activator, CEntityInstance caller, CVariant value, float delay)
|
||||||
{
|
{
|
||||||
CCSPlayerController? player = Utilities.GetEntityFromIndex<CCSPlayerPawn>((int)activator.Index).OriginalController.Value;
|
CCSPlayerController? player = Utilities.GetEntityFromIndex<CCSPlayerPawn>((int)activator.Index).OriginalController.Value;
|
||||||
|
|
||||||
if (player == null || player.IsBot || player.IsHLTV ||
|
if (player == null || player.IsBot || player.IsHLTV ||
|
||||||
player.SteamID.ToString() == "" || !g_knifePickupCount.TryGetValue((int)player.Index, out var pickupCount) ||
|
player.SteamID.ToString().Length != 17 || !g_knifePickupCount.TryGetValue((int)player.Index, out var pickupCount) ||
|
||||||
!g_playersKnife.ContainsKey((int)player.Index))
|
!g_playersKnife.ContainsKey((int)player.Index))
|
||||||
{
|
{
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
@@ -156,10 +115,14 @@ namespace WeaponPaints
|
|||||||
{
|
{
|
||||||
pickupCount++;
|
pickupCount++;
|
||||||
g_knifePickupCount[(int)player.Index] = pickupCount;
|
g_knifePickupCount[(int)player.Index] = pickupCount;
|
||||||
player.RemoveItemByDesignerName(weapon.DesignerName);
|
|
||||||
if (Config.Additional.GiveKnifeAfterRemove)
|
if (Config.Additional.GiveKnifeAfterRemove)
|
||||||
{
|
{
|
||||||
AddTimer(0.2f, () => GiveKnifeToPlayer(player));
|
AddTimer(0.37f, () =>
|
||||||
|
{
|
||||||
|
player.RemoveItemByDesignerName(weapon.DesignerName, true);
|
||||||
|
GiveKnifeToPlayer(player);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,72 +147,14 @@ namespace WeaponPaints
|
|||||||
if (Config.GlobalShare)
|
if (Config.GlobalShare)
|
||||||
GlobalShareConnect();
|
GlobalShareConnect();
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
|
||||||
g_hTimerCheckSkinsData = AddTimer(10.0f, () =>
|
|
||||||
{
|
|
||||||
List<CCSPlayerController> players = Utilities.GetPlayers();
|
|
||||||
|
|
||||||
foreach (CCSPlayerController player in players)
|
|
||||||
{
|
|
||||||
if (player.IsBot || player.IsHLTV || player.SteamID.ToString() == "") continue;
|
|
||||||
if (gPlayerWeaponsInfo.ContainsKey((int)player.Index)) continue;
|
|
||||||
|
|
||||||
PlayerInfo playerInfo = new PlayerInfo
|
|
||||||
{
|
|
||||||
UserId = player.UserId,
|
|
||||||
Index = (int)player.Index,
|
|
||||||
SteamId = player?.SteamID.ToString(),
|
|
||||||
Name = player?.PlayerName,
|
|
||||||
IpAddress = player?.IpAddress?.Split(":")[0]
|
|
||||||
};
|
|
||||||
|
|
||||||
if (Config.Additional.SkinEnabled && weaponSync != null)
|
|
||||||
_ = weaponSync.GetWeaponPaintsFromDatabase(playerInfo);
|
|
||||||
if (Config.Additional.KnifeEnabled && weaponSync != null)
|
|
||||||
_ = weaponSync.GetKnifeFromDatabase(playerInfo);
|
|
||||||
}
|
|
||||||
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE | CounterStrikeSharp.API.Modules.Timers.TimerFlags.REPEAT);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
private HookResult OnPlayerConnectFull(EventPlayerConnectFull @event, GameEventInfo info)
|
|
||||||
{
|
|
||||||
CCSPlayerController? player = @event.Userid;
|
|
||||||
|
|
||||||
if (player == null || !player.IsValid || player.IsBot || player.IsHLTV || weaponSync == null) return HookResult.Continue;
|
|
||||||
|
|
||||||
PlayerInfo playerInfo = new PlayerInfo
|
|
||||||
{
|
|
||||||
UserId = player.UserId,
|
|
||||||
Index = (int)player.Index,
|
|
||||||
SteamId = player?.SteamID.ToString(),
|
|
||||||
Name = player?.PlayerName,
|
|
||||||
IpAddress = player?.IpAddress?.Split(":")[0]
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!gPlayerWeaponsInfo.ContainsKey((int)player!.Index))
|
|
||||||
{
|
|
||||||
Console.WriteLine($"[WeaponPaints] Retrying to retrieve player {player.PlayerName} skins");
|
|
||||||
Task.Run(async () =>
|
|
||||||
{
|
|
||||||
if (Config.Additional.SkinEnabled)
|
|
||||||
await weaponSync.GetWeaponPaintsFromDatabase(playerInfo);
|
|
||||||
if (Config.Additional.KnifeEnabled)
|
|
||||||
await weaponSync.GetKnifeFromDatabase(playerInfo);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return HookResult.Continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
|
private HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
|
||||||
{
|
{
|
||||||
CCSPlayerController? player = @event.Userid;
|
CCSPlayerController? player = @event.Userid;
|
||||||
if (player == null || !player.IsValid || !Config.Additional.KnifeEnabled || PlayerHasKnife(player))
|
|
||||||
{
|
if (player is null || !player.IsValid || !Config.Additional.KnifeEnabled)
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
}
|
|
||||||
|
|
||||||
g_knifePickupCount[(int)player.Index] = 0;
|
g_knifePickupCount[(int)player.Index] = 0;
|
||||||
GiveKnifeToPlayer(player);
|
GiveKnifeToPlayer(player);
|
||||||
@@ -280,7 +185,16 @@ namespace WeaponPaints
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (player is null || !player.IsValid || !player.PawnIsAlive || player.IsBot || player.IsHLTV || player.Connected != PlayerConnectedState.PlayerConnected)
|
if (player is null || !player.IsValid || !player.PawnIsAlive || player.SteamID.ToString().Length != 17
|
||||||
|
|| player.IsBot || player.IsHLTV || player.Connected != PlayerConnectedState.PlayerConnected)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (Config.Additional.ShowSkinImage && PlayerWeaponImage.ContainsKey(player.Slot) && !string.IsNullOrEmpty(PlayerWeaponImage[player.Slot]))
|
||||||
|
{
|
||||||
|
player.PrintToCenterHtml("<img src='{PATH}'</img>".Replace("{PATH}", PlayerWeaponImage[player.Slot]));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player.PlayerPawn?.IsValid != true || player.PlayerPawn?.Value?.IsValid != true)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var viewModels = GetPlayerViewModels(player);
|
var viewModels = GetPlayerViewModels(player);
|
||||||
@@ -292,7 +206,7 @@ namespace WeaponPaints
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
var weapon = viewModel.Value.Weapon.Value;
|
var weapon = viewModel.Value.Weapon.Value;
|
||||||
if (weapon == null || !weapon.IsValid)
|
if (weapon == null || !weapon.IsValid || weapon.FallbackPaintKit == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (viewModel.Value.VMName.Contains("knife"))
|
if (viewModel.Value.VMName.Contains("knife"))
|
||||||
@@ -306,8 +220,8 @@ namespace WeaponPaints
|
|||||||
if (skeleton == null)
|
if (skeleton == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int[] knifePaintKits = { 1171, 1170, 1169, 1164, 1162, 1161, 1159, 1175, 1174, 1167, 1165, 1168, 1163, 1160, 1166, 1173 };
|
int[] newPaints = { 1171, 1170, 1169, 1164, 1162, 1161, 1159, 1175, 1174, 1167, 1165, 1168, 1163, 1160, 1166, 1173 };
|
||||||
if (knifePaintKits.Contains(weapon.FallbackPaintKit))
|
if (newPaints.Contains(weapon.FallbackPaintKit))
|
||||||
{
|
{
|
||||||
skeleton.ModelState.MeshGroupMask = 1;
|
skeleton.ModelState.MeshGroupMask = 1;
|
||||||
}
|
}
|
||||||
@@ -323,7 +237,6 @@ namespace WeaponPaints
|
|||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
// Handle exceptions silently
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -336,36 +249,13 @@ namespace WeaponPaints
|
|||||||
RegisterListener<Listeners.OnMapStart>(OnMapStart);
|
RegisterListener<Listeners.OnMapStart>(OnMapStart);
|
||||||
RegisterListener<Listeners.OnTick>(OnTick);
|
RegisterListener<Listeners.OnTick>(OnTick);
|
||||||
|
|
||||||
//RegisterEventHandler<EventPlayerConnectFull>(OnPlayerConnectFull);
|
|
||||||
RegisterEventHandler<EventPlayerSpawn>(OnPlayerSpawn);
|
RegisterEventHandler<EventPlayerSpawn>(OnPlayerSpawn);
|
||||||
RegisterEventHandler<EventRoundStart>(OnRoundStart, HookMode.Pre);
|
RegisterEventHandler<EventRoundStart>(OnRoundStart, HookMode.Pre);
|
||||||
RegisterEventHandler<EventRoundEnd>(OnRoundEnd);
|
RegisterEventHandler<EventRoundEnd>(OnRoundEnd);
|
||||||
//RegisterEventHandler<EventItemPurchase>(OnEventItemPurchasePost);
|
|
||||||
//RegisterEventHandler<EventItemPickup>(OnItemPickup);
|
//RegisterEventHandler<EventItemPickup>(OnItemPickup);
|
||||||
HookEntityOutput("weapon_knife", "OnPlayerPickup", OnPickup, HookMode.Pre);
|
|
||||||
|
HookEntityOutput("weapon_knife", "OnPlayerPickup", OnPickup);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* WORKAROUND FOR CLIENTS WITHOUT STEAMID ON AUTHORIZATION */
|
|
||||||
/*private HookResult OnPlayerConnectFull(EventPlayerConnectFull @event, GameEventInfo info)
|
|
||||||
{
|
|
||||||
CCSPlayerController? player = @event.Userid;
|
|
||||||
|
|
||||||
if (player == null || !player.IsValid || !player.EntityIndex.HasValue || player.IsHLTV) return HookResult.Continue;
|
|
||||||
|
|
||||||
int playerIndex = (int)player.EntityIndex.Value.Value;
|
|
||||||
if (Config.Additional.SkinEnabled && weaponSync != null)
|
|
||||||
_ = weaponSync.GetWeaponPaintsFromDatabase(playerIndex);
|
|
||||||
if (Config.Additional.KnifeEnabled && weaponSync != null)
|
|
||||||
_ = weaponSync.GetKnifeFromDatabase(playerIndex);
|
|
||||||
|
|
||||||
Task.Run(async () =>
|
|
||||||
{
|
|
||||||
if (Config.Additional.SkinEnabled && weaponSync != null)
|
|
||||||
if (Config.Additional.KnifeEnabled && weaponSync != null)
|
|
||||||
});
|
|
||||||
|
|
||||||
return HookResult.Continue;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
24
SchemaString.cs
Normal file
24
SchemaString.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using CounterStrikeSharp.API;
|
||||||
|
using CounterStrikeSharp.API.Modules.Memory;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace WeaponPaints;
|
||||||
|
|
||||||
|
public class SchemaString<TSchemaClass> : NativeObject where TSchemaClass : NativeObject
|
||||||
|
{
|
||||||
|
internal SchemaString(TSchemaClass instance, string member) : base(Schema.GetSchemaValue<nint>(instance.Handle, typeof(TSchemaClass).Name!, member))
|
||||||
|
{ }
|
||||||
|
|
||||||
|
internal unsafe void Set(string str)
|
||||||
|
{
|
||||||
|
var bytes = Encoding.UTF8.GetBytes(str);
|
||||||
|
|
||||||
|
for (var i = 0; i < bytes.Length; i++)
|
||||||
|
{
|
||||||
|
Unsafe.Write((void*)(Handle.ToInt64() + i), bytes[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Unsafe.Write((void*)(Handle.ToInt64() + bytes.Length), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
149
WeaponAction.cs
149
WeaponAction.cs
@@ -26,6 +26,8 @@ namespace WeaponPaints
|
|||||||
weapon.AttributeManager.Item.EntityQuality = 3;
|
weapon.AttributeManager.Item.EntityQuality = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int fallbackPaintKit = weapon.FallbackPaintKit;
|
||||||
|
|
||||||
if (_config.Additional.GiveRandomSkin &&
|
if (_config.Additional.GiveRandomSkin &&
|
||||||
!gPlayerWeaponsInfo[playerIndex].ContainsKey(weaponDefIndex))
|
!gPlayerWeaponsInfo[playerIndex].ContainsKey(weaponDefIndex))
|
||||||
{
|
{
|
||||||
@@ -36,13 +38,29 @@ namespace WeaponPaints
|
|||||||
weapon.FallbackPaintKit = GetRandomPaint(weaponDefIndex);
|
weapon.FallbackPaintKit = GetRandomPaint(weaponDefIndex);
|
||||||
weapon.FallbackSeed = 0;
|
weapon.FallbackSeed = 0;
|
||||||
weapon.FallbackWear = 0.000001f;
|
weapon.FallbackWear = 0.000001f;
|
||||||
|
|
||||||
|
fallbackPaintKit = weapon.FallbackPaintKit;
|
||||||
|
|
||||||
|
if (fallbackPaintKit == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var foundSkin = skinsList.FirstOrDefault(skin =>
|
||||||
|
((int?)skin?["weapon_defindex"] ?? 0) == weaponDefIndex &&
|
||||||
|
((int?)skin?["paint"] ?? 0) == fallbackPaintKit &&
|
||||||
|
skin?["paint_name"] != null
|
||||||
|
);
|
||||||
|
|
||||||
|
string skinName = foundSkin?["paint_name"]?.ToString() ?? "";
|
||||||
|
if (!string.IsNullOrEmpty(skinName))
|
||||||
|
new SchemaString<CEconItemView>(weapon.AttributeManager.Item, "m_szCustomName").Set(skinName);
|
||||||
|
|
||||||
if (!isKnife && weapon.CBodyComponent != null && weapon.CBodyComponent.SceneNode != null)
|
if (!isKnife && weapon.CBodyComponent != null && weapon.CBodyComponent.SceneNode != null)
|
||||||
{
|
{
|
||||||
var skeleton = GetSkeletonInstance(weapon.CBodyComponent.SceneNode);
|
var skeleton = GetSkeletonInstance(weapon.CBodyComponent.SceneNode);
|
||||||
|
|
||||||
int[] array = { 1171, 1170, 1169, 1164, 1162, 1161, 1159, 1175, 1174, 1167, 1165, 1168, 1163, 1160, 1166, 1173 };
|
int[] newPaints = { 1171, 1170, 1169, 1164, 1162, 1161, 1159, 1175, 1174, 1167, 1165, 1168, 1163, 1160, 1166, 1173 };
|
||||||
int fallbackPaintKit = weapon.FallbackPaintKit;
|
|
||||||
if (array.Contains(fallbackPaintKit))
|
if (newPaints.Contains(fallbackPaintKit))
|
||||||
{
|
{
|
||||||
skeleton.ModelState.MeshGroupMask = 1;
|
skeleton.ModelState.MeshGroupMask = 1;
|
||||||
}
|
}
|
||||||
@@ -54,6 +72,17 @@ namespace WeaponPaints
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var viewModels = GetPlayerViewModels(player);
|
||||||
|
if (viewModels == null || viewModels.Length == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var viewModel = viewModels[0];
|
||||||
|
if (viewModel == null || viewModel.Value == null || viewModel.Value.Weapon == null || viewModel.Value.Weapon.Value == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Utilities.SetStateChanged(viewModel.Value, "CBaseEntity", "m_CBodyComponent");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,12 +96,26 @@ namespace WeaponPaints
|
|||||||
weapon.FallbackSeed = weaponInfo.Seed;
|
weapon.FallbackSeed = weaponInfo.Seed;
|
||||||
weapon.FallbackWear = weaponInfo.Wear;
|
weapon.FallbackWear = weaponInfo.Wear;
|
||||||
|
|
||||||
|
fallbackPaintKit = weapon.FallbackPaintKit;
|
||||||
|
|
||||||
|
if (fallbackPaintKit == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var foundSkin1 = skinsList.FirstOrDefault(skin =>
|
||||||
|
((int?)skin?["weapon_defindex"] ?? 0) == weaponDefIndex &&
|
||||||
|
((int?)skin?["paint"] ?? 0) == fallbackPaintKit &&
|
||||||
|
skin?["paint_name"] != null
|
||||||
|
);
|
||||||
|
|
||||||
|
var skinName1 = foundSkin1?["paint_name"]?.ToString() ?? "";
|
||||||
|
if (!string.IsNullOrEmpty(skinName1))
|
||||||
|
new SchemaString<CEconItemView>(weapon.AttributeManager.Item, "m_szCustomName").Set(skinName1);
|
||||||
|
|
||||||
if (!isKnife && weapon.CBodyComponent != null && weapon.CBodyComponent.SceneNode != null)
|
if (!isKnife && weapon.CBodyComponent != null && weapon.CBodyComponent.SceneNode != null)
|
||||||
{
|
{
|
||||||
var skeleton = GetSkeletonInstance(weapon.CBodyComponent.SceneNode);
|
var skeleton = GetSkeletonInstance(weapon.CBodyComponent.SceneNode);
|
||||||
int[] array = { 1171, 1170, 1169, 1164, 1162, 1161, 1159, 1175, 1174, 1167, 1165, 1168, 1163, 1160, 1166, 1173 };
|
int[] newPaints = { 1171, 1170, 1169, 1164, 1162, 1161, 1159, 1175, 1174, 1167, 1165, 1168, 1163, 1160, 1166, 1173 };
|
||||||
int fallbackPaintKit = weapon.FallbackPaintKit;
|
if (newPaints.Contains(fallbackPaintKit))
|
||||||
if (array.Contains(fallbackPaintKit))
|
|
||||||
{
|
{
|
||||||
skeleton.ModelState.MeshGroupMask = 1;
|
skeleton.ModelState.MeshGroupMask = 1;
|
||||||
}
|
}
|
||||||
@@ -84,6 +127,16 @@ namespace WeaponPaints
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var viewModels1 = GetPlayerViewModels(player);
|
||||||
|
if (viewModels1 == null || viewModels1.Length == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var viewModel1 = viewModels1[0];
|
||||||
|
if (viewModel1 == null || viewModel1.Value == null || viewModel1.Value.Weapon == null || viewModel1.Value.Weapon.Value == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Utilities.SetStateChanged(viewModel1.Value, "CBaseEntity", "m_CBodyComponent");
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void GiveKnifeToPlayer(CCSPlayerController? player)
|
internal static void GiveKnifeToPlayer(CCSPlayerController? player)
|
||||||
@@ -144,79 +197,6 @@ namespace WeaponPaints
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
internal void RefreshPlayerKnife(CCSPlayerController? player)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
if (player == null || !player.IsValid || player.PlayerPawn.Value == null || !player.PawnIsAlive) return;
|
|
||||||
if (player.PlayerPawn.Value.WeaponServices == null || player.PlayerPawn.Value.ItemServices == null) return;
|
|
||||||
|
|
||||||
var weapons = player.PlayerPawn.Value.WeaponServices.MyWeapons;
|
|
||||||
if (weapons != null && weapons.Count > 0)
|
|
||||||
{
|
|
||||||
CCSPlayer_ItemServices service = new(player.PlayerPawn.Value.ItemServices.Handle);
|
|
||||||
//var dropWeapon = VirtualFunction.CreateVoid<nint, nint>(service.Handle, GameData.GetOffset("CCSPlayer_ItemServices_DropActivePlayerWeapon"));
|
|
||||||
|
|
||||||
foreach (var weapon in weapons)
|
|
||||||
{
|
|
||||||
if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid)
|
|
||||||
{
|
|
||||||
//if (weapon.Value.AttributeManager.Item.ItemDefinitionIndex == 42 || weapon.Value.AttributeManager.Item.ItemDefinitionIndex == 59)
|
|
||||||
if (weapon.Value.DesignerName.Contains("knife") || weapon.Value.DesignerName.Contains("bayonet"))
|
|
||||||
{
|
|
||||||
if (weapon.Index <= 0) return;
|
|
||||||
int weaponEntityIndex = (int)weapon.Index;
|
|
||||||
NativeAPI.IssueClientCommand((int)player.Index - 1, "slot3");
|
|
||||||
AddTimer(0.22f, () =>
|
|
||||||
{
|
|
||||||
if (player.PlayerPawn.Value.WeaponServices.ActiveWeapon.Value!.DesignerName.Contains("knife")
|
|
||||||
||
|
|
||||||
player.PlayerPawn.Value.WeaponServices.ActiveWeapon.Value!.DesignerName.Contains("bayonet")
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (player.PawnIsAlive)
|
|
||||||
{
|
|
||||||
NativeAPI.IssueClientCommand((int)player.Index - 1, "slot3");
|
|
||||||
service.DropActivePlayerWeapon(weapon.Value);
|
|
||||||
GiveKnifeToPlayer(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Task.Delay(TimeSpan.FromSeconds(3.5)).ContinueWith(_ =>
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
CEntityInstance? knife = Utilities.GetEntityFromIndex<CEntityInstance>(weaponEntityIndex);
|
|
||||||
|
|
||||||
if (knife != null && knife.IsValid && knife.Handle != -1 && knife.Index > 0)
|
|
||||||
{
|
|
||||||
knife.Remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception) { }
|
|
||||||
});
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
internal void RefreshSkins(CCSPlayerController? player)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
if (!Utility.IsPlayerValid(player) || !player!.PawnIsAlive) return;
|
|
||||||
|
|
||||||
AddTimer(0.18f, () => NativeAPI.IssueClientCommand((int)player.Index - 1, "slot3"));
|
|
||||||
AddTimer(0.25f, () => NativeAPI.IssueClientCommand((int)player.Index - 1, "slot2"));
|
|
||||||
AddTimer(0.38f, () => NativeAPI.IssueClientCommand((int)player.Index - 1, "slot1"));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
internal void RefreshWeapons(CCSPlayerController? player)
|
internal void RefreshWeapons(CCSPlayerController? player)
|
||||||
{
|
{
|
||||||
if (player == null || !player.IsValid || player.PlayerPawn?.Value == null || (LifeState_t)player.LifeState != LifeState_t.LIFE_ALIVE)
|
if (player == null || !player.IsValid || player.PlayerPawn?.Value == null || (LifeState_t)player.LifeState != LifeState_t.LIFE_ALIVE)
|
||||||
@@ -229,9 +209,6 @@ namespace WeaponPaints
|
|||||||
if (weapons == null || weapons.Count == 0)
|
if (weapons == null || weapons.Count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Dictionary to store weapons and their ammo
|
|
||||||
|
|
||||||
|
|
||||||
if (weapons != null && weapons.Count > 0)
|
if (weapons != null && weapons.Count > 0)
|
||||||
{
|
{
|
||||||
//Dictionary<string, (int, int)> weaponsWithAmmo = new Dictionary<string, (int, int)>();
|
//Dictionary<string, (int, int)> weaponsWithAmmo = new Dictionary<string, (int, int)>();
|
||||||
@@ -270,7 +247,7 @@ namespace WeaponPaints
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!weapon.Value.DesignerName.Contains("knife") && weaponDefindex.TryGetValue(weapon.Value.AttributeManager.Item.ItemDefinitionIndex, out weaponByDefindex) && weaponByDefindex != null)
|
if (!weapon.Value.DesignerName.Contains("knife") && WeaponDefindex.TryGetValue(weapon.Value.AttributeManager.Item.ItemDefinitionIndex, out weaponByDefindex) && weaponByDefindex != null)
|
||||||
{
|
{
|
||||||
int clip1 = weapon.Value.Clip1;
|
int clip1 = weapon.Value.Clip1;
|
||||||
int reservedAmmo = weapon.Value.ReserveAmmo[0];
|
int reservedAmmo = weapon.Value.ReserveAmmo[0];
|
||||||
@@ -337,7 +314,7 @@ namespace WeaponPaints
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void RefreshKnife(CCSPlayerController? player, bool force = false)
|
internal void RefreshKnife(CCSPlayerController? player)
|
||||||
{
|
{
|
||||||
if (player == null || !player.IsValid || player.PlayerPawn?.Value == null || (LifeState_t)player.LifeState != LifeState_t.LIFE_ALIVE)
|
if (player == null || !player.IsValid || player.PlayerPawn?.Value == null || (LifeState_t)player.LifeState != LifeState_t.LIFE_ALIVE)
|
||||||
return;
|
return;
|
||||||
@@ -358,8 +335,7 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
if (weapon.Value.DesignerName.Contains("knife") || weaponData?.GearSlot == gear_slot_t.GEAR_SLOT_KNIFE)
|
if (weapon.Value.DesignerName.Contains("knife") || weaponData?.GearSlot == gear_slot_t.GEAR_SLOT_KNIFE)
|
||||||
{
|
{
|
||||||
player.RemoveItemByDesignerName(weapon.Value.DesignerName, weapon.Value.Entity?.EntityInstance.IsValid ?? false);
|
RefreshWeapons(player);
|
||||||
AddTimer(0.2f, () => GiveKnifeToPlayer(player));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -419,6 +395,5 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -81,6 +81,7 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
|||||||
internal static List<JObject> skinsList = new List<JObject>();
|
internal static List<JObject> skinsList = new List<JObject>();
|
||||||
internal static WeaponSynchronization? weaponSync;
|
internal static WeaponSynchronization? weaponSync;
|
||||||
internal bool g_bCommandsAllowed = true;
|
internal bool g_bCommandsAllowed = true;
|
||||||
|
internal Dictionary<int, string> PlayerWeaponImage = new();
|
||||||
|
|
||||||
internal Uri GlobalShareApi = new("https://weaponpaints.fun/api.php");
|
internal Uri GlobalShareApi = new("https://weaponpaints.fun/api.php");
|
||||||
internal int GlobalShareServerId = 0;
|
internal int GlobalShareServerId = 0;
|
||||||
@@ -88,7 +89,7 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
|||||||
internal static Database? _database;
|
internal static Database? _database;
|
||||||
|
|
||||||
//private CounterStrikeSharp.API.Modules.Timers.Timer? g_hTimerCheckSkinsData = null;
|
//private CounterStrikeSharp.API.Modules.Timers.Timer? g_hTimerCheckSkinsData = null;
|
||||||
public static Dictionary<int, string> weaponDefindex { get; } = new Dictionary<int, string>
|
public static Dictionary<int, string> WeaponDefindex { get; } = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
{ 1, "weapon_deagle" },
|
{ 1, "weapon_deagle" },
|
||||||
{ 2, "weapon_elite" },
|
{ 2, "weapon_elite" },
|
||||||
@@ -151,7 +152,7 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
|||||||
public override string ModuleAuthor => "Nereziel & daffyy";
|
public override string ModuleAuthor => "Nereziel & daffyy";
|
||||||
public override string ModuleDescription => "Skin and knife selector, standalone and web-based";
|
public override string ModuleDescription => "Skin and knife selector, standalone and web-based";
|
||||||
public override string ModuleName => "WeaponPaints";
|
public override string ModuleName => "WeaponPaints";
|
||||||
public override string ModuleVersion => "1.6b";
|
public override string ModuleVersion => "1.7a";
|
||||||
|
|
||||||
public static WeaponPaintsConfig GetWeaponPaintsConfig()
|
public static WeaponPaintsConfig GetWeaponPaintsConfig()
|
||||||
{
|
{
|
||||||
@@ -160,13 +161,14 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
|||||||
|
|
||||||
public override void Load(bool hotReload)
|
public override void Load(bool hotReload)
|
||||||
{
|
{
|
||||||
if (hotReload && weaponSync != null)
|
if (hotReload)
|
||||||
{
|
{
|
||||||
OnMapStart(string.Empty);
|
OnMapStart(string.Empty);
|
||||||
|
|
||||||
foreach (var player in Utilities.GetPlayers())
|
foreach (var player in Utilities.GetPlayers())
|
||||||
{
|
{
|
||||||
if (weaponSync == null || player is null || !player.IsValid || !player.PawnIsAlive || player.IsBot || player.IsHLTV || player.Connected != PlayerConnectedState.PlayerConnected)
|
if (weaponSync == null || player is null || !player.IsValid || player.SteamID.ToString().Length != 17 || !player.PawnIsAlive || player.IsBot ||
|
||||||
|
player.IsHLTV || player.Connected != PlayerConnectedState.PlayerConnected)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
g_knifePickupCount[(int)player.Index] = 0;
|
g_knifePickupCount[(int)player.Index] = 0;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.163" />
|
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.167" />
|
||||||
<PackageReference Include="Dapper" Version="2.1.28" />
|
<PackageReference Include="Dapper" Version="2.1.28" />
|
||||||
<PackageReference Include="MySqlConnector" Version="2.3.5" />
|
<PackageReference Include="MySqlConnector" Version="2.3.5" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
|
|||||||
12078
website/data/skins.json
12078
website/data/skins.json
File diff suppressed because one or more lines are too long
@@ -8,7 +8,7 @@ $weapons = array (
|
|||||||
"weapon_aug" => 8,
|
"weapon_aug" => 8,
|
||||||
"weapon_awp" => 9,
|
"weapon_awp" => 9,
|
||||||
"weapon_famas" => 10,
|
"weapon_famas" => 10,
|
||||||
"weapon_g3sg1" => 10,
|
"weapon_g3sg1" => 11,
|
||||||
"weapon_galilar" => 13,
|
"weapon_galilar" => 13,
|
||||||
"weapon_m249" => 14,
|
"weapon_m249" => 14,
|
||||||
"weapon_m4a1" => 16,
|
"weapon_m4a1" => 16,
|
||||||
@@ -53,7 +53,14 @@ $weapons = array (
|
|||||||
"weapon_knife_stiletto" => 522,
|
"weapon_knife_stiletto" => 522,
|
||||||
"weapon_knife_widowmaker" => 523,
|
"weapon_knife_widowmaker" => 523,
|
||||||
"weapon_knife_skeleton" => 525);
|
"weapon_knife_skeleton" => 525);
|
||||||
$json = json_decode(file_get_contents('skins.json'));
|
|
||||||
|
|
||||||
|
|
||||||
|
$
|
||||||
|
|
||||||
|
$json = json_decode(file_get_contents('https://bymykel.github.io/CSGO-API/api/en/skins.json'));
|
||||||
|
|
||||||
|
die(var_dump($json));
|
||||||
echo "<pre>";
|
echo "<pre>";
|
||||||
foreach($json as $skin)
|
foreach($json as $skin)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user