mirror of
https://github.com/Nereziel/cs2-WeaponPaints.git
synced 2026-03-05 07:00:00 +00:00
Compare commits
18 Commits
build-338
...
9f12d5a81f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f12d5a81f | ||
|
|
3929a43e46 | ||
|
|
f7f18b7919 | ||
|
|
0d110d83c7 | ||
|
|
db20e2eef9 | ||
|
|
536cea96d6 | ||
|
|
84684f4a26 | ||
|
|
48b9679236 | ||
|
|
7493ee4c7f | ||
|
|
027a547052 | ||
|
|
686c225f4f | ||
|
|
c5e219b445 | ||
|
|
5c75616060 | ||
|
|
3ddf8f23ac | ||
|
|
7d185825ff | ||
|
|
48acbd3fa8 | ||
|
|
6842861f55 | ||
|
|
53cadcff40 |
14
Commands.cs
14
Commands.cs
@@ -164,17 +164,9 @@ public partial class WeaponPaints
|
||||
if (!teamWeapons.TryGetValue(weapon.AttributeManager.Item.ItemDefinitionIndex, out var teamWeapon))
|
||||
return;
|
||||
|
||||
if (teamWeapon.StatTrak)
|
||||
{
|
||||
teamWeapon.StatTrak = false;
|
||||
RefreshWeapons(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
teamWeapon.StatTrak = true;
|
||||
RefreshWeapons(player);
|
||||
}
|
||||
|
||||
teamWeapon.StatTrak = !teamWeapon.StatTrak;
|
||||
RefreshWeapons(player);
|
||||
|
||||
if (!string.IsNullOrEmpty(Localizer["wp_stattrak_action"]))
|
||||
{
|
||||
player.Print(Localizer["wp_stattrak_action"]);
|
||||
|
||||
38
Events.cs
38
Events.cs
@@ -2,6 +2,7 @@
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Core.Attributes.Registration;
|
||||
using CounterStrikeSharp.API.Modules.Entities;
|
||||
using CounterStrikeSharp.API.Modules.Entities.Constants;
|
||||
using CounterStrikeSharp.API.Modules.Memory;
|
||||
using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;
|
||||
|
||||
@@ -79,15 +80,17 @@ namespace WeaponPaints
|
||||
IpAddress = player.IpAddress?.Split(":")[0]
|
||||
};
|
||||
|
||||
if (WeaponSync != null)
|
||||
Task.Run(async () =>
|
||||
{
|
||||
_ = Task.Run(async () => await WeaponSync.SyncStatTrakToDatabase(playerInfo));
|
||||
}
|
||||
if (WeaponSync != null)
|
||||
await WeaponSync.SyncStatTrakToDatabase(playerInfo);
|
||||
|
||||
if (Config.Additional.SkinEnabled)
|
||||
{
|
||||
GPlayerWeaponsInfo.TryRemove(player.Slot, out _);
|
||||
}
|
||||
});
|
||||
|
||||
if (Config.Additional.SkinEnabled)
|
||||
{
|
||||
GPlayerWeaponsInfo.TryRemove(player.Slot, out _);
|
||||
}
|
||||
if (Config.Additional.KnifeEnabled)
|
||||
{
|
||||
GPlayersKnife.TryRemove(player.Slot, out _);
|
||||
@@ -121,6 +124,9 @@ namespace WeaponPaints
|
||||
|
||||
if (Database != null)
|
||||
WeaponSync = new WeaponSynchronization(Database, Config);
|
||||
|
||||
_fadeSeed = 0;
|
||||
_nextItemId = MinimumCustomItemId;
|
||||
}
|
||||
|
||||
private HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
|
||||
@@ -199,7 +205,17 @@ namespace WeaponPaints
|
||||
|
||||
var player = GetPlayerFromItemServices(itemServices);
|
||||
if (player != null)
|
||||
{
|
||||
var weaponServices = player.PlayerPawn.Value?.WeaponServices;
|
||||
|
||||
GivePlayerWeaponSkin(player, weapon);
|
||||
|
||||
if (weaponServices is { MyWeapons.Count: 1 })
|
||||
{
|
||||
// player.GiveNamedItem(CsItem.Healthshot);
|
||||
// newWeapon.AddEntityIOEvent("Kill", newWeapon, null, "", 0.1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
@@ -271,9 +287,10 @@ namespace WeaponPaints
|
||||
[GameEventHandler]
|
||||
public HookResult OnItemPickup(EventItemPickup @event, GameEventInfo _)
|
||||
{
|
||||
if (!IsWindows) return HookResult.Continue;
|
||||
|
||||
// if (!IsWindows) return HookResult.Continue;
|
||||
var player = @event.Userid;
|
||||
if (!@event.Item.Contains("knife")) return HookResult.Continue;
|
||||
|
||||
if (player != null && player is { IsValid: true, Connected: PlayerConnectedState.PlayerConnected, PawnIsAlive: true, PlayerPawn.IsValid: true })
|
||||
{
|
||||
GiveOnItemPickup(player);
|
||||
@@ -333,8 +350,7 @@ namespace WeaponPaints
|
||||
if (Config.Additional.ShowSkinImage)
|
||||
RegisterListener<Listeners.OnTick>(OnTick);
|
||||
|
||||
if (!IsWindows)
|
||||
VirtualFunctions.GiveNamedItemFunc.Hook(OnGiveNamedItemPost, HookMode.Post);
|
||||
VirtualFunctions.GiveNamedItemFunc.Hook(OnGiveNamedItemPost, HookMode.Post);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -77,7 +77,8 @@ 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 Dictionary<int, int> GPlayersKnivesPickup = [];
|
||||
internal static readonly ConcurrentDictionary<int, ConcurrentDictionary<CsTeam, ConcurrentDictionary<int, WeaponInfo>>> GPlayerWeaponsInfo = new();
|
||||
internal static List<JObject> SkinsList = [];
|
||||
internal static List<JObject> PinsList = [];
|
||||
@@ -92,7 +93,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 +166,6 @@ public partial class WeaponPaints
|
||||
|
||||
internal static IMenuApi? MenuApi;
|
||||
private static readonly PluginCapability<IMenuApi> MenuCapability = new("menu:nfcore");
|
||||
|
||||
private int _fadeSeed;
|
||||
}
|
||||
@@ -44,7 +44,7 @@ namespace WeaponPaints
|
||||
UpdatePlayerEconItemId(weapon.AttributeManager.Item);
|
||||
|
||||
int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;
|
||||
int fallbackPaintKit = 0;
|
||||
int fallbackPaintKit;
|
||||
|
||||
weapon.AttributeManager.Item.AccountID = (uint)player.SteamID;
|
||||
|
||||
@@ -85,7 +85,11 @@ namespace WeaponPaints
|
||||
return;
|
||||
}
|
||||
|
||||
if (!GPlayerWeaponsInfo[player.Slot][player.Team].TryGetValue(weaponDefIndex, out var value) || value.Paint == 0) return;
|
||||
if (!GPlayerWeaponsInfo.TryGetValue(player.Slot, out var teamInfo) ||
|
||||
!teamInfo.TryGetValue(player.Team, out var teamWeapons) )
|
||||
return;
|
||||
if (!teamWeapons.TryGetValue(weaponDefIndex, out var value))
|
||||
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]}");
|
||||
@@ -98,13 +102,22 @@ 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;
|
||||
|
||||
if (weaponInfo is { Paint: 38, Seed: 0 })
|
||||
{
|
||||
weapon.FallbackSeed = _fadeSeed++;
|
||||
}
|
||||
else
|
||||
{
|
||||
weapon.FallbackSeed = 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 = 7;
|
||||
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);
|
||||
@@ -118,8 +131,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);
|
||||
|
||||
@@ -130,6 +141,7 @@ namespace WeaponPaints
|
||||
.ToList();
|
||||
|
||||
isLegacyModel = skinInfo.Count <= 0 || skinInfo[0].Value<bool>("legacy_model");
|
||||
|
||||
UpdatePlayerWeaponMeshGroupMask(player, weapon, isLegacyModel);
|
||||
}
|
||||
|
||||
@@ -229,6 +241,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)
|
||||
@@ -271,6 +284,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)
|
||||
@@ -278,7 +293,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;
|
||||
@@ -317,6 +332,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)
|
||||
@@ -328,9 +344,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)
|
||||
{
|
||||
@@ -449,6 +472,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");
|
||||
}
|
||||
@@ -512,13 +536,23 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Core.Attributes;
|
||||
using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using MySqlConnector;
|
||||
|
||||
@@ -16,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.0a";
|
||||
public override string ModuleVersion => "3.0c";
|
||||
|
||||
public override void Load(bool hotReload)
|
||||
{
|
||||
@@ -39,6 +40,7 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
||||
!string.IsNullOrEmpty(player.IpAddress) && player is
|
||||
{ IsBot: false, Connected: PlayerConnectedState.PlayerConnected }))
|
||||
{
|
||||
GPlayersKnivesPickup[player.Slot] = 0;
|
||||
var playerInfo = new PlayerInfo
|
||||
{
|
||||
UserId = player.UserId,
|
||||
|
||||
@@ -3,7 +3,6 @@ using MySqlConnector;
|
||||
using System.Collections.Concurrent;
|
||||
using CounterStrikeSharp.API.Modules.Utils;
|
||||
|
||||
|
||||
namespace WeaponPaints;
|
||||
|
||||
internal class WeaponSynchronization
|
||||
|
||||
25
lang/zh-Hans.json
Normal file
25
lang/zh-Hans.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"wp_prefix": "{lightblue}[WeaponPaints] {default}",
|
||||
"wp_info_website": "您可以在浏览器访问 {lime}{0}{default} 来更改您的饰品",
|
||||
"wp_info_refresh": "输入 {lime}!wp{default} 来刷新武器皮肤",
|
||||
"wp_info_knife": "输入 {lime}!knife{default} 来打开选刀菜单",
|
||||
"wp_info_glove": "输入 {lime}!gloves{default} 来打开手套菜单",
|
||||
"wp_info_agent": "输入 {lime}!agents{default} 来打开探员菜单",
|
||||
"wp_info_music": "输入 {lime}!music{default} 来打开音乐盒菜单",
|
||||
"wp_command_cooldown": "{lightred}饰品刷新冷却中!请稍后再试!",
|
||||
"wp_command_refresh_done": "{lime}饰品已刷新",
|
||||
"wp_knife_menu_select": "您的刀已更改为 {lime}{0}{default}",
|
||||
"wp_knife_menu_kill": "",
|
||||
"wp_knife_menu_title": "选刀菜单",
|
||||
"wp_glove_menu_select": "您的手套已更改为 {lime}{0}{default}",
|
||||
"wp_glove_menu_title": "手套菜单",
|
||||
"wp_agent_menu_select": "您的探员已更改为 {lime}{0}{default}",
|
||||
"wp_agent_menu_title": "探员菜单",
|
||||
"wp_music_menu_title": "音乐盒菜单",
|
||||
"wp_music_menu_select": "您的音乐盒已更改为 {lime}{0}{default}",
|
||||
"wp_skin_menu_weapon_title": "武器菜单",
|
||||
"wp_skin_menu_skin_title": "为 {lime}{0}{default} 更换皮肤",
|
||||
"wp_skin_menu_select": "皮肤已更换为 {lime}{0}{default} ",
|
||||
|
||||
"None": "无"
|
||||
}
|
||||
Reference in New Issue
Block a user