Compare commits
35 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c418de1e17 | ||
|
|
82e73e764e | ||
|
|
ad6c7df357 | ||
|
|
a1fa8f37c7 | ||
|
|
475e91e779 | ||
|
|
a136f5472e | ||
|
|
b5d7f12024 | ||
|
|
9ec64e346f | ||
|
|
b4dc20523c | ||
|
|
8891ce815e | ||
|
|
ea9963b920 | ||
|
|
4a5a08aca9 | ||
|
|
573604a9d9 | ||
|
|
3929a43e46 | ||
|
|
f7f18b7919 | ||
|
|
0d110d83c7 | ||
|
|
db20e2eef9 | ||
|
|
536cea96d6 | ||
|
|
84684f4a26 | ||
|
|
48b9679236 | ||
|
|
7493ee4c7f | ||
|
|
027a547052 | ||
|
|
686c225f4f | ||
|
|
a5397e3831 | ||
|
|
1b95ddb089 | ||
|
|
7d4078dc40 | ||
|
|
e3011c51ae | ||
|
|
b99f30deb2 | ||
|
|
44c59e6bac | ||
|
|
845a40c189 | ||
|
|
f93bed46f1 | ||
|
|
ccee3e52c9 | ||
|
|
7d33693930 | ||
|
|
7b868611e5 | ||
|
|
b7289dd1e8 |
48
Commands.cs
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Concurrent;
|
||||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Modules.Commands;
|
||||
using CounterStrikeSharp.API.Modules.Menu;
|
||||
@@ -106,6 +107,16 @@ public partial class WeaponPaints
|
||||
|
||||
private void RegisterCommands()
|
||||
{
|
||||
_config.Additional.CommandStattrak.ForEach(c =>
|
||||
{
|
||||
AddCommand($"css_{c}", "Stattrak toggle", (player, info) =>
|
||||
{
|
||||
if (!Utility.IsPlayerValid(player)) return;
|
||||
|
||||
OnCommandStattrak(player, info);
|
||||
});
|
||||
});
|
||||
|
||||
_config.Additional.CommandSkin.ForEach(c =>
|
||||
{
|
||||
AddCommand($"css_{c}", "Skins info", (player, info) =>
|
||||
@@ -138,6 +149,27 @@ public partial class WeaponPaints
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCommandStattrak(CCSPlayerController? player, CommandInfo commandInfo)
|
||||
{
|
||||
if (player == null || !player.IsValid) return;
|
||||
|
||||
var weapon = player.PlayerPawn.Value?.WeaponServices?.ActiveWeapon.Value;
|
||||
|
||||
if (weapon == null || !weapon.IsValid)
|
||||
return;
|
||||
|
||||
if (!HasChangedPaint(player, weapon.AttributeManager.Item.ItemDefinitionIndex, out var weaponInfo) || weaponInfo == null)
|
||||
return;
|
||||
|
||||
weaponInfo.StatTrak = !weaponInfo.StatTrak;
|
||||
RefreshWeapons(player);
|
||||
|
||||
if (!string.IsNullOrEmpty(Localizer["wp_stattrak_action"]))
|
||||
{
|
||||
player.Print(Localizer["wp_stattrak_action"]);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetupKnifeMenu()
|
||||
{
|
||||
if (!Config.Additional.KnifeEnabled || !_gBCommandsAllowed) return;
|
||||
@@ -146,7 +178,7 @@ public partial class WeaponPaints
|
||||
.Where(pair => pair.Key.StartsWith("weapon_knife") || pair.Key.StartsWith("weapon_bayonet"))
|
||||
.ToDictionary(pair => pair.Key, pair => pair.Value);
|
||||
|
||||
var giveItemMenu = MenuApi?.NewMenu(Localizer["wp_knife_menu_title"]);
|
||||
var giveItemMenu = Utility.CreateMenu(Localizer["wp_knife_menu_title"]);
|
||||
|
||||
var handleGive = (CCSPlayerController player, ChatMenuOption option) =>
|
||||
{
|
||||
@@ -230,7 +262,7 @@ public partial class WeaponPaints
|
||||
.Except([new KeyValuePair<string, string>("weapon_knife", "Default Knife")])
|
||||
.ToDictionary(kvp => kvp.Value, kvp => kvp.Key);
|
||||
|
||||
var weaponSelectionMenu = MenuApi?.NewMenu(Localizer["wp_skin_menu_weapon_title"]);
|
||||
var weaponSelectionMenu = Utility.CreateMenu(Localizer["wp_skin_menu_weapon_title"]);
|
||||
|
||||
// Function to handle skin selection for a specific weapon
|
||||
var handleWeaponSelection = (CCSPlayerController? player, ChatMenuOption option) =>
|
||||
@@ -245,7 +277,7 @@ public partial class WeaponPaints
|
||||
weaponName?.ToString() == selectedWeaponClassname
|
||||
)?.ToList();
|
||||
|
||||
var skinSubMenu = MenuApi?.NewMenu(Localizer["wp_skin_menu_skin_title", selectedWeapon]);
|
||||
var skinSubMenu = Utility.CreateMenu(Localizer["wp_skin_menu_skin_title", selectedWeapon]);
|
||||
|
||||
// Function to handle skin selection for the chosen weapon
|
||||
var handleSkinSelection = (CCSPlayerController p, ChatMenuOption opt) =>
|
||||
@@ -302,7 +334,7 @@ public partial class WeaponPaints
|
||||
value.Seed = 0;
|
||||
}
|
||||
|
||||
PlayerInfo playerInfo = new PlayerInfo
|
||||
var playerInfo = new PlayerInfo
|
||||
{
|
||||
UserId = p.UserId,
|
||||
Slot = p.Slot,
|
||||
@@ -381,7 +413,7 @@ public partial class WeaponPaints
|
||||
|
||||
private void SetupGlovesMenu()
|
||||
{
|
||||
var glovesSelectionMenu = MenuApi?.NewMenu(Localizer["wp_glove_menu_title"]);
|
||||
var glovesSelectionMenu = Utility.CreateMenu(Localizer["wp_glove_menu_title"]);
|
||||
if (glovesSelectionMenu == null) return;
|
||||
glovesSelectionMenu.PostSelectAction = PostSelectAction.Close;
|
||||
|
||||
@@ -590,7 +622,7 @@ public partial class WeaponPaints
|
||||
if (!CommandsCooldown.TryGetValue(player.Slot, out DateTime cooldownEndTime) ||
|
||||
DateTime.UtcNow >= (CommandsCooldown.TryGetValue(player.Slot, out cooldownEndTime) ? cooldownEndTime : DateTime.UtcNow))
|
||||
{
|
||||
var agentsSelectionMenu = MenuApi?.NewMenu(Localizer["wp_agent_menu_title"]);
|
||||
var agentsSelectionMenu = Utility.CreateMenu(Localizer["wp_agent_menu_title"]);
|
||||
if (agentsSelectionMenu == null) return;
|
||||
agentsSelectionMenu.PostSelectAction = PostSelectAction.Close;
|
||||
|
||||
@@ -630,7 +662,7 @@ public partial class WeaponPaints
|
||||
|
||||
private void SetupMusicMenu()
|
||||
{
|
||||
var musicSelectionMenu = MenuApi?.NewMenu(Localizer["wp_music_menu_title"]);
|
||||
var musicSelectionMenu = Utility.CreateMenu(Localizer["wp_music_menu_title"]);
|
||||
if (musicSelectionMenu == null) return;
|
||||
musicSelectionMenu.PostSelectAction = PostSelectAction.Close;
|
||||
|
||||
@@ -765,7 +797,7 @@ public partial class WeaponPaints
|
||||
|
||||
private void SetupPinsMenu()
|
||||
{
|
||||
var pinsSelectionMenu = MenuApi?.NewMenu(Localizer["wp_pins_menu_title"]);
|
||||
var pinsSelectionMenu = Utility.CreateMenu(Localizer["wp_pins_menu_title"]);
|
||||
if (pinsSelectionMenu == null) return;
|
||||
pinsSelectionMenu.PostSelectAction = PostSelectAction.Close;
|
||||
|
||||
|
||||
10
Config.cs
@@ -43,6 +43,9 @@ namespace WeaponPaints
|
||||
|
||||
[JsonPropertyName("CommandAgent")]
|
||||
public List<string> CommandAgent { get; set; } = ["agents"];
|
||||
|
||||
[JsonPropertyName("CommandStattrak")]
|
||||
public List<string> CommandStattrak { get; set; } = ["stattrak", "st"];
|
||||
|
||||
[JsonPropertyName("CommandSkin")]
|
||||
public List<string> CommandSkin { get; set; } = ["ws"];
|
||||
@@ -68,7 +71,7 @@ namespace WeaponPaints
|
||||
|
||||
public class WeaponPaintsConfig : BasePluginConfig
|
||||
{
|
||||
[JsonPropertyName("ConfigVersion")] public override int Version { get; set; } = 9;
|
||||
[JsonPropertyName("ConfigVersion")] public override int Version { get; set; } = 10;
|
||||
|
||||
[JsonPropertyName("SkinsLanguage")]
|
||||
public string SkinsLanguage { get; set; } = "en";
|
||||
@@ -89,12 +92,15 @@ namespace WeaponPaints
|
||||
public string DatabaseName { get; set; } = "";
|
||||
|
||||
[JsonPropertyName("CmdRefreshCooldownSeconds")]
|
||||
public int CmdRefreshCooldownSeconds { get; set; } = 10;
|
||||
public int CmdRefreshCooldownSeconds { get; set; } = 3;
|
||||
|
||||
[JsonPropertyName("Website")]
|
||||
public string Website { get; set; } = "example.com/skins";
|
||||
|
||||
[JsonPropertyName("Additional")]
|
||||
public Additional Additional { get; set; } = new();
|
||||
|
||||
[JsonPropertyName("MenuType")]
|
||||
public string MenuType { get; set; } = "selectable";
|
||||
}
|
||||
}
|
||||
91
Events.cs
@@ -9,6 +9,8 @@ namespace WeaponPaints
|
||||
{
|
||||
public partial class WeaponPaints
|
||||
{
|
||||
private bool _mvpPlayed;
|
||||
|
||||
[GameEventHandler]
|
||||
public HookResult OnClientFullConnect(EventPlayerConnectFull @event, GameEventInfo info)
|
||||
{
|
||||
@@ -77,13 +79,17 @@ namespace WeaponPaints
|
||||
IpAddress = player.IpAddress?.Split(":")[0]
|
||||
};
|
||||
|
||||
if (WeaponSync != null)
|
||||
_ = Task.Run(async () => await WeaponSync.SyncStatTrakToDatabase(playerInfo));
|
||||
|
||||
if (Config.Additional.SkinEnabled)
|
||||
Task.Run(async () =>
|
||||
{
|
||||
GPlayerWeaponsInfo.TryRemove(player.Slot, out _);
|
||||
}
|
||||
if (WeaponSync != null)
|
||||
await WeaponSync.SyncStatTrakToDatabase(playerInfo);
|
||||
|
||||
if (Config.Additional.SkinEnabled)
|
||||
{
|
||||
GPlayerWeaponsInfo.TryRemove(player.Slot, out _);
|
||||
}
|
||||
});
|
||||
|
||||
if (Config.Additional.KnifeEnabled)
|
||||
{
|
||||
GPlayersKnife.TryRemove(player.Slot, out _);
|
||||
@@ -104,7 +110,7 @@ namespace WeaponPaints
|
||||
{
|
||||
GPlayersPin.TryRemove(player.Slot, out _);
|
||||
}
|
||||
|
||||
|
||||
_temporaryPlayerWeaponWear.TryRemove(player.Slot, out _);
|
||||
CommandsCooldown.Remove(player.Slot);
|
||||
|
||||
@@ -114,9 +120,12 @@ namespace WeaponPaints
|
||||
private void OnMapStart(string mapName)
|
||||
{
|
||||
if (Config.Additional is { KnifeEnabled: false, SkinEnabled: false, GloveEnabled: false }) return;
|
||||
|
||||
|
||||
if (Database != null)
|
||||
WeaponSync = new WeaponSynchronization(Database, Config);
|
||||
|
||||
_fadeSeed = 0;
|
||||
_nextItemId = MinimumCustomItemId;
|
||||
}
|
||||
|
||||
private HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
|
||||
@@ -148,10 +157,43 @@ namespace WeaponPaints
|
||||
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;
|
||||
}
|
||||
|
||||
public HookResult OnGiveNamedItemPost(DynamicHook hook)
|
||||
private HookResult OnGiveNamedItemPost(DynamicHook hook)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -162,14 +204,16 @@ namespace WeaponPaints
|
||||
|
||||
var player = GetPlayerFromItemServices(itemServices);
|
||||
if (player != null)
|
||||
{
|
||||
GivePlayerWeaponSkin(player, weapon);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
return HookResult.Continue;
|
||||
}
|
||||
|
||||
public void OnEntityCreated(CEntityInstance entity)
|
||||
private void OnEntityCreated(CEntityInstance entity)
|
||||
{
|
||||
var designerName = entity.DesignerName;
|
||||
|
||||
@@ -234,10 +278,17 @@ namespace WeaponPaints
|
||||
[GameEventHandler]
|
||||
public HookResult OnItemPickup(EventItemPickup @event, GameEventInfo _)
|
||||
{
|
||||
if (!IsWindows) return HookResult.Continue;
|
||||
|
||||
// if (!IsWindows) return HookResult.Continue;
|
||||
var player = @event.Userid;
|
||||
if (player != null && player is { IsValid: true, Connected: PlayerConnectedState.PlayerConnected, PawnIsAlive: true, PlayerPawn.IsValid: true })
|
||||
if (player == null || !player.IsValid || player.IsBot) return HookResult.Continue;
|
||||
if (!@event.Item.Contains("knife")) return HookResult.Continue;
|
||||
|
||||
var weaponDefIndex = (int)@event.Defindex;
|
||||
|
||||
if (!HasChangedKnife(player, out var _) || !HasChangedPaint(player, weaponDefIndex, out var _))
|
||||
return HookResult.Continue;
|
||||
|
||||
if (player is { Connected: PlayerConnectedState.PlayerConnected, PawnIsAlive: true, PlayerPawn.IsValid: true })
|
||||
{
|
||||
GiveOnItemPickup(player);
|
||||
}
|
||||
@@ -255,20 +306,16 @@ namespace WeaponPaints
|
||||
|
||||
if (victim == null || !victim.IsValid || victim == player)
|
||||
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 (!teamWeapons.TryGetValue(weaponDefIndex, out var weaponInfo) || weaponInfo.Paint == 0)
|
||||
if (!HasChangedPaint(player, weaponDefIndex, out var weaponInfo) || weaponInfo == null)
|
||||
return HookResult.Continue;
|
||||
|
||||
|
||||
if (!weaponInfo.StatTrak) return HookResult.Continue;
|
||||
|
||||
weaponInfo.StatTrakCount += 1;
|
||||
@@ -289,14 +336,14 @@ namespace WeaponPaints
|
||||
RegisterEventHandler<EventPlayerSpawn>(OnPlayerSpawn);
|
||||
RegisterEventHandler<EventRoundStart>(OnRoundStart);
|
||||
RegisterEventHandler<EventRoundEnd>(OnRoundEnd);
|
||||
RegisterEventHandler<EventRoundMvp>(OnRoundMvp);
|
||||
RegisterListener<Listeners.OnEntityCreated>(OnEntityCreated);
|
||||
RegisterEventHandler<EventPlayerDeath>(OnPlayerDeath);
|
||||
|
||||
if (Config.Additional.ShowSkinImage)
|
||||
RegisterListener<Listeners.OnTick>(OnTick);
|
||||
|
||||
if (!IsWindows)
|
||||
VirtualFunctions.GiveNamedItemFunc.Hook(OnGiveNamedItemPost, HookMode.Post);
|
||||
VirtualFunctions.GiveNamedItemFunc.Hook(OnGiveNamedItemPost, HookMode.Post);
|
||||
}
|
||||
}
|
||||
}
|
||||
30
Utility.cs
@@ -1,6 +1,8 @@
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Core.Translations;
|
||||
using CounterStrikeSharp.API.Modules.Menu;
|
||||
using Dapper;
|
||||
using MenuManager;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
@@ -188,10 +190,32 @@ namespace WeaponPaints
|
||||
Console.WriteLine("[WeaponPaints] " + message);
|
||||
Console.ResetColor();
|
||||
}
|
||||
|
||||
internal static string ReplaceTags(string message)
|
||||
|
||||
internal static IMenu? CreateMenu(string title)
|
||||
{
|
||||
return message.ReplaceColorTags();
|
||||
var menuType = WeaponPaints.Instance.Config.MenuType.ToLower();
|
||||
|
||||
var menu = menuType switch
|
||||
{
|
||||
_ when menuType.Equals("selectable", StringComparison.CurrentCultureIgnoreCase) =>
|
||||
WeaponPaints.MenuApi?.NewMenu(title),
|
||||
|
||||
_ when menuType.Equals("dynamic", StringComparison.CurrentCultureIgnoreCase) =>
|
||||
WeaponPaints.MenuApi?.NewMenuForcetype(title, MenuType.ButtonMenu),
|
||||
|
||||
_ when menuType.Equals("center", StringComparison.CurrentCultureIgnoreCase) =>
|
||||
WeaponPaints.MenuApi?.NewMenuForcetype(title, MenuType.CenterMenu),
|
||||
|
||||
_ when menuType.Equals("chat", StringComparison.CurrentCultureIgnoreCase) =>
|
||||
WeaponPaints.MenuApi?.NewMenuForcetype(title, MenuType.ChatMenu),
|
||||
|
||||
_ when menuType.Equals("console", StringComparison.CurrentCultureIgnoreCase) =>
|
||||
WeaponPaints.MenuApi?.NewMenuForcetype(title, MenuType.ConsoleMenu),
|
||||
|
||||
_ => WeaponPaints.MenuApi?.NewMenu(title)
|
||||
};
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
internal static async Task CheckVersion(string version, ILogger logger)
|
||||
|
||||
@@ -77,7 +77,7 @@ public partial class WeaponPaints
|
||||
internal static readonly ConcurrentDictionary<int, ConcurrentDictionary<CsTeam, ushort>> GPlayersGlove = new();
|
||||
internal static readonly ConcurrentDictionary<int, ConcurrentDictionary<CsTeam, ushort>> GPlayersMusic = new();
|
||||
internal static readonly ConcurrentDictionary<int, ConcurrentDictionary<CsTeam, ushort>> GPlayersPin = new();
|
||||
public static readonly ConcurrentDictionary<int, (string? CT, string? T)> GPlayersAgent = new();
|
||||
internal static readonly ConcurrentDictionary<int, (string? CT, string? T)> GPlayersAgent = new();
|
||||
internal static readonly ConcurrentDictionary<int, ConcurrentDictionary<CsTeam, ConcurrentDictionary<int, WeaponInfo>>> GPlayerWeaponsInfo = new();
|
||||
internal static List<JObject> SkinsList = [];
|
||||
internal static List<JObject> PinsList = [];
|
||||
@@ -92,7 +92,7 @@ public partial class WeaponPaints
|
||||
internal static Database? Database;
|
||||
|
||||
private static readonly MemoryFunctionVoid<nint, string, float> CAttributeListSetOrAddAttributeValueByName = new(GameData.GetSignature("CAttributeList_SetOrAddAttributeValueByName"));
|
||||
|
||||
|
||||
private static readonly MemoryFunctionWithReturn<nint, string, int, int> SetBodygroupFunc = new(
|
||||
GameData.GetSignature("CBaseModelEntity_SetBodygroup"));
|
||||
|
||||
@@ -165,4 +165,6 @@ public partial class WeaponPaints
|
||||
|
||||
internal static IMenuApi? MenuApi;
|
||||
private static readonly PluginCapability<IMenuApi> MenuCapability = new("menu:nfcore");
|
||||
|
||||
private int _fadeSeed;
|
||||
}
|
||||
153
WeaponAction.cs
@@ -20,27 +20,34 @@ namespace WeaponPaints
|
||||
|
||||
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)
|
||||
switch (isKnife)
|
||||
{
|
||||
var newDefIndex = WeaponDefindex.FirstOrDefault(x => x.Value == GPlayersKnife[player.Slot][player.Team]);
|
||||
if (newDefIndex.Key == 0) return;
|
||||
|
||||
if (weapon.AttributeManager.Item.ItemDefinitionIndex != newDefIndex.Key)
|
||||
case true when !HasChangedKnife(player, out var _):
|
||||
return;
|
||||
|
||||
case true:
|
||||
{
|
||||
SubclassChange(weapon, (ushort)newDefIndex.Key);
|
||||
}
|
||||
var newDefIndex = WeaponDefindex.FirstOrDefault(x => x.Value == GPlayersKnife[player.Slot][player.Team]);
|
||||
if (newDefIndex.Key == 0) return;
|
||||
|
||||
weapon.AttributeManager.Item.ItemDefinitionIndex = (ushort)newDefIndex.Key;
|
||||
weapon.AttributeManager.Item.EntityQuality = 3;
|
||||
if (weapon.AttributeManager.Item.ItemDefinitionIndex != newDefIndex.Key)
|
||||
{
|
||||
SubclassChange(weapon, (ushort)newDefIndex.Key);
|
||||
}
|
||||
|
||||
weapon.AttributeManager.Item.ItemDefinitionIndex = (ushort)newDefIndex.Key;
|
||||
weapon.AttributeManager.Item.EntityQuality = 3;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
weapon.AttributeManager.Item.EntityQuality = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
UpdatePlayerEconItemId(weapon.AttributeManager.Item);
|
||||
|
||||
int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;
|
||||
int fallbackPaintKit = 0;
|
||||
int fallbackPaintKit;
|
||||
|
||||
weapon.AttributeManager.Item.AccountID = (uint)player.SteamID;
|
||||
|
||||
@@ -48,7 +55,7 @@ namespace WeaponPaints
|
||||
bool isLegacyModel;
|
||||
|
||||
if (_config.Additional.GiveRandomSkin &&
|
||||
!GPlayerWeaponsInfo[player.Slot][player.Team].ContainsKey(weaponDefIndex))
|
||||
!HasChangedPaint(player, weaponDefIndex, out _))
|
||||
{
|
||||
// Random skins
|
||||
weapon.FallbackPaintKit = GetRandomPaint(weaponDefIndex);
|
||||
@@ -81,9 +88,9 @@ namespace WeaponPaints
|
||||
return;
|
||||
}
|
||||
|
||||
if (!GPlayerWeaponsInfo[player.Slot][player.Team].TryGetValue(weaponDefIndex, out var value) || value.Paint == 0) return;
|
||||
if (!HasChangedPaint(player, weaponDefIndex, out var weaponInfo) || weaponInfo == null)
|
||||
return;
|
||||
|
||||
var weaponInfo = value;
|
||||
//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.AttributeList.Attributes.RemoveAll();
|
||||
@@ -94,12 +101,16 @@ namespace WeaponPaints
|
||||
weapon.AttributeManager.Item.ItemIDHigh = weapon.AttributeManager.Item.ItemIDLow >> 32;
|
||||
weapon.AttributeManager.Item.CustomName = weaponInfo.Nametag;
|
||||
weapon.FallbackPaintKit = weaponInfo.Paint;
|
||||
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);
|
||||
|
||||
if (weaponInfo.StatTrak)
|
||||
{
|
||||
{
|
||||
weapon.AttributeManager.Item.EntityQuality = 9;
|
||||
|
||||
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, "kill eater", ViewAsFloat((uint)weaponInfo.StatTrakCount));
|
||||
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, "kill eater score type", 0);
|
||||
|
||||
@@ -112,8 +123,6 @@ namespace WeaponPaints
|
||||
if (fallbackPaintKit == 0)
|
||||
return;
|
||||
|
||||
if (isKnife) return;
|
||||
|
||||
if (weaponInfo.KeyChain != null) SetKeychain(player, weapon);
|
||||
if (weaponInfo.Stickers.Count > 0) SetStickers(player, weapon);
|
||||
|
||||
@@ -124,6 +133,7 @@ namespace WeaponPaints
|
||||
.ToList();
|
||||
|
||||
isLegacyModel = skinInfo.Count <= 0 || skinInfo[0].Value<bool>("legacy_model");
|
||||
|
||||
UpdatePlayerWeaponMeshGroupMask(player, weapon, isLegacyModel);
|
||||
}
|
||||
|
||||
@@ -131,9 +141,7 @@ namespace WeaponPaints
|
||||
private void IncrementWearForWeaponWithStickers(CCSPlayerController player, CBasePlayerWeapon weapon)
|
||||
{
|
||||
int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;
|
||||
if (!GPlayerWeaponsInfo.TryGetValue(player.Slot, out var playerWeapons) ||
|
||||
!playerWeapons.TryGetValue(player.Team, out var weaponInfoDict) ||
|
||||
!weaponInfoDict.TryGetValue(weaponDefIndex, out var weaponInfo) ||
|
||||
if (!HasChangedPaint(player, weaponDefIndex, out var weaponInfo) || weaponInfo == null ||
|
||||
weaponInfo.Stickers.Count <= 0) return;
|
||||
|
||||
float wearIncrement = 0.001f;
|
||||
@@ -156,11 +164,8 @@ namespace WeaponPaints
|
||||
|
||||
int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;
|
||||
|
||||
if (!GPlayerWeaponsInfo.TryGetValue(player.Slot, out var playerWeapons) ||
|
||||
!playerWeapons[player.Team].TryGetValue(weaponDefIndex, out var weaponInfo))
|
||||
{
|
||||
if (!HasChangedPaint(player ,weaponDefIndex, out var weaponInfo) || weaponInfo == null)
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var sticker in weaponInfo.Stickers)
|
||||
{
|
||||
@@ -168,15 +173,13 @@ namespace WeaponPaints
|
||||
|
||||
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)
|
||||
// {
|
||||
// // CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle,
|
||||
// // $"sticker slot {stickerSlot} offset x", 0.05f);
|
||||
// // CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle,
|
||||
// // $"sticker slot {stickerSlot} offset y", 0.02f);
|
||||
// }
|
||||
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,
|
||||
@@ -198,9 +201,9 @@ namespace WeaponPaints
|
||||
|
||||
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;
|
||||
if (!HasChangedPaint(player, weaponDefIndex, out var value) || value?.KeyChain == null)
|
||||
return;
|
||||
|
||||
var keyChain = value.KeyChain;
|
||||
|
||||
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle,
|
||||
@@ -223,6 +226,7 @@ namespace WeaponPaints
|
||||
|
||||
//string knifeToGive = (CsTeam)player.TeamNum == CsTeam.Terrorist ? "weapon_knife_t" : "weapon_knife";
|
||||
player.GiveNamedItem(CsItem.Knife);
|
||||
Utilities.SetStateChanged(player, "CCSPlayerController", "m_pInventoryServices");
|
||||
}
|
||||
|
||||
private static bool PlayerHasKnife(CCSPlayerController? player)
|
||||
@@ -265,6 +269,8 @@ namespace WeaponPaints
|
||||
if (player.Team is CsTeam.None or CsTeam.Spectator)
|
||||
return;
|
||||
|
||||
var hasKnife = false;
|
||||
|
||||
Dictionary<string, List<(int, int)>> weaponsWithAmmo = [];
|
||||
|
||||
foreach (var weapon in weapons)
|
||||
@@ -272,7 +278,7 @@ namespace WeaponPaints
|
||||
if (!weapon.IsValid || weapon.Value == null ||
|
||||
!weapon.Value.IsValid || !weapon.Value.DesignerName.Contains("weapon_"))
|
||||
continue;
|
||||
|
||||
|
||||
CCSWeaponBaseGun gun = weapon.Value.As<CCSWeaponBaseGun>();
|
||||
|
||||
if (weapon.Value.Entity == null) continue;
|
||||
@@ -311,6 +317,7 @@ namespace WeaponPaints
|
||||
if (weaponData.GearSlot == gear_slot_t.GEAR_SLOT_KNIFE)
|
||||
{
|
||||
weapon.Value?.AddEntityIOEvent("Kill", weapon.Value, null, "", 0.1f);
|
||||
hasKnife = true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -322,9 +329,16 @@ namespace WeaponPaints
|
||||
AddTimer(0.23f, () =>
|
||||
{
|
||||
if (!_gBCommandsAllowed) return;
|
||||
|
||||
if (!PlayerHasKnife(player))
|
||||
GiveKnifeToPlayer(player);
|
||||
|
||||
if (!PlayerHasKnife(player) && hasKnife)
|
||||
{
|
||||
var newKnife = new CBasePlayerWeapon(player.GiveNamedItem(CsItem.Knife));
|
||||
newKnife.AddEntityIOEvent("Kill", newKnife, null, "", 0.01f);
|
||||
var newWeapon = new CBasePlayerWeapon(player.GiveNamedItem(CsItem.USP));
|
||||
player.GiveNamedItem(CsItem.Knife);
|
||||
player.ExecuteClientCommand("slot3");
|
||||
newWeapon.AddEntityIOEvent("Kill", newWeapon, null, "", 0.01f);
|
||||
}
|
||||
|
||||
foreach (var entry in weaponsWithAmmo)
|
||||
{
|
||||
@@ -377,9 +391,10 @@ namespace WeaponPaints
|
||||
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 ||
|
||||
!HasChangedPaint(player, gloveId, out var weaponInfo) || weaponInfo == null)
|
||||
return;
|
||||
|
||||
item.ItemDefinitionIndex = gloveId;
|
||||
item.ItemIDLow = 16384 & 0xFFFFFFFF;
|
||||
@@ -443,6 +458,7 @@ namespace WeaponPaints
|
||||
var viewModel = GetPlayerViewModel(player);
|
||||
if (viewModel == null || viewModel.Weapon.Value == null ||
|
||||
viewModel.Weapon.Value.Index != weapon.Index) return;
|
||||
|
||||
UpdateWeaponMeshGroupMask(viewModel, isLegacy);
|
||||
Utilities.SetStateChanged(viewModel, "CBaseEntity", "m_CBodyComponent");
|
||||
}
|
||||
@@ -506,13 +522,22 @@ namespace WeaponPaints
|
||||
|
||||
var myWeapons = pawn.WeaponServices?.MyWeapons;
|
||||
if (myWeapons == null) return;
|
||||
|
||||
foreach (var handle in myWeapons)
|
||||
{
|
||||
var weapon = handle.Value;
|
||||
if (weapon != null && weapon.DesignerName.Contains("knife"))
|
||||
|
||||
if (weapon == null || !weapon.IsValid) continue;
|
||||
if (myWeapons.Count == 1)
|
||||
{
|
||||
GivePlayerWeaponSkin(player, weapon);
|
||||
var newWeapon = new CBasePlayerWeapon(player.GiveNamedItem(CsItem.USP));
|
||||
weapon.AddEntityIOEvent("Kill", weapon, null, "", 0.01f);
|
||||
player.GiveNamedItem(CsItem.Knife);
|
||||
player.ExecuteClientCommand("slot3");
|
||||
newWeapon.AddEntityIOEvent("Kill", newWeapon, null, "", 0.01f);
|
||||
}
|
||||
|
||||
GivePlayerWeaponSkin(player, weapon);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -543,6 +568,36 @@ namespace WeaponPaints
|
||||
return viewModel.Value == null ? null : viewModel.Value;
|
||||
}
|
||||
|
||||
private static bool HasChangedKnife(CCSPlayerController player, out string? knifeValue)
|
||||
{
|
||||
knifeValue = null;
|
||||
|
||||
// Check if player has knife info for their slot and team
|
||||
if (!GPlayersKnife.TryGetValue(player.Slot, out var knife) ||
|
||||
!knife.TryGetValue(player.Team, out var value) ||
|
||||
value == "weapon_knife") return false;
|
||||
knifeValue = value; // Assign the knife value to the out parameter
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool HasChangedPaint(CCSPlayerController player, int weaponDefIndex, out WeaponInfo? weaponInfo)
|
||||
{
|
||||
weaponInfo = null;
|
||||
|
||||
// Check if player has weapons info for their slot and team
|
||||
if (!GPlayerWeaponsInfo.TryGetValue(player.Slot, out var teamInfo) ||
|
||||
!teamInfo.TryGetValue(player.Team, out var teamWeapons))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the specified weapon has a paint/skin change
|
||||
if (!teamWeapons.TryGetValue(weaponDefIndex, out var value) || value.Paint <= 0) return false;
|
||||
|
||||
weaponInfo = value; // Assign the out variable when it exists
|
||||
return true;
|
||||
}
|
||||
|
||||
private static float ViewAsFloat(uint value)
|
||||
{
|
||||
return BitConverter.Int32BitsToSingle((int)value);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
public int Seed { get; set; }
|
||||
public float Wear { get; set; }
|
||||
public string Nametag { get; set; } = "";
|
||||
public bool StatTrak { get; set; } = false;
|
||||
public bool StatTrak { get; set; }
|
||||
public int StatTrakCount { get; set; }
|
||||
public KeyChainInfo? KeyChain { get; set; }
|
||||
public List<StickerInfo> Stickers { get; set; } = new();
|
||||
|
||||
@@ -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.9c";
|
||||
public override string ModuleVersion => "3.1c";
|
||||
|
||||
public override void Load(bool hotReload)
|
||||
{
|
||||
|
||||
@@ -3,7 +3,6 @@ using MySqlConnector;
|
||||
using System.Collections.Concurrent;
|
||||
using CounterStrikeSharp.API.Modules.Utils;
|
||||
|
||||
|
||||
namespace WeaponPaints;
|
||||
|
||||
internal class WeaponSynchronization
|
||||
@@ -50,7 +49,7 @@ internal class WeaponSynchronization
|
||||
if (!_config.Additional.KnifeEnabled || string.IsNullOrEmpty(player?.SteamId))
|
||||
return;
|
||||
|
||||
const string query = "SELECT `knife`, `weapon_team` FROM `wp_player_knife` WHERE `steamid` = @steamid";
|
||||
const string query = "SELECT `knife`, `weapon_team` FROM `wp_player_knife` WHERE `steamid` = @steamid ORDER BY `weapon_team` ASC";
|
||||
var rows = connection.Query<dynamic>(query, new { steamid = player.SteamId }); // Retrieve all records for the player
|
||||
|
||||
foreach (var row in rows)
|
||||
@@ -61,9 +60,9 @@ internal class WeaponSynchronization
|
||||
// Determine the weapon team based on the query result
|
||||
CsTeam weaponTeam = (int)row.weapon_team switch
|
||||
{
|
||||
0 => CsTeam.None,
|
||||
2 => CsTeam.Terrorist,
|
||||
_ => CsTeam.CounterTerrorist
|
||||
3 => CsTeam.CounterTerrorist,
|
||||
_ => CsTeam.None,
|
||||
};
|
||||
|
||||
// Get or create entries for the player’s slot
|
||||
@@ -95,7 +94,7 @@ internal class WeaponSynchronization
|
||||
if (!_config.Additional.GloveEnabled || string.IsNullOrEmpty(player?.SteamId))
|
||||
return;
|
||||
|
||||
const string query = "SELECT `weapon_defindex`, `weapon_team` FROM `wp_player_gloves` WHERE `steamid` = @steamid";
|
||||
const string query = "SELECT `weapon_defindex`, `weapon_team` FROM `wp_player_gloves` WHERE `steamid` = @steamid ORDER BY `weapon_team` ASC";
|
||||
var rows = connection.Query<dynamic>(query, new { steamid = player.SteamId }); // Retrieve all records for the player
|
||||
|
||||
foreach (var row in rows)
|
||||
@@ -106,9 +105,9 @@ internal class WeaponSynchronization
|
||||
var playerGloves = WeaponPaints.GPlayersGlove.GetOrAdd(player.Slot, _ => new ConcurrentDictionary<CsTeam, ushort>());
|
||||
CsTeam weaponTeam = (int)row.weapon_team switch
|
||||
{
|
||||
0 => CsTeam.None,
|
||||
2 => CsTeam.Terrorist,
|
||||
_ => CsTeam.CounterTerrorist
|
||||
3 => CsTeam.CounterTerrorist,
|
||||
_ => CsTeam.None,
|
||||
};
|
||||
|
||||
// Get or create entries for the player’s slot
|
||||
@@ -172,28 +171,27 @@ internal class WeaponSynchronization
|
||||
|
||||
// var weaponInfos = new ConcurrentDictionary<int, WeaponInfo>();
|
||||
|
||||
const string query = "SELECT * FROM `wp_player_skins` WHERE `steamid` = @steamid";
|
||||
const string query = "SELECT * FROM `wp_player_skins` WHERE `steamid` = @steamid ORDER BY `weapon_team` ASC";
|
||||
var playerSkins = connection.Query<dynamic>(query, new { steamid = player.SteamId });
|
||||
|
||||
foreach (var row in playerSkins)
|
||||
{
|
||||
int weaponDefIndex = row?.weapon_defindex ?? 0;
|
||||
int weaponPaintId = row?.weapon_paint_id ?? 0;
|
||||
float weaponWear = row?.weapon_wear ?? 0f;
|
||||
int weaponSeed = row?.weapon_seed ?? 0;
|
||||
string weaponNameTag = row?.weapon_nametag ?? "";
|
||||
bool weaponStatTrak = row?.weapon_stattrak ?? false;
|
||||
int weaponStatTrakCount = row?.weapon_stattrak_count ?? 0;
|
||||
int weaponDefIndex = row.weapon_defindex ?? 0;
|
||||
int weaponPaintId = row.weapon_paint_id ?? 0;
|
||||
float weaponWear = row.weapon_wear ?? 0f;
|
||||
int weaponSeed = row.weapon_seed ?? 0;
|
||||
string weaponNameTag = row.weapon_nametag ?? "";
|
||||
bool weaponStatTrak = row.weapon_stattrak ?? false;
|
||||
int weaponStatTrakCount = row.weapon_stattrak_count ?? 0;
|
||||
|
||||
CsTeam weaponTeam = row?.weapon_team switch
|
||||
CsTeam weaponTeam = row.weapon_team switch
|
||||
{
|
||||
null => CsTeam.None,
|
||||
0 => CsTeam.None,
|
||||
2 => CsTeam.Terrorist,
|
||||
_ => CsTeam.CounterTerrorist
|
||||
3 => CsTeam.CounterTerrorist,
|
||||
_ => CsTeam.None,
|
||||
};
|
||||
|
||||
string[]? keyChainParts = row?.weapon_keychain?.ToString().Split(';');
|
||||
string[]? keyChainParts = row.weapon_keychain?.ToString().Split(';');
|
||||
|
||||
KeyChainInfo keyChainInfo = new KeyChainInfo();
|
||||
|
||||
@@ -303,7 +301,7 @@ internal class WeaponSynchronization
|
||||
if (!_config.Additional.MusicEnabled || string.IsNullOrEmpty(player?.SteamId))
|
||||
return;
|
||||
|
||||
const string query = "SELECT `music_id`, `weapon_team` FROM `wp_player_music` WHERE `steamid` = @steamid";
|
||||
const string query = "SELECT `music_id`, `weapon_team` FROM `wp_player_music` WHERE `steamid` = @steamid ORDER BY `weapon_team` ASC";
|
||||
var rows = connection.Query<dynamic>(query, new { steamid = player.SteamId }); // Retrieve all records for the player
|
||||
|
||||
foreach (var row in rows)
|
||||
@@ -314,9 +312,9 @@ internal class WeaponSynchronization
|
||||
// Determine the weapon team based on the query result
|
||||
CsTeam weaponTeam = (int)row.weapon_team switch
|
||||
{
|
||||
0 => CsTeam.None,
|
||||
2 => CsTeam.Terrorist,
|
||||
_ => CsTeam.CounterTerrorist
|
||||
3 => CsTeam.CounterTerrorist,
|
||||
_ => CsTeam.None,
|
||||
};
|
||||
|
||||
// Get or create entries for the player’s slot
|
||||
@@ -348,7 +346,7 @@ internal class WeaponSynchronization
|
||||
if (string.IsNullOrEmpty(player?.SteamId))
|
||||
return;
|
||||
|
||||
const string query = "SELECT `id`, `weapon_team` FROM `wp_player_pins` WHERE `steamid` = @steamid";
|
||||
const string query = "SELECT `id`, `weapon_team` FROM `wp_player_pins` WHERE `steamid` = @steamid ORDER BY `weapon_team` ASC";
|
||||
var rows = connection.Query<dynamic>(query, new { steamid = player.SteamId }); // Retrieve all records for the player
|
||||
|
||||
foreach (var row in rows)
|
||||
@@ -359,9 +357,9 @@ internal class WeaponSynchronization
|
||||
// Determine the weapon team based on the query result
|
||||
CsTeam weaponTeam = (int)row.weapon_team switch
|
||||
{
|
||||
0 => CsTeam.None,
|
||||
2 => CsTeam.Terrorist,
|
||||
_ => CsTeam.CounterTerrorist
|
||||
3 => CsTeam.CounterTerrorist,
|
||||
_ => CsTeam.None,
|
||||
};
|
||||
|
||||
// Get or create entries for the player’s slot
|
||||
@@ -566,7 +564,6 @@ internal class WeaponSynchronization
|
||||
internal async Task SyncStatTrakToDatabase(PlayerInfo player)
|
||||
{
|
||||
if (WeaponPaints.WeaponSync == null || WeaponPaints.GPlayerWeaponsInfo.IsEmpty) return;
|
||||
|
||||
if (string.IsNullOrEmpty(player.SteamId))
|
||||
return;
|
||||
|
||||
@@ -578,7 +575,7 @@ internal class WeaponSynchronization
|
||||
// Check if player's slot exists in GPlayerWeaponsInfo
|
||||
if (!WeaponPaints.GPlayerWeaponsInfo.TryGetValue(player.Slot, out var teamWeaponsInfo))
|
||||
return;
|
||||
|
||||
|
||||
// Iterate through each team in the player's weapon info
|
||||
foreach (var teamInfo in teamWeaponsInfo)
|
||||
{
|
||||
@@ -587,27 +584,33 @@ internal class WeaponSynchronization
|
||||
|
||||
// Get StatTrak weapons for the current team
|
||||
var statTrakWeapons = weaponInfos
|
||||
.Where(w => w.Value is { StatTrak: true, StatTrakCount: > 0 })
|
||||
.ToDictionary(w => w.Key, w => w.Value.StatTrakCount);
|
||||
.ToDictionary(
|
||||
w => w.Key,
|
||||
w => (w.Value.StatTrak, w.Value.StatTrakCount) // Store both StatTrak and StatTrakCount in a tuple
|
||||
);
|
||||
|
||||
// Check if there are StatTrak weapons to sync
|
||||
if (statTrakWeapons.Count == 0) continue;
|
||||
|
||||
|
||||
// Get the current team ID
|
||||
int weaponTeam = (int)teamInfo.Key;
|
||||
|
||||
// Sync StatTrak values for the current team
|
||||
foreach (var (defindex, statTrakCount) in statTrakWeapons)
|
||||
foreach (var (defindex, (statTrak, statTrakCount)) in statTrakWeapons)
|
||||
{
|
||||
const string query = @"
|
||||
INSERT INTO `wp_player_skins` (`steamid`, `weapon_defindex`, `weapon_stattrak_count`, `weapon_team`)
|
||||
VALUES (@steamid, @weaponDefIndex, @StatTrakCount, @weaponTeam)
|
||||
ON DUPLICATE KEY UPDATE `weapon_stattrak_count` = @StatTrakCount";
|
||||
const string query = @"
|
||||
UPDATE `wp_player_skins`
|
||||
SET `weapon_stattrak` = @StatTrak,
|
||||
`weapon_stattrak_count` = @StatTrakCount
|
||||
WHERE `steamid` = @steamid
|
||||
AND `weapon_defindex` = @weaponDefIndex
|
||||
AND `weapon_team` = @weaponTeam";
|
||||
|
||||
var parameters = new
|
||||
{
|
||||
steamid = player.SteamId,
|
||||
weaponDefIndex = defindex,
|
||||
StatTrak = statTrak,
|
||||
StatTrakCount = statTrakCount,
|
||||
weaponTeam
|
||||
};
|
||||
|
||||
@@ -24,5 +24,7 @@
|
||||
"wp_skin_menu_skin_title": "Select skin for {lime}{0}{default}",
|
||||
"wp_skin_menu_select": "You have chosen {lime}{0}{default} as your skin",
|
||||
|
||||
"wp_stattrak_action": "You have successfully changed the stattrak setting",
|
||||
|
||||
"None": "None"
|
||||
}
|
||||
@@ -23,6 +23,8 @@
|
||||
"wp_skin_menu_weapon_title": "Ieroču Izvēlne",
|
||||
"wp_skin_menu_skin_title": "Izvēlieties ādu priekš {lime}{0}{default}",
|
||||
"wp_skin_menu_select": "Jūs esat izvēlējies {lime}{0}{default} kā savu ādu",
|
||||
|
||||
|
||||
"wp_stattrak_action": "Jūs veiksmīgi mainījāt stattrak iestatījumu",
|
||||
|
||||
"None": "Nav"
|
||||
}
|
||||
@@ -24,5 +24,7 @@
|
||||
"wp_skin_menu_skin_title": "Wybierz skórkę dla {lime}{0}{default}",
|
||||
"wp_skin_menu_select": "Wybrałeś {lime}{0}{default} jako swoją skórkę",
|
||||
|
||||
"wp_stattrak_action": "Pomyślnie zmieniłeś ustawienie stattraka",
|
||||
|
||||
"None": "Brak"
|
||||
}
|
||||
@@ -24,5 +24,7 @@
|
||||
"wp_skin_menu_skin_title": "Selecione a skin para {lime}{0}{default}",
|
||||
"wp_skin_menu_select": "Você escolheu {lime}{0}{default} como sua skin",
|
||||
|
||||
"wp_stattrak_action": "Você alterou a configuração de stattrak com sucesso",
|
||||
|
||||
"None": "Nenhum"
|
||||
}
|
||||
@@ -24,5 +24,7 @@
|
||||
"wp_skin_menu_skin_title": "Selecione a skin para {lime}{0}{default}",
|
||||
"wp_skin_menu_select": "Escolheu {lime}{0}{default} como a sua skin",
|
||||
|
||||
"wp_stattrak_action": "Alterou com sucesso a configuração do stattrak",
|
||||
|
||||
"None": "Nenhum"
|
||||
}
|
||||
@@ -24,5 +24,7 @@
|
||||
"wp_skin_menu_skin_title": "Выберите скин для {lime}{0}{default}",
|
||||
"wp_skin_menu_select": "Вы выбрали {lime}{0}{default} в качестве вашего скина",
|
||||
|
||||
"wp_stattrak_action": "Вы успешно изменили настройки статтрак",
|
||||
|
||||
"None": "Нет"
|
||||
}
|
||||
@@ -24,5 +24,7 @@
|
||||
"wp_skin_menu_skin_title": "{lime}{0}{default} için cilt seçin",
|
||||
"wp_skin_menu_select": "{lime}{0}{default} olarak cildinizi seçtiniz",
|
||||
|
||||
"wp_stattrak_action": "StatTrak ayarını başarıyla değiştirdiniz",
|
||||
|
||||
"None": "Hiçbiri"
|
||||
}
|
||||
@@ -24,5 +24,7 @@
|
||||
"wp_skin_menu_skin_title": "Виберіть шкіру для {lime}{0}{default}",
|
||||
"wp_skin_menu_select": "Ви обрали {lime}{0}{default} як свою шкіру",
|
||||
|
||||
"wp_stattrak_action": "Ви успішно змінили налаштування статтрака",
|
||||
|
||||
"None": "Немає"
|
||||
}
|
||||
@@ -24,5 +24,7 @@
|
||||
"wp_skin_menu_skin_title": "选择 {lime}{0}{default} 的皮肤",
|
||||
"wp_skin_menu_select": "您选择了 {lime}{0}{default} 作为您的皮肤",
|
||||
|
||||
"wp_stattrak_action": "您已成功更改 StatTrak 设置",
|
||||
|
||||
"None": "无"
|
||||
}
|
||||
|
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 88 KiB |
|
Before Width: | Height: | Size: 93 KiB After Width: | Height: | Size: 93 KiB |
|
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 83 KiB After Width: | Height: | Size: 84 KiB |
|
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 85 KiB |
BIN
website/img/skins/weapon_ak47-113.png
Normal file
|
After Width: | Height: | Size: 94 KiB |
|
Before Width: | Height: | Size: 102 KiB After Width: | Height: | Size: 102 KiB |
|
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 87 KiB |
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 90 KiB |
BIN
website/img/skins/weapon_ak47-1179.png
Normal file
|
After Width: | Height: | Size: 79 KiB |
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 95 KiB After Width: | Height: | Size: 95 KiB |
|
Before Width: | Height: | Size: 82 KiB After Width: | Height: | Size: 82 KiB |
|
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 81 KiB |
BIN
website/img/skins/weapon_ak47-142.png
Normal file
|
After Width: | Height: | Size: 92 KiB |
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 77 KiB |
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 85 KiB |
|
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 86 KiB |
|
Before Width: | Height: | Size: 83 KiB After Width: | Height: | Size: 84 KiB |
|
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 72 KiB |
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 79 KiB |
|
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 85 KiB |
|
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 92 KiB |
|
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 85 KiB |
|
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 90 KiB |
|
Before Width: | Height: | Size: 82 KiB After Width: | Height: | Size: 83 KiB |
|
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 72 KiB |
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 84 KiB |
|
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 79 KiB |
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 85 KiB |
|
Before Width: | Height: | Size: 96 KiB After Width: | Height: | Size: 96 KiB |
|
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 91 KiB |
|
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 87 KiB |
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 90 KiB |
|
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 87 KiB |
|
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 90 KiB |
|
Before Width: | Height: | Size: 98 KiB After Width: | Height: | Size: 98 KiB |
|
Before Width: | Height: | Size: 77 KiB After Width: | Height: | Size: 78 KiB |
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 90 KiB |
|
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 80 KiB |
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 85 KiB |
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 79 KiB |
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 80 KiB |
|
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 90 KiB |
BIN
website/img/skins/weapon_ak47-912.png
Normal file
|
After Width: | Height: | Size: 80 KiB |
|
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 86 KiB |
|
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 89 KiB |
|
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 81 KiB |
|
Before Width: | Height: | Size: 116 KiB After Width: | Height: | Size: 117 KiB |
|
Before Width: | Height: | Size: 107 KiB After Width: | Height: | Size: 108 KiB |
|
Before Width: | Height: | Size: 105 KiB After Width: | Height: | Size: 107 KiB |
|
Before Width: | Height: | Size: 116 KiB After Width: | Height: | Size: 117 KiB |
|
Before Width: | Height: | Size: 110 KiB After Width: | Height: | Size: 112 KiB |
BIN
website/img/skins/weapon_aug-121.png
Normal file
|
After Width: | Height: | Size: 104 KiB |
|
Before Width: | Height: | Size: 122 KiB After Width: | Height: | Size: 123 KiB |
BIN
website/img/skins/weapon_aug-134.png
Normal file
|
After Width: | Height: | Size: 127 KiB |
BIN
website/img/skins/weapon_aug-173.png
Normal file
|
After Width: | Height: | Size: 116 KiB |
|
Before Width: | Height: | Size: 102 KiB After Width: | Height: | Size: 104 KiB |
|
Before Width: | Height: | Size: 103 KiB After Width: | Height: | Size: 105 KiB |
|
Before Width: | Height: | Size: 107 KiB After Width: | Height: | Size: 109 KiB |
|
Before Width: | Height: | Size: 101 KiB After Width: | Height: | Size: 103 KiB |
|
Before Width: | Height: | Size: 101 KiB After Width: | Height: | Size: 103 KiB |
|
Before Width: | Height: | Size: 112 KiB After Width: | Height: | Size: 113 KiB |
|
Before Width: | Height: | Size: 121 KiB After Width: | Height: | Size: 121 KiB |
|
Before Width: | Height: | Size: 114 KiB After Width: | Height: | Size: 116 KiB |
|
Before Width: | Height: | Size: 105 KiB After Width: | Height: | Size: 107 KiB |
|
Before Width: | Height: | Size: 109 KiB After Width: | Height: | Size: 111 KiB |
|
Before Width: | Height: | Size: 118 KiB After Width: | Height: | Size: 119 KiB |
|
Before Width: | Height: | Size: 123 KiB After Width: | Height: | Size: 124 KiB |
|
Before Width: | Height: | Size: 115 KiB After Width: | Height: | Size: 116 KiB |
|
Before Width: | Height: | Size: 114 KiB After Width: | Height: | Size: 115 KiB |
|
Before Width: | Height: | Size: 114 KiB After Width: | Height: | Size: 115 KiB |
|
Before Width: | Height: | Size: 121 KiB After Width: | Height: | Size: 122 KiB |
|
Before Width: | Height: | Size: 113 KiB After Width: | Height: | Size: 115 KiB |
|
Before Width: | Height: | Size: 117 KiB After Width: | Height: | Size: 119 KiB |
|
Before Width: | Height: | Size: 107 KiB After Width: | Height: | Size: 109 KiB |
|
Before Width: | Height: | Size: 105 KiB After Width: | Height: | Size: 106 KiB |
|
Before Width: | Height: | Size: 117 KiB After Width: | Height: | Size: 118 KiB |
|
Before Width: | Height: | Size: 111 KiB After Width: | Height: | Size: 112 KiB |