Compare commits

...

57 Commits

Author SHA1 Message Date
Oliver Zámečník
3cf012e067 Merge 9576b41ace into d1a4d35e20 2024-11-30 11:51:39 +01:00
Dawid Bepierszcz
d1a4d35e20 Merge pull request #357 from originalaidn/missing-music-images
added missing music kit images
2024-11-30 03:35:58 +01:00
originalaidn
415824755e adding latest MVP 2024-11-29 16:05:04 +01:00
originalaidn
5955accadd added missing music kit images 2024-11-23 09:36:44 +01:00
Dawid Bepierszcz
eae091b59a Merge pull request #356 from stefanx111/fix-invariant
fix float parsing to use invariant culture
2024-11-19 17:02:43 +01:00
StefanX
a89593f6a2 fx float parsing to use invariant culture 2024-11-18 21:09:34 +02:00
Dawid Bepierszcz
c418de1e17 Merge pull request #349 from daffyyyy/main
3.1c
2024-10-28 21:15:27 +01:00
Dawid Bepierszcz
82e73e764e Merge branch 'Nereziel:main' into main 2024-10-28 21:13:38 +01:00
Dawid Bepierszcz
ad6c7df357 3.1c
- Fix for custom weapons
2024-10-28 21:13:12 +01:00
Dawid Bepierszcz
a1fa8f37c7 Merge pull request #345 from daffyyyy/main
Website fix
2024-10-24 21:06:49 +02:00
Dawid Bepierszcz
475e91e779 Merge branch 'main' of https://github.com/daffyyyy/cs2-WeaponPaints 2024-10-24 21:00:59 +02:00
Dawid Bepierszcz
a136f5472e Website fix
- Website fix (still missing new features)
2024-10-24 21:00:44 +02:00
Oliver Zámečník
9576b41ace Update README.md 2024-10-24 20:34:51 +02:00
Oliver Zámečník
0decc0405a Update README.md 2024-10-24 20:34:29 +02:00
Dawid Bepierszcz
b5d7f12024 Merge pull request #344 from daffyyyy/main
3.2b
2024-10-24 18:04:32 +02:00
Dawid Bepierszcz
9ec64e346f Merge branch 'Nereziel:main' into main 2024-10-24 18:02:40 +02:00
Dawid Bepierszcz
b4dc20523c Merge branch 'main' of https://github.com/daffyyyy/cs2-WeaponPaints 2024-10-24 18:02:28 +02:00
Dawid Bepierszcz
8891ce815e 3.2b
- Schema for stickers when using custom coords
- Fixed some not found team key
2024-10-24 18:02:25 +02:00
Oneycs
e48308f8af Created a Czech language 2024-10-24 16:33:07 +02:00
Oneycs
2fcf5d7caa Update README.md 2024-10-24 16:32:12 +02:00
Dawid Bepierszcz
ea9963b920 Merge pull request #342 from daffyyyy/main
3.1a
2024-10-24 14:16:22 +02:00
Dawid Bepierszcz
4a5a08aca9 Merge branch 'Nereziel:main' into main 2024-10-24 14:14:32 +02:00
Dawid Bepierszcz
573604a9d9 3.1a
- Possibility to change menu type by config

`MenuType:`
- selectable (each player can change menu type by command css_menus)
- dynamic (center + keys)
- center (center + chat)
- chat
- console
2024-10-24 14:14:10 +02:00
Dawid Bepierszcz
3929a43e46 Merge pull request #336 from daffyyyy/main
3.0c
2024-10-21 21:05:20 +02:00
Dawid Bepierszcz
f7f18b7919 Merge branch 'Nereziel:main' into main 2024-10-21 21:04:08 +02:00
Dawid Bepierszcz
0d110d83c7 3.0c
- Temp fix for knife (one weapon)
- Fix for stattrak saving
2024-10-21 21:01:38 +02:00
Dawid Bepierszcz
db20e2eef9 Merge pull request #334 from daffyyyy/main
GiveSkin fix
2024-10-20 20:47:22 +02:00
Dawid Bepierszcz
536cea96d6 Merge branch 'main' of https://github.com/daffyyyy/cs2-WeaponPaints 2024-10-20 20:45:55 +02:00
Dawid Bepierszcz
84684f4a26 Update WeaponAction.cs 2024-10-20 20:45:17 +02:00
Dawid Bepierszcz
48b9679236 Merge pull request #332 from daffyyyy/main
3.0b
2024-10-20 15:37:41 +02:00
Dawid Bepierszcz
7493ee4c7f Merge branch 'Nereziel:main' into main 2024-10-20 15:35:43 +02:00
Dawid Bepierszcz
027a547052 Merge branch 'main' of https://github.com/daffyyyy/cs2-WeaponPaints 2024-10-20 15:35:22 +02:00
Dawid Bepierszcz
686c225f4f 3.0b
- Fix for fade skins (same seed if 0 by default)
2024-10-20 15:35:20 +02:00
Dawid Bepierszcz
a5397e3831 Merge pull request #331 from daffyyyy/main
3.0a
2024-10-20 15:02:07 +02:00
Dawid Bepierszcz
1b95ddb089 Merge branch 'Nereziel:main' into main 2024-10-20 15:00:54 +02:00
Dawid Bepierszcz
7d4078dc40 Merge branch 'main' of https://github.com/daffyyyy/cs2-WeaponPaints 2024-10-20 15:00:16 +02:00
Dawid Bepierszcz
e3011c51ae 3.0a
- Stattrak fix & command
2024-10-20 15:00:13 +02:00
Dawid Bepierszcz
b99f30deb2 Merge pull request #330 from daffyyyy/main
Sticker position re-added
2024-10-20 09:34:38 +02:00
Dawid Bepierszcz
44c59e6bac Merge branch 'Nereziel:main' into main 2024-10-20 09:34:17 +02:00
Dawid Bepierszcz
845a40c189 Merge branch 'main' of https://github.com/daffyyyy/cs2-WeaponPaints 2024-10-20 09:33:46 +02:00
Dawid Bepierszcz
f93bed46f1 Sticker position re-added
Sticker position re-added
2024-10-20 09:33:35 +02:00
Dawid Bepierszcz
ccee3e52c9 Merge pull request #329 from daffyyyy/main
Music kit fix
2024-10-20 09:24:32 +02:00
Dawid Bepierszcz
7d33693930 Merge branch 'Nereziel:main' into main 2024-10-20 09:23:59 +02:00
Dawid Bepierszcz
7b868611e5 Merge branch 'main' of https://github.com/daffyyyy/cs2-WeaponPaints 2024-10-20 09:23:28 +02:00
Dawid Bepierszcz
b7289dd1e8 Update Events.cs
- Music kits fix
2024-10-20 09:23:23 +02:00
Dawid Bepierszcz
5808255780 Merge pull request #327 from daffyyyy/main
2.9c
2024-10-20 01:58:20 +02:00
Dawid Bepierszcz
7724102d7c Merge branch 'Nereziel:main' into main 2024-10-20 01:57:17 +02:00
Dawid Bepierszcz
a6b9982367 Update Events.cs 2024-10-20 01:56:59 +02:00
Dawid Bepierszcz
bff8a726ce 2.9c
- Fixed music kits
2024-10-20 01:53:21 +02:00
Dawid Bepierszcz
aca68aac1a Merge pull request #325 from daffyyyy/main
2.9b
2024-10-19 22:06:56 +02:00
Dawid Bepierszcz
7e5e47f1d1 Merge branch 'Nereziel:main' into main 2024-10-19 22:05:43 +02:00
Dawid Bepierszcz
59b63646c9 2.9b
- Hotfix for musickit (probably not 100% valid)
- Hotfix for website
2024-10-19 22:05:27 +02:00
Dawid Bepierszcz
1f32b7922b Merge pull request #324 from daffyyyy/main
2.9a
2024-10-19 20:26:29 +02:00
Dawid Bepierszcz
eba4ba08d2 2.9a
- Team based items
2024-10-19 20:24:26 +02:00
Dawid Bepierszcz
18051501f8 Merge pull request #322 from stefanx111/patch-1
remove attributes before initializing skins
2024-10-19 17:00:01 +02:00
StefanX
6ea0336814 .net 8 2024-10-19 15:40:02 +03:00
StefanX
52e8525117 remove attributes before skin initialization 2024-10-19 15:39:00 +03:00
1854 changed files with 1545 additions and 1955 deletions

View File

@@ -30,7 +30,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
- name: Restore
run: dotnet restore
- name: Build
@@ -46,7 +46,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
- name: Restore
run: dotnet restore
- name: Build

View File

@@ -1,7 +1,10 @@
using CounterStrikeSharp.API.Core;
using System.Collections.Concurrent;
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Commands;
using CounterStrikeSharp.API.Modules.Menu;
using CounterStrikeSharp.API.Modules.Timers;
using CounterStrikeSharp.API.Modules.Utils;
using Newtonsoft.Json.Linq;
namespace WeaponPaints;
@@ -104,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) =>
@@ -136,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;
@@ -144,12 +178,17 @@ 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) =>
{
if (!Utility.IsPlayerValid(player)) return;
var playerKnives = GPlayersKnife.GetOrAdd(player.Slot, new ConcurrentDictionary<CsTeam, string>());
var teamsToCheck = player.TeamNum < 2
? new[] { CsTeam.Terrorist, CsTeam.CounterTerrorist }
: [player.Team];
var knifeName = option.Text;
var knifeKey = knivesOnly.FirstOrDefault(x => x.Value == knifeName).Key;
if (string.IsNullOrEmpty(knifeKey)) return;
@@ -172,14 +211,18 @@ public partial class WeaponPaints
Name = player.PlayerName,
IpAddress = player.IpAddress?.Split(":")[0]
};
GPlayersKnife[player.Slot] = knifeKey;
foreach (var team in teamsToCheck)
{
// Attempt to get the existing knives
playerKnives[team] = knifeKey;
}
if (_gBCommandsAllowed && (LifeState_t)player.LifeState == LifeState_t.LIFE_ALIVE)
RefreshWeapons(player);
if (WeaponSync != null)
_ = Task.Run(async () => await WeaponSync.SyncKnifeToDatabase(playerInfo, knifeKey));
_ = Task.Run(async () => await WeaponSync.SyncKnifeToDatabase(playerInfo, knifeKey, teamsToCheck));
};
foreach (var knifePair in knivesOnly)
{
@@ -219,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) =>
@@ -229,20 +272,19 @@ public partial class WeaponPaints
var selectedWeapon = option.Text;
if (!classNamesByWeapon.TryGetValue(selectedWeapon, out var selectedWeaponClassname)) return;
var skinsForSelectedWeapon = SkinsList?.Where(skin =>
var skinsForSelectedWeapon = SkinsList.Where(skin =>
skin.TryGetValue("weapon_name", out var weaponName) &&
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) =>
{
if (!Utility.IsPlayerValid(p)) return;
var steamId = p.SteamID.ToString();
var firstSkin = SkinsList?.FirstOrDefault(skin =>
var firstSkin = SkinsList.FirstOrDefault(skin =>
{
if (skin.TryGetValue("weapon_name", out var weaponName))
{
@@ -259,31 +301,40 @@ public partial class WeaponPaints
!int.TryParse(weaponDefIndexObj.ToString(), out var weaponDefIndex) ||
!int.TryParse(selectedPaintId, out var paintId)) return;
{
if (Config.Additional.ShowSkinImage && SkinsList != null)
if (Config.Additional.ShowSkinImage)
{
var foundSkin = SkinsList.FirstOrDefault(skin =>
((int?)skin?["weapon_defindex"] ?? 0) == weaponDefIndex &&
((int?)skin?["paint"] ?? 0) == paintId &&
skin?["image"] != null
((int?)skin["weapon_defindex"] ?? 0) == weaponDefIndex &&
((int?)skin["paint"] ?? 0) == paintId &&
skin["image"] != null
);
var image = foundSkin?["image"]?.ToString() ?? "";
_playerWeaponImage[p.Slot] = image;
AddTimer(2.0f, () => _playerWeaponImage.Remove(p.Slot), CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
AddTimer(2.0f, () => _playerWeaponImage.Remove(p.Slot), TimerFlags.STOP_ON_MAPCHANGE);
}
p.Print(Localizer["wp_skin_menu_select", selectedSkin]);
var playerSkins = GPlayerWeaponsInfo.GetOrAdd(p.Slot, new ConcurrentDictionary<CsTeam, ConcurrentDictionary<int, WeaponInfo>>());
if (!GPlayerWeaponsInfo[p.Slot].TryGetValue(weaponDefIndex, out var value))
var teamsToCheck = p.TeamNum < 2
? new[] { CsTeam.Terrorist, CsTeam.CounterTerrorist }
: [p.Team];
foreach (var team in teamsToCheck)
{
value = new WeaponInfo();
GPlayerWeaponsInfo[p.Slot][weaponDefIndex] = value;
// Ensure there's an entry for the team in playerSkins
var teamWeapons = playerSkins.GetOrAdd(team, _ => new ConcurrentDictionary<int, WeaponInfo>());
// Attempt to get or add the existing WeaponInfo
var value = teamWeapons.GetOrAdd(weaponDefIndex, _ => new WeaponInfo());
// Update the properties of WeaponInfo
value.Paint = paintId;
value.Wear = 0.01f;
value.Seed = 0;
}
value.Paint = paintId;
value.Wear = 0.01f;
value.Seed = 0;
PlayerInfo playerInfo = new PlayerInfo
var playerInfo = new PlayerInfo
{
UserId = p.UserId,
Slot = p.Slot,
@@ -362,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;
@@ -371,6 +422,11 @@ public partial class WeaponPaints
if (!Utility.IsPlayerValid(player) || player is null) return;
var selectedPaintName = option.Text;
var playerGloves = GPlayersGlove.GetOrAdd(player.Slot, new ConcurrentDictionary<CsTeam, ushort>());
var teamsToCheck = player.TeamNum < 2
? new[] { CsTeam.Terrorist, CsTeam.CounterTerrorist }
: [player.Team];
var selectedGlove = GlovesList.FirstOrDefault(g => g.ContainsKey("paint_name") && g["paint_name"]?.ToString() == selectedPaintName);
var image = selectedGlove?["image"]?.ToString() ?? "";
@@ -397,15 +453,32 @@ public partial class WeaponPaints
if (paint != 0)
{
GPlayersGlove[player.Slot] = (ushort)weaponDefindex;
if (!GPlayerWeaponsInfo[player.Slot].ContainsKey(weaponDefindex))
// Ensure that player weapons info exists for the player
if (!GPlayerWeaponsInfo.ContainsKey(player.Slot))
{
WeaponInfo weaponInfo = new()
GPlayerWeaponsInfo[player.Slot] = new ConcurrentDictionary<CsTeam, ConcurrentDictionary<int, WeaponInfo>>();
}
// Ensure teams are initialized
foreach (var team in teamsToCheck)
{
if (!GPlayerWeaponsInfo[player.Slot].ContainsKey(team))
{
Paint = paint
};
GPlayerWeaponsInfo[player.Slot][weaponDefindex] = weaponInfo;
GPlayerWeaponsInfo[player.Slot][team] = new ConcurrentDictionary<int, WeaponInfo>();
}
// Update the glove for the player in the specified team
playerGloves[team] = (ushort)weaponDefindex;
// Check if the glove information already exists for the player
if (!GPlayerWeaponsInfo[player.Slot][team].ContainsKey(weaponDefindex))
{
WeaponInfo weaponInfo = new()
{
Paint = paint
};
GPlayerWeaponsInfo[player.Slot][team][weaponDefindex] = weaponInfo;
}
}
}
else
@@ -413,28 +486,30 @@ public partial class WeaponPaints
GPlayersGlove.TryRemove(player.Slot, out _);
}
if (!string.IsNullOrEmpty(Localizer["wp_glove_menu_select"]))
{
player.Print(Localizer["wp_glove_menu_select", selectedPaintName]);
}
if (WeaponSync == null) return;
_ = Task.Run(async () =>
{
await WeaponSync.SyncGloveToDatabase(playerInfo, weaponDefindex);
if (!GPlayerWeaponsInfo[playerInfo.Slot].TryGetValue(weaponDefindex, out var value))
// Sync glove to database for all teams
foreach (var team in teamsToCheck)
{
value = new WeaponInfo();
GPlayerWeaponsInfo[playerInfo.Slot][weaponDefindex] = value;
await WeaponSync.SyncGloveToDatabase(playerInfo, (ushort)weaponDefindex, teamsToCheck);
// Check if the weapon info exists for the glove
if (!GPlayerWeaponsInfo[playerInfo.Slot][team].TryGetValue(weaponDefindex, out var value))
{
value = new WeaponInfo();
GPlayerWeaponsInfo[playerInfo.Slot][team][weaponDefindex] = value;
}
// Update weapon info
value.Paint = paint;
value.Wear = 0.00f;
value.Seed = 0;
// Sync weapon paints to database
await WeaponSync.SyncWeaponPaintsToDatabase(playerInfo);
}
value.Paint = paint;
value.Wear = 0.00f;
value.Seed = 0;
await WeaponSync.SyncWeaponPaintsToDatabase(playerInfo);
});
AddTimer(0.1f, () => GivePlayerGloves(player));
@@ -547,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;
@@ -587,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;
@@ -596,6 +671,11 @@ public partial class WeaponPaints
if (!Utility.IsPlayerValid(player) || player is null) return;
var selectedPaintName = option.Text;
var playerMusic = GPlayersMusic.GetOrAdd(player.Slot, new ConcurrentDictionary<CsTeam, ushort>());
var teamsToCheck = player.TeamNum < 2
? new[] { CsTeam.Terrorist, CsTeam.CounterTerrorist }
: [player.Team]; // Corrected array initializer
var selectedMusic = MusicList.FirstOrDefault(g => g.ContainsKey("name") && g["name"]?.ToString() == selectedPaintName);
if (selectedMusic != null)
@@ -607,7 +687,7 @@ public partial class WeaponPaints
if (Config.Additional.ShowSkinImage)
{
_playerWeaponImage[player.Slot] = image;
AddTimer(2.0f, () => _playerWeaponImage.Remove(player.Slot), CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
AddTimer(2.0f, () => _playerWeaponImage.Remove(player.Slot), TimerFlags.STOP_ON_MAPCHANGE);
}
PlayerInfo playerInfo = new PlayerInfo
@@ -619,15 +699,23 @@ public partial class WeaponPaints
Name = player.PlayerName,
IpAddress = player.IpAddress?.Split(":")[0]
};
if (paint != 0)
{
GPlayersMusic[player.Slot] = (ushort)paint;
foreach (var team in teamsToCheck)
{
playerMusic[team] = (ushort)paint;
}
}
else
{
GPlayersMusic[player.Slot] = 0;
foreach (var team in teamsToCheck)
{
playerMusic[team] = 0;
}
}
GivePlayerMusicKit(player);
if (!string.IsNullOrEmpty(Localizer["wp_music_menu_select"]))
{
@@ -638,11 +726,9 @@ public partial class WeaponPaints
{
_ = Task.Run(async () =>
{
await WeaponSync.SyncMusicToDatabase(playerInfo, (ushort)paint);
await WeaponSync.SyncMusicToDatabase(playerInfo, (ushort)paint, teamsToCheck);
});
}
//RefreshGloves(player);
}
else
{
@@ -656,7 +742,12 @@ public partial class WeaponPaints
IpAddress = player.IpAddress?.Split(":")[0]
};
GPlayersMusic[player.Slot] = 0;
foreach (var team in teamsToCheck)
{
playerMusic[team] = 0;
}
GivePlayerMusicKit(player);
if (!string.IsNullOrEmpty(Localizer["wp_music_menu_select"]))
{
@@ -667,7 +758,7 @@ public partial class WeaponPaints
{
_ = Task.Run(async () =>
{
await WeaponSync.SyncMusicToDatabase(playerInfo, 0);
await WeaponSync.SyncMusicToDatabase(playerInfo, 0, teamsToCheck);
});
}
}
@@ -706,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;
@@ -716,6 +807,11 @@ public partial class WeaponPaints
var selectedPaintName = option.Text;
var playerPins = GPlayersPin.GetOrAdd(player.Slot, new ConcurrentDictionary<CsTeam, ushort>());
var teamsToCheck = player.TeamNum < 2
? new[] { CsTeam.Terrorist, CsTeam.CounterTerrorist }
: [player.Team];
var selectedPin = PinsList.FirstOrDefault(g => g.ContainsKey("name") && g["name"]?.ToString() == selectedPaintName);
if (selectedPin != null)
{
@@ -738,14 +834,20 @@ public partial class WeaponPaints
Name = player.PlayerName,
IpAddress = player.IpAddress?.Split(":")[0]
};
if (paint != 0)
{
GPlayersPin[player.Slot] = (ushort)paint;
foreach (var team in teamsToCheck)
{
playerPins[team] = (ushort)paint; // Set pin for each team
}
}
else
{
GPlayersPin[player.Slot] = 0;
foreach (var team in teamsToCheck)
{
playerPins[team] = 0; // Set pin for each team
}
}
if (!string.IsNullOrEmpty(Localizer["wp_pins_menu_select"]))
@@ -759,7 +861,7 @@ public partial class WeaponPaints
{
_ = Task.Run(async () =>
{
await WeaponSync.SyncPinToDatabase(playerInfo, (ushort)paint);
await WeaponSync.SyncPinToDatabase(playerInfo, (ushort)paint, teamsToCheck);
});
}
}
@@ -775,7 +877,10 @@ public partial class WeaponPaints
IpAddress = player.IpAddress?.Split(":")[0]
};
GPlayersPin[player.Slot] = 0;
foreach (var team in teamsToCheck)
{
playerPins[team] = 0; // Set music for each team
}
if (!string.IsNullOrEmpty(Localizer["wp_pins_menu_select"]))
{
@@ -788,7 +893,7 @@ public partial class WeaponPaints
{
_ = Task.Run(async () =>
{
await WeaponSync.SyncPinToDatabase(playerInfo, 0);
await WeaponSync.SyncPinToDatabase(playerInfo, 0, teamsToCheck);
});
}
}

View File

@@ -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";
}
}

104
Events.cs
View File

@@ -9,6 +9,8 @@ namespace WeaponPaints
{
public partial class WeaponPaints
{
private bool _mvpPlayed;
[GameEventHandler]
public HookResult OnClientFullConnect(EventPlayerConnectFull @event, GameEventInfo info)
{
@@ -77,16 +79,17 @@ namespace WeaponPaints
IpAddress = player.IpAddress?.Split(":")[0]
};
if (!GPlayerWeaponsInfo.TryGetValue(player.Slot, out var weaponInfos))
return HookResult.Continue;
if (WeaponSync != null)
_ = Task.Run(async () => await WeaponSync.SyncStatTrakToDatabase(playerInfo, weaponInfos));
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 _);
@@ -107,19 +110,22 @@ namespace WeaponPaints
{
GPlayersPin.TryRemove(player.Slot, out _);
}
_temporaryPlayerWeaponWear.TryRemove(player.Slot, out _);
CommandsCooldown.Remove(player.Slot);
return HookResult.Continue;
}
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)
@@ -145,17 +151,49 @@ namespace WeaponPaints
private HookResult OnRoundEnd(EventRoundEnd @event, GameEventInfo info)
{
_gBCommandsAllowed = false;
return HookResult.Continue;
}
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
{
@@ -166,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;
@@ -223,9 +263,8 @@ namespace WeaponPaints
if (!Config.Additional.ShowSkinImage) return;
foreach (var player in Utilities.GetPlayers().Where(p =>
p is { IsValid: true, PlayerPawn.IsValid: true } &&
(LifeState_t)p.LifeState == LifeState_t.LIFE_ALIVE
&& !p.IsBot && p is { Connected: PlayerConnectedState.PlayerConnected }
p is { IsValid: true, PlayerPawn.IsValid: true, IsBot: false } and
{ Connected: PlayerConnectedState.PlayerConnected }
)
)
{
@@ -239,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);
}
@@ -253,21 +299,23 @@ namespace WeaponPaints
private HookResult OnPlayerDeath(EventPlayerDeath @event, GameEventInfo info)
{
CCSPlayerController? player = @event.Attacker;
CCSPlayerController? victim = @event.Userid;
if (player is null || !player.IsValid)
return HookResult.Continue;
if (!GPlayerWeaponsInfo.TryGetValue(player.Slot, out _)) return HookResult.Continue;
if (victim == null || !victim.IsValid || victim == player)
return HookResult.Continue;
CBasePlayerWeapon? weapon = player.PlayerPawn.Value?.WeaponServices?.ActiveWeapon.Value;
if (weapon == null) return HookResult.Continue;
int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;
if (!GPlayerWeaponsInfo[player.Slot].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;
@@ -288,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);
}
}
}

153
README.md
View File

@@ -1,20 +1,36 @@
# CS2 Weapon Paints
```
## Description
__ __ ___ _ _
/ / /\ \ \___ __ _ _ __ ___ _ __ / _ \__ _(_)_ __ | |_ ___
\ \/ \/ / _ \/ _` | '_ \ / _ \| '_ \ / /_)/ _` | | '_ \| __/ __|
\ /\ / __/ (_| | |_) | (_) | | | / ___/ (_| | | | | | |_\__ \
\/ \/ \___|\__,_| .__/ \___/|_| |_\/ \__,_|_|_| |_|\__|___/
|_|
```
<p align="center">
<a href="https://github.com/Nereziel/cs2-WeaponPaints/releases">📖 Releases</a> •
<a href="https://discord.gg/d9CvaYPSFe">💬 Discord</a>
<br /><br />
</p>
<hr />
## 📝 Description
Unfinished, unoptimized and not fully functional ugly demo weapon paints plugin for **[CSSharp](https://docs.cssharp.dev/docs/guides/getting-started.html)**.
## Created [Discord server](https://discord.gg/d9CvaYPSFe) where you can discuss about plugin.
### Consider to donate instead of buying from unknown sources.
### 💸 Consider to donate instead of buying from unknown sources.
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/E1E2G0P2O) or [![Donate on Steam](https://github.com/Nereziel/cs2-WeaponPaints/assets/32937653/a0d53822-4ca7-4caf-83b4-e1a9b5f8c94e)](https://steamcommunity.com/tradeoffer/new/?partner=41515647&token=gW2W-nXE)
## Features
## Features
- Changes only paint, seed and wear on weapons, knives, gloves and agents
- MySQL based
- Data syncs on player connect
- Added command **`!wp`** to refresh skins ***(with cooldown in seconds can be configured)***
- Added command **`!ws`** to show website
- Added command **`!knife`** to show menu with knives
- Added command **`!stattrak`** to enable stattrak on weapon
- Added command **`!gloves`** to show menu with gloves
- Added command **`!agents`** to show menu with agents
- Added command **`!pins`** to show menu with pins
@@ -29,7 +45,7 @@ Unfinished, unoptimized and not fully functional ugly demo weapon paints plugin
- [MenuManagerCS2](https://github.com/NickFox007/MenuManagerCS2)
- MySQL database
## CS2 Server
## 🗄️ CS2 Server
- Have working CounterStrikeSharp (**with RUNTIME!**)
- Download from Release and copy plugin to plugins
- Run server with plugin, **it will generate config if installed correctly!**
@@ -37,49 +53,72 @@ Unfinished, unoptimized and not fully functional ugly demo weapon paints plugin
- In `addons/counterstrikesharp/configs/`**`core.json`** set **FollowCS2ServerGuidelines** to **`false`**
- Copy from plugins folder gamedata file **`weaponpaints.json`** to folder **`addons/counterstrikesharp/gamedata/`**
## Plugin Configuration
## 🛠️ Plugin Configuration
<details>
<summary>Click to expand</summary>
<code><pre>{
"Version": 4, // Don't touch
"DatabaseHost": "", // MySQL host
"DatabasePort": 3306, // MySQL port
"DatabaseUser": "", // MySQL username
"DatabasePassword": "", // MySQL user password
"DatabaseName": "", // MySQL database name
"CmdRefreshCooldownSeconds": 60, // Cooldown time in refreshing skins (!wp command)
"Prefix": "[WeaponPaints]", // Prefix every chat message
"Website": "example.com/skins", // Website used in WebsiteMessageCommand (!ws command)
"Messages": {
"WebsiteMessageCommand": "Visit {WEBSITE} where you can change skins.", // Information about website where player can change skins (!ws command) Set to empty to disable
"SynchronizeMessageCommand": "Type !wp to synchronize chosen skins.", // Information about skins refreshing (!ws command) Set to empty to disable
"KnifeMessageCommand": "Type !knife to open knife menu.", // Information about knife menu (!ws command) Set to empty to disable
"CooldownRefreshCommand": "You can\u0027t refresh weapon paints right now.", // Cooldown information (!wp command) Set to empty to disable
"SuccessRefreshCommand": "Refreshing weapon paints.", // Information about refreshing skins (!wp command) Set to empty to disable
"ChosenKnifeMenu": "You have chosen {KNIFE} as your knife.", // Information about choosen knife (!knife command) Set to empty to disable
"ChosenSkinMenu": "You have chosen {SKIN} as your skin.", // Information about choosen skin (!skins command) Set to empty to disable
"ChosenKnifeMenuKill": "To correctly apply skin for knife, you need to type !kill.", // Information about suicide after knife selection (!knife command) Set to empty to disable
"KnifeMenuTitle": "Knife Menu.", // Menu title (!knife menu)
"WeaponMenuTitle": "Weapon Menu.", // Menu title (!skins menu)
"SkinMenuTitle": "Select skin for {WEAPON}" // Menu title (!skins menu, after weapon select)
},
"Additional": {
"KnifeEnabled": true, // Enable or disable knife feature
"SkinEnabled": true, // Enable or disable skin feature
"CommandWpEnabled": true, // Enable or disable refreshing command
"CommandKillEnabled": true, // Enable or disable kill command
"CommandKnife": "knife", // Name of knife menu command, u can change to for e.g, knives
"CommandSkin": "ws", // Name of skin information command, u can change to for e.g, skins
"CommandSkinSelection": "skins", // Name of skins menu command, u can change to for e.g, weapons
"CommandRefresh": "wp", // Name of skin refreshing command, u can change to for e.g, refreshskins
"CommandKill": "kill", // Name of kill command, u can change to for e.g, suicide
"GiveRandomKnife": false, // Give random knife to players if they didn't choose
"GiveRandomSkins": false // Give random skins to players if they didn't choose
},
"ConfigVersion": 10, // Don't touch
"SkinsLanguage": "en", // Language
"DatabaseHost": "", // MySQL host
"DatabasePort": 3306, // MySQL Port
"DatabaseUser": "", // MySQL Username
"DatabasePassword": "", // MySQL User password
"DatabaseName": "", // MySQL Database name
"CmdRefreshCooldownSeconds": 3, // Cooldown time in refreshing skins (!wp command)
"Website": "example.com/skins", // Website used in WebsiteMessageCommand (!ws command)
"Additional": {
"KnifeEnabled": true, // If knives are enabled
"GloveEnabled": true, // If gloves are enabled
"MusicEnabled": true, // If music kits are enabled
"AgentEnabled": true, // If agents are enabled
"SkinEnabled": true, // If skins are enabled
"PinsEnabled": true, // If pins are enabled
"CommandWpEnabled": true, // If command !wp is enabled
"CommandKillEnabled": true, // If command !kill is enabled
"CommandKnife": [ // Command for knives
"knife"
],
"CommandMusic": [ // Command for music kits
"music"
],
"CommandPin": [ // Command for pins
"pin",
"pins",
"coin",
"coins"
],
"CommandGlove": [ // Command for gloves
"gloves"
],
"CommandAgent": [ // Command for agents
"agents"
],
"CommandStattrak": [ // Command for stattrak
"stattrak",
"st"
],
"CommandSkin": [ // Command for skins
"ws"
],
"CommandSkinSelection": [ // Command for skin selection
"skins"
],
"CommandRefresh": [ // Command for refreshing your skins
"wp"
],
"CommandKill": [ // Command for death
"kill"
],
"GiveRandomKnife": false, // If it should give you Random Knife
"GiveRandomSkin": false, // If it should give you Random Skin
"ShowSkinImage": true // When you select a skin if it should show skins image
},
"MenuType": "selectable" // Menu type commands. Can be: selectable, dynamic, center, chat, console
}
</pre></code>
</details>
## Web install
## 🖥️ Web install
- Requires PHP >= 7.4 with curl and pdo_mysql ***(Tested on php ver **`8.2.3`** and nginx webserver)***
- **Before using website, make sure the plugin is correctly loaded in cs2 server!** Mysql tables are created by plugin not by website.
- Copy website to web server ***(Folder `img` not needed)***
@@ -87,22 +126,44 @@ Unfinished, unoptimized and not fully functional ugly demo weapon paints plugin
- Fill in database credentials and api key in `class/config.php`
- Visit website and login via steam
## Web Features
## 🧩 Web Features
> [!WARNING]
> We recommend you to use any third-party website for WeaponPaints. Website by us doesn't get updated!
- Basic website
- Steam login/logout
- Change knife, paint, seed and wear
## Troubleshooting
## 🌐 Third-party websites
- **[CSS-Bans](https://github.com/counterstrikesharp-panel/css-bans)**
- **[CS2-WeaponPaints-Website](https://github.com/LielXD/CS2-WeaponPaints-Website)**
- **[cs2-WeaponPaints-website](https://github.com/L1teD/cs2-WeaponPaints-website)** > This webiste is different from the one above!
- **[CS2-WeaponPaints-Web](https://github.com/rogeraabbccdd/CS2-WeaponPaints-Web)**
## 🤔 Troubleshooting
<details>
**Skins are not changing:**
Set FollowCSGOGuidelines to false in cssharps core.jcon config
**Database error table does not exists:**
Plugin is not loaded or configured with mysql credentials. Tables are auto-created by plugin.
**An error occured in Get....FromDatabase:**
If you used WeaponPaints and you update to newer version you could get this error. You need to add this queries to Database:
```
ALTER TABLE wp_player_skins
ADD COLUMN weapon_nametag VARCHAR(128) DEFAULT NULL,
ADD COLUMN weapon_stattrak tinyint(1) NOT NULL,
ADD COLUMN weapon_stattrak_count int(10) NOT NULL,
ADD COLUMN weapon_sticker_0 VARCHAR(128) DEFAULT '0;0;0;0;0;0;0' COMMENT 'id;schema;x;y;wear;scale;rotation',
ADD COLUMN weapon_sticker_1 VARCHAR(128) DEFAULT '0;0;0;0;0;0' COMMENT 'id;schema;x;y;wear;scale;rotation',
ADD COLUMN weapon_sticker_2 VARCHAR(128) DEFAULT '0;0;0;0;0;0' COMMENT 'id;schema;x;y;wear;scale;rotation',
ADD COLUMN weapon_sticker_3 VARCHAR(128) DEFAULT '0;0;0;0;0;0' COMMENT 'id;schema;x;y;wear;scale;rotation',
ADD COLUMN weapon_sticker_4 VARCHAR(128) DEFAULT '0;0;0;0;0;0' COMMENT 'id;schema;x;y;wear;scale;rotation',
ADD COLUMN weapon_keychain VARCHAR(128) DEFAULT '0;0;0;0;0' COMMENT 'id;x;y;z;seed';
```
</details>
### Use this plugin at your own risk! Using this may lead to GSLT ban or something else Valve come with. [Valve Server guidelines](https://blog.counter-strike.net/index.php/server_guidelines/)
## Preview
## Website Preview
![preview](https://github.com/Nereziel/cs2-WeaponPaints/blob/main/website/preview.png?raw=true)

View File

@@ -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;
@@ -24,58 +26,65 @@ namespace WeaponPaints
{
string[] createTableQueries =
[
"""
CREATE TABLE IF NOT EXISTS `wp_player_skins` (
`steamid` varchar(18) NOT NULL,
`weapon_defindex` int(6) NOT NULL,
`weapon_paint_id` int(6) NOT NULL,
`weapon_wear` float NOT NULL DEFAULT 0.000001,
`weapon_seed` int(16) NOT NULL DEFAULT 0,
`weapon_nametag` VARCHAR(128) DEFAULT NULL,
`weapon_stattrak` tinyint(1) NOT NULL,
`weapon_stattrak_count` int(10) NOT NULL,
`weapon_sticker_0` VARCHAR(128) NOT NULL DEFAULT '0;0;0;0;0;0;0' COMMENT 'id;schema;x;y;wear;scale;rotation',
`weapon_sticker_1` VARCHAR(128) NOT NULL DEFAULT '0;0;0;0;0;0;0' COMMENT 'id;schema;x;y;wear;scale;rotation',
`weapon_sticker_2` VARCHAR(128) NOT NULL DEFAULT '0;0;0;0;0;0;0' COMMENT 'id;schema;x;y;wear;scale;rotation',
`weapon_sticker_3` VARCHAR(128) NOT NULL DEFAULT '0;0;0;0;0;0;0' COMMENT 'id;schema;x;y;wear;scale;rotation',
`weapon_sticker_4` VARCHAR(128) NOT NULL DEFAULT '0;0;0;0;0;0;0' COMMENT 'id;schema;x;y;wear;scale;rotation',
`weapon_keychain`VARCHAR(128) NOT NULL DEFAULT '0;0;0;0;0' COMMENT 'id;x;y;z;seed'
) ENGINE=InnoDB
""",
@"CREATE TABLE IF NOT EXISTS `wp_player_knife` (
`steamid` varchar(18) NOT NULL,
`knife` varchar(64) NOT NULL,
UNIQUE (`steamid`)
) ENGINE = InnoDB",
"""
CREATE TABLE IF NOT EXISTS `wp_player_gloves` (
`steamid` varchar(18) NOT NULL,
`weapon_defindex` int(11) NOT NULL,
UNIQUE (`steamid`)
) ENGINE=InnoDB
""",
"""
CREATE TABLE IF NOT EXISTS `wp_player_agents` (
`steamid` varchar(18) NOT NULL,
`agent_ct` varchar(64) DEFAULT NULL,
`agent_t` varchar(64) DEFAULT NULL,
UNIQUE (`steamid`)
) ENGINE=InnoDB
""",
"""
CREATE TABLE IF NOT EXISTS `wp_player_music` (
`steamid` varchar(64) NOT NULL,
`music_id` int(11) NOT NULL,
UNIQUE (`steamid`)
) ENGINE=InnoDB
""",
"""
CREATE TABLE IF NOT EXISTS `wp_player_pins` (
`steamid` varchar(64) NOT NULL,
`id` int(11) NOT NULL,
UNIQUE (`steamid`)
) ENGINE=InnoDB
""",
@"
CREATE TABLE IF NOT EXISTS `wp_player_skins` (
`steamid` varchar(18) NOT NULL,
`weapon_team` int(1) NOT NULL,
`weapon_defindex` int(6) NOT NULL,
`weapon_paint_id` int(6) NOT NULL,
`weapon_wear` float NOT NULL DEFAULT 0.000001,
`weapon_seed` int(16) NOT NULL DEFAULT 0,
`weapon_nametag` VARCHAR(128) DEFAULT NULL,
`weapon_stattrak` tinyint(1) NOT NULL DEFAULT 0,
`weapon_stattrak_count` int(10) NOT NULL DEFAULT 0,
`weapon_sticker_0` VARCHAR(128) NOT NULL DEFAULT '0;0;0;0;0;0;0' COMMENT 'id;schema;x;y;wear;scale;rotation',
`weapon_sticker_1` VARCHAR(128) NOT NULL DEFAULT '0;0;0;0;0;0;0' COMMENT 'id;schema;x;y;wear;scale;rotation',
`weapon_sticker_2` VARCHAR(128) NOT NULL DEFAULT '0;0;0;0;0;0;0' COMMENT 'id;schema;x;y;wear;scale;rotation',
`weapon_sticker_3` VARCHAR(128) NOT NULL DEFAULT '0;0;0;0;0;0;0' COMMENT 'id;schema;x;y;wear;scale;rotation',
`weapon_sticker_4` VARCHAR(128) NOT NULL DEFAULT '0;0;0;0;0;0;0' COMMENT 'id;schema;x;y;wear;scale;rotation',
`weapon_keychain` VARCHAR(128) NOT NULL DEFAULT '0;0;0;0;0' COMMENT 'id;x;y;z;seed',
UNIQUE (`steamid`, `weapon_team`, `weapon_defindex`) -- Add unique constraint here
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;",
@"
CREATE TABLE IF NOT EXISTS `wp_player_knife` (
`steamid` varchar(18) NOT NULL,
`weapon_team` int(1) NOT NULL,
`knife` varchar(64) NOT NULL,
UNIQUE (`steamid`, `weapon_team`) -- Unique constraint
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;",
@"
CREATE TABLE IF NOT EXISTS `wp_player_gloves` (
`steamid` varchar(18) NOT NULL,
`weapon_team` int(1) NOT NULL,
`weapon_defindex` int(11) NOT NULL,
UNIQUE (`steamid`, `weapon_team`) -- Unique constraint
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;",
@"
CREATE TABLE IF NOT EXISTS `wp_player_agents` (
`steamid` varchar(18) NOT NULL,
`agent_ct` varchar(64) DEFAULT NULL,
`agent_t` varchar(64) DEFAULT NULL,
UNIQUE (`steamid`) -- Unique constraint
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;",
@"
CREATE TABLE IF NOT EXISTS `wp_player_music` (
`steamid` varchar(64) NOT NULL,
`weapon_team` int(1) NOT NULL,
`music_id` int(11) NOT NULL,
UNIQUE (`steamid`, `weapon_team`) -- Unique constraint
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;",
@"
CREATE TABLE IF NOT EXISTS `wp_player_pins` (
`steamid` varchar(64) NOT NULL,
`weapon_team` int(1) NOT NULL,
`id` int(11) NOT NULL,
UNIQUE (`steamid`, `weapon_team`) -- Unique constraint
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;"
];
foreach (var query in createTableQueries)
@@ -181,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)

View File

@@ -1 +1 @@
2.8c
3.1c

View File

@@ -3,6 +3,7 @@ using System.Runtime.InteropServices;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Capabilities;
using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;
using CounterStrikeSharp.API.Modules.Utils;
using MenuManager;
using Microsoft.Extensions.Localization;
using Newtonsoft.Json.Linq;
@@ -72,12 +73,12 @@ public partial class WeaponPaints
};
public static IStringLocalizer? _localizer;
internal static readonly ConcurrentDictionary<int, string> GPlayersKnife = new();
internal static readonly ConcurrentDictionary<int, ushort> GPlayersGlove = new();
internal static readonly ConcurrentDictionary<int, ushort> GPlayersMusic = new();
internal static readonly ConcurrentDictionary<int, ushort> GPlayersPin = new();
public static readonly ConcurrentDictionary<int, (string? CT, string? T)> GPlayersAgent = new();
internal static readonly ConcurrentDictionary<int, ConcurrentDictionary<int, WeaponInfo>> GPlayerWeaponsInfo = new();
internal static readonly ConcurrentDictionary<int, ConcurrentDictionary<CsTeam, string>> GPlayersKnife = new();
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();
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 = [];
internal static List<JObject> GlovesList = [];
@@ -91,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"));
@@ -164,4 +165,6 @@ public partial class WeaponPaints
internal static IMenuApi? MenuApi;
private static readonly PluginCapability<IMenuApi> MenuCapability = new("menu:nfcore");
private int _fadeSeed;
}

View File

@@ -20,26 +20,34 @@ namespace WeaponPaints
bool isKnife = weapon.DesignerName.Contains("knife") || weapon.DesignerName.Contains("bayonet");
if (isKnife && !GPlayersKnife.ContainsKey(player.Slot) || isKnife && GPlayersKnife[player.Slot] == "weapon_knife") return;
if (isKnife)
switch (isKnife)
{
var newDefIndex = WeaponDefindex.FirstOrDefault(x => x.Value == GPlayersKnife[player.Slot]);
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;
@@ -47,7 +55,7 @@ namespace WeaponPaints
bool isLegacyModel;
if (_config.Additional.GiveRandomSkin &&
!GPlayerWeaponsInfo[player.Slot].ContainsKey(weaponDefIndex))
!HasChangedPaint(player, weaponDefIndex, out _))
{
// Random skins
weapon.FallbackPaintKit = GetRandomPaint(weaponDefIndex);
@@ -80,22 +88,29 @@ namespace WeaponPaints
return;
}
if (!GPlayerWeaponsInfo[player.Slot].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();
weapon.AttributeManager.Item.NetworkedDynamicAttributes.Attributes.RemoveAll();
weapon.AttributeManager.Item.ItemID = 16384;
weapon.AttributeManager.Item.ItemIDLow = 16384 & 0xFFFFFFFF;
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);
@@ -108,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);
@@ -120,6 +133,7 @@ namespace WeaponPaints
.ToList();
isLegacyModel = skinInfo.Count <= 0 || skinInfo[0].Value<bool>("legacy_model");
UpdatePlayerWeaponMeshGroupMask(player, weapon, isLegacyModel);
}
@@ -127,8 +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(weaponDefIndex, out var weaponInfo) ||
if (!HasChangedPaint(player, weaponDefIndex, out var weaponInfo) || weaponInfo == null ||
weaponInfo.Stickers.Count <= 0) return;
float wearIncrement = 0.001f;
@@ -151,11 +164,8 @@ namespace WeaponPaints
int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;
if (!GPlayerWeaponsInfo.TryGetValue(player.Slot, out var playerWeapons) ||
!playerWeapons.TryGetValue(weaponDefIndex, out var weaponInfo))
{
if (!HasChangedPaint(player ,weaponDefIndex, out var weaponInfo) || weaponInfo == null)
return;
}
foreach (var sticker in weaponInfo.Stickers)
{
@@ -163,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,
@@ -193,9 +201,9 @@ namespace WeaponPaints
int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;
if (!GPlayerWeaponsInfo.TryGetValue(player.Slot, out var playerWeaponsInfo) ||
!playerWeaponsInfo.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,
@@ -218,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)
@@ -260,8 +269,8 @@ namespace WeaponPaints
if (player.Team is CsTeam.None or CsTeam.Spectator)
return;
int playerTeam = player.TeamNum;
var hasKnife = false;
Dictionary<string, List<(int, int)>> weaponsWithAmmo = [];
foreach (var weapon in weapons)
@@ -269,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;
@@ -308,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)
@@ -319,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)
{
@@ -373,11 +390,13 @@ namespace WeaponPaints
if (!player.PawnIsAlive)
return;
if (!GPlayersGlove.TryGetValue(player.Slot, out var gloveInfo) || gloveInfo == 0) return;
if (!GPlayersGlove.TryGetValue(player.Slot, out var gloveInfo) ||
!gloveInfo.TryGetValue(player.Team, out var gloveId) ||
gloveId == 0 ||
!HasChangedPaint(player, gloveId, out var weaponInfo) || weaponInfo == null)
return;
WeaponInfo weaponInfo = GPlayerWeaponsInfo[player.Slot][gloveInfo];
item.ItemDefinitionIndex = gloveInfo;
item.ItemDefinitionIndex = gloveId;
item.ItemIDLow = 16384 & 0xFFFFFFFF;
item.ItemIDHigh = 16384;
@@ -439,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");
}
@@ -469,21 +489,29 @@ namespace WeaponPaints
private static void GivePlayerMusicKit(CCSPlayerController player)
{
if (!GPlayersMusic.TryGetValue(player.Slot, out var value)) return;
if (player.InventoryServices == null) return;
if (player.IsBot) return;
if (!GPlayersMusic.TryGetValue(player.Slot, out var musicInfo) ||
!musicInfo.TryGetValue(player.Team, out var musicId) || musicId == 0) return;
player.InventoryServices.MusicID = value;
Utilities.SetStateChanged(player, "CCSPlayerController", "m_pInventoryServices");
player.MusicKitID = value;
if (player.InventoryServices == null) return;
player.MusicKitID = musicId;
// player.MvpNoMusic = false;
player.InventoryServices.MusicID = musicId;
Utilities.SetStateChanged(player, "CCSPlayerController", "m_iMusicKitID");
// Utilities.SetStateChanged(player, "CCSPlayerController", "m_bMvpNoMusic");
Utilities.SetStateChanged(player, "CCSPlayerController", "m_pInventoryServices");
// player.MusicKitMVPs = musicId;
// Utilities.SetStateChanged(player, "CCSPlayerController", "m_iMusicKitMVPs");
}
private static void GivePlayerPin(CCSPlayerController player)
{
if (!GPlayersPin.TryGetValue(player.Slot, out var pin)) return;
if (!GPlayersPin.TryGetValue(player.Slot, out var pinInfo) ||
!pinInfo.TryGetValue(player.Team, out var pinId)) return;
if (player.InventoryServices == null) return;
player.InventoryServices.Rank[5] = pin > 0 ? (MedalRank_t)pin : MedalRank_t.MEDAL_RANK_NONE;
player.InventoryServices.Rank[5] = pinId > 0 ? (MedalRank_t)pinId : MedalRank_t.MEDAL_RANK_NONE;
Utilities.SetStateChanged(player, "CCSPlayerController", "m_pInventoryServices");
}
@@ -494,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);
}
}
@@ -531,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);

View File

@@ -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();

View File

@@ -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.8c";
public override string ModuleVersion => "3.1c";
public override void Load(bool hotReload)
{
@@ -25,19 +25,20 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
if (hotReload)
{
OnMapStart(string.Empty);
GPlayerWeaponsInfo.Clear();
GPlayersKnife.Clear();
GPlayersGlove.Clear();
GPlayersAgent.Clear();
GPlayersPin.Clear();
GPlayersMusic.Clear();
foreach (var player in Enumerable
.OfType<CCSPlayerController>(Utilities.GetPlayers().TakeWhile(player => WeaponSync != null))
.OfType<CCSPlayerController>(Utilities.GetPlayers().TakeWhile(_ => WeaponSync != null))
.Where(player => player.IsValid &&
!string.IsNullOrEmpty(player.IpAddress) && player is
{ IsBot: false, Connected: PlayerConnectedState.PlayerConnected }))
{
GPlayerWeaponsInfo.TryRemove(player.Slot, out _);
GPlayersKnife.TryRemove(player.Slot, out _);
GPlayersGlove.TryRemove(player.Slot, out _);
GPlayersAgent.TryRemove(player.Slot, out _);
GPlayersPin.TryRemove(player.Slot, out _);
var playerInfo = new PlayerInfo
{
UserId = player.UserId,

File diff suppressed because it is too large Load Diff

30
lang/cs.json Normal file
View File

@@ -0,0 +1,30 @@
{
"wp_prefix": "{lightblue}[WeaponPaints] {default}",
"wp_info_website": "Navštiv {lime}{0}{default} kde si můžeš změnit skiny",
"wp_info_refresh": "Napiš {lime}!wp{default} pro synchronizaci vybraných skinů",
"wp_info_knife": "Napiš {lime}!knife{default} pro otevření menu nožů",
"wp_info_glove": "Napiš {lime}!gloves{default} pro otevření menu rukavic",
"wp_info_agent": "Napiš {lime}!agents{default} pro otevření menu agentů",
"wp_info_music": "Napiš {lime}!music{default} pro otevření menu MVP hudeb",
"wp_info_pin": "Napiš {lime}!pins{default} pro otevření menu odznaků",
"wp_command_cooldown": "{lightred}Skiny nelze nýni obnovit!",
"wp_command_refresh_done": "{lime}Obnovuji skiny",
"wp_knife_menu_select": "Vybral jsi si {lime}{0}{default} jako tvůj nůž",
"wp_knife_menu_kill": "",
"wp_knife_menu_title": "Menu nožů",
"wp_glove_menu_select": "Vybral jsi si {lime}{0}{default} jako tvoje rukavice",
"wp_glove_menu_title": "Menu rukavic",
"wp_agent_menu_select": "Vybral jsi si {lime}{0}{default} jako tvůj agent",
"wp_agent_menu_title": "Menu agentů",
"wp_music_menu_title": "Menu MVP hudeb",
"wp_music_menu_select": "Vybral jsi si {lime}{0}{default} jako tvojí MVP hudbu",
"wp_pins_menu_title": "Menu odznaků",
"wp_pins_menu_select": "Vybral jsi si {lime}{0}{default} jako tvůj odznak",
"wp_skin_menu_weapon_title": "Menu zbraní",
"wp_skin_menu_skin_title": "Vyběr skinů pro {lime}{0}{default}",
"wp_skin_menu_select": "Vybral jsi si {lime}{0}{default} jako tvůj skin",
"wp_stattrak_action": "Úspěšně jste změnil nastavení stattraku",
"None": "Žádné"
}

View File