Compare commits
183 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
09d9de2a2a | ||
|
|
362084c503 | ||
|
|
8cf175d336 | ||
|
|
84adfa8085 | ||
|
|
286d97d125 | ||
|
|
4d3db5b34f | ||
|
|
85d4e11f26 | ||
|
|
34b086a140 | ||
|
|
ad73e0a85d | ||
|
|
25c205e53d | ||
|
|
1366e141a7 | ||
|
|
5465b982b7 | ||
|
|
ead5ae23a3 | ||
|
|
ff2e7ffd6b | ||
|
|
c9a1fad496 | ||
|
|
0d4d01800d | ||
|
|
19d004c21d | ||
|
|
391efd5cac | ||
|
|
3cf9a67ee2 | ||
|
|
ddb4fb7cba | ||
|
|
e75d48bd0d | ||
|
|
959123344f | ||
|
|
14b0b8153f | ||
|
|
fa48245b34 | ||
|
|
5d5e0f2bd1 | ||
|
|
726e67865c | ||
|
|
868e6c8746 | ||
|
|
a1285bef26 | ||
|
|
b1920f312c | ||
|
|
5e9850bece | ||
|
|
e1802fd0f0 | ||
|
|
267de3c4de | ||
|
|
9f24fbf3ef | ||
|
|
9c23545173 | ||
|
|
40d1088ee6 | ||
|
|
e7f546ed58 | ||
|
|
beab940ebb | ||
|
|
7dc78e7706 | ||
|
|
02208095f0 | ||
|
|
63f4b4c43d | ||
|
|
a6821b85b4 | ||
|
|
a37f4e9e58 | ||
|
|
fb4340cc1d | ||
|
|
bbbf27a751 | ||
|
|
c9d8bb9b5f | ||
|
|
1109c0cf56 | ||
|
|
63869f4c94 | ||
|
|
fa284678e8 | ||
|
|
558f3178f2 | ||
|
|
c5f9cc6429 | ||
|
|
4087d3d016 | ||
|
|
e7919bb468 | ||
|
|
33bd83d0a1 | ||
|
|
73d989c0ce | ||
|
|
f1cecfc73e | ||
|
|
aae6f7e260 | ||
|
|
171d520cc0 | ||
|
|
deac9bab97 | ||
|
|
8a76530302 | ||
|
|
d1cbecaecb | ||
|
|
ebc932e47c | ||
|
|
e258ed8c92 | ||
|
|
e44af369bb | ||
|
|
47055ad6f7 | ||
|
|
d9166253b3 | ||
|
|
4e90506645 | ||
|
|
bd93936fab | ||
|
|
63403dfc8e | ||
|
|
b24a2bd04e | ||
|
|
dbc652a68c | ||
|
|
a59ce8f1a5 | ||
|
|
baaa47d837 | ||
|
|
7dcfea3e17 | ||
|
|
4eab8f0a87 | ||
|
|
236c79c4b9 | ||
|
|
83084452df | ||
|
|
43e7a3183e | ||
|
|
60c592aa54 | ||
|
|
2568f263d9 | ||
|
|
14e285d44f | ||
|
|
97b8840ac4 | ||
|
|
f820c7d251 | ||
|
|
6e5d595c0f | ||
|
|
71d57eb3ad | ||
|
|
620b067991 | ||
|
|
89c425c170 | ||
|
|
c744f2898b | ||
|
|
d04bc0879a | ||
|
|
4417b093dd | ||
|
|
3f8533ab94 | ||
|
|
55905ccc33 | ||
|
|
24fcfa0222 | ||
|
|
cd059c6bfb | ||
|
|
e338bebaec | ||
|
|
efd7f5dbef | ||
|
|
6bd002cdec | ||
|
|
3a1adf8d4a | ||
|
|
7c3fa6469b | ||
|
|
52962518fe | ||
|
|
7e12b89a9e | ||
|
|
ae56b18a3c | ||
|
|
c907911cd1 | ||
|
|
1aa486cd7d | ||
|
|
5e62c7c597 | ||
|
|
819ac6233c | ||
|
|
ed24eb0dfc | ||
|
|
1a9f7ad108 | ||
|
|
6f1a29bb39 | ||
|
|
9e64cdcd43 | ||
|
|
da86756092 | ||
|
|
22880070cd | ||
|
|
208cbe1aef | ||
|
|
c0cf9210dc | ||
|
|
5f61254b4e | ||
|
|
6cd1bb3bf5 | ||
|
|
4f94b831c2 | ||
|
|
969d40b970 | ||
|
|
0cd36a7877 | ||
|
|
a3306b5f8f | ||
|
|
379c2f797c | ||
|
|
7f41607d54 | ||
|
|
fc42190701 | ||
|
|
928c1e1466 | ||
|
|
78649f5dcf | ||
|
|
4e72f10326 | ||
|
|
3ddbf7e11e | ||
|
|
ee770fd8c2 | ||
|
|
72c5df53b5 | ||
|
|
d0ed0f4c0b | ||
|
|
643beaad46 | ||
|
|
6d44e582be | ||
|
|
813a9abcc8 | ||
|
|
b0790729be | ||
|
|
74a6dff114 | ||
|
|
e37f111f1b | ||
|
|
5e6286b667 | ||
|
|
ed4da98a50 | ||
|
|
c825febeac | ||
|
|
1e5c2a439f | ||
|
|
21eccfb6d9 | ||
|
|
a6b193cd13 | ||
|
|
b992433d44 | ||
|
|
06559af230 | ||
|
|
dfe6b200d8 | ||
|
|
3edcb5e52f | ||
|
|
28936e9bb5 | ||
|
|
2772fb59b9 | ||
|
|
0f6bb26ac9 | ||
|
|
be51e4d1e9 | ||
|
|
0d521e0cd3 | ||
|
|
00f920713d | ||
|
|
42d70690eb | ||
|
|
73e3a05270 | ||
|
|
dd9e01db54 | ||
|
|
393281ea12 | ||
|
|
a5787d95e0 | ||
|
|
6a7b15e942 | ||
|
|
8e7a2a2923 | ||
|
|
93e8af07d2 | ||
|
|
7e5485b209 | ||
|
|
414818e314 | ||
|
|
a42e9a37fc | ||
|
|
dcd68aed67 | ||
|
|
7bb97af619 | ||
|
|
cdc58df13c | ||
|
|
fe5cc9a82a | ||
|
|
01542a7dc6 | ||
|
|
a8cf33d404 | ||
|
|
e1f24abd5d | ||
|
|
646050fb72 | ||
|
|
87dadb9c62 | ||
|
|
cf421c5614 | ||
|
|
fc64e1d261 | ||
|
|
1c026c018e | ||
|
|
45fc4a86a5 | ||
|
|
ad105e5cd2 | ||
|
|
f668f56d66 | ||
|
|
de6672507a | ||
|
|
4a410fd0d8 | ||
|
|
bb08e88371 | ||
|
|
2855d4e9ae | ||
|
|
0c05c25e8e | ||
|
|
8335ede7d7 |
14
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# These are supported funding model platforms
|
||||||
|
|
||||||
|
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||||
|
patreon: # Replace with a single Patreon username
|
||||||
|
open_collective: # Replace with a single Open Collective username
|
||||||
|
ko_fi: nereziel # Replace with a single Ko-fi username
|
||||||
|
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||||
|
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||||
|
liberapay: # Replace with a single Liberapay username
|
||||||
|
issuehunt: # Replace with a single IssueHunt username
|
||||||
|
otechie: # Replace with a single Otechie username
|
||||||
|
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
|
||||||
|
polar: # Replace with a single Polar username
|
||||||
|
custom: ['https://steamcommunity.com/tradeoffer/new/?partner=41515647&token=gW2W-nXE'] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||||
10
.github/workflows/build.yml
vendored
@@ -58,12 +58,12 @@ jobs:
|
|||||||
${{ env.OUTPUT_PATH }}/McMaster.NETCore.Plugins.dll \
|
${{ env.OUTPUT_PATH }}/McMaster.NETCore.Plugins.dll \
|
||||||
${{ env.OUTPUT_PATH }}/Microsoft.DotNet.PlatformAbstractions.dll \
|
${{ env.OUTPUT_PATH }}/Microsoft.DotNet.PlatformAbstractions.dll \
|
||||||
${{ env.OUTPUT_PATH }}/Microsoft.Extensions.DependencyModel.dll \
|
${{ env.OUTPUT_PATH }}/Microsoft.Extensions.DependencyModel.dll \
|
||||||
|
- name: Copy skins.json
|
||||||
|
run: cp website/data/skins.json ${{ env.OUTPUT_PATH }}/skins.json
|
||||||
|
- name: Copy gloves.json
|
||||||
|
run: cp website/data/gloves.json ${{ env.OUTPUT_PATH }}/gloves.json
|
||||||
- name: Zip
|
- name: Zip
|
||||||
uses: thedoctor0/zip-release@0.7.5
|
run: zip -r "${{ env.PROJECT_NAME }}.zip" "${{ env.OUTPUT_PATH }}" gamedata/
|
||||||
with:
|
|
||||||
type: 'zip'
|
|
||||||
filename: '${{ env.PROJECT_NAME }}.zip'
|
|
||||||
path: ${{ env.OUTPUT_PATH }}
|
|
||||||
- name: Clean files Website
|
- name: Clean files Website
|
||||||
run: |
|
run: |
|
||||||
rm -rf website/img/
|
rm -rf website/img/
|
||||||
|
|||||||
2
.gitignore
vendored
@@ -1,4 +1,4 @@
|
|||||||
|
|
||||||
.vs/
|
.vs/
|
||||||
bin/
|
bin/
|
||||||
obj/
|
obj/
|
||||||
|
website/getskins.php
|
||||||
|
|||||||
455
Commands.cs
Normal file
@@ -0,0 +1,455 @@
|
|||||||
|
using CounterStrikeSharp.API.Core;
|
||||||
|
using CounterStrikeSharp.API.Modules.Commands;
|
||||||
|
using CounterStrikeSharp.API.Modules.Menu;
|
||||||
|
|
||||||
|
namespace WeaponPaints
|
||||||
|
{
|
||||||
|
public partial class WeaponPaints
|
||||||
|
{
|
||||||
|
private void OnCommandRefresh(CCSPlayerController? player, CommandInfo command)
|
||||||
|
{
|
||||||
|
if (!Config.Additional.CommandWpEnabled || !Config.Additional.SkinEnabled || !g_bCommandsAllowed) return;
|
||||||
|
if (!Utility.IsPlayerValid(player)) return;
|
||||||
|
|
||||||
|
if (player == null || !player.IsValid || player.UserId == null || player.IsBot) return;
|
||||||
|
|
||||||
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
|
{
|
||||||
|
UserId = player.UserId,
|
||||||
|
Slot = player.Slot,
|
||||||
|
Index = (int)player.Index,
|
||||||
|
SteamId = player?.SteamID.ToString(),
|
||||||
|
Name = player?.PlayerName,
|
||||||
|
IpAddress = player?.IpAddress?.Split(":")[0]
|
||||||
|
};
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (player != null && !commandsCooldown.TryGetValue(player.Slot, out DateTime cooldownEndTime) ||
|
||||||
|
player != null && DateTime.UtcNow >= (commandsCooldown.TryGetValue(player.Slot, out cooldownEndTime) ? cooldownEndTime : DateTime.UtcNow))
|
||||||
|
{
|
||||||
|
commandsCooldown[player.Slot] = DateTime.UtcNow.AddSeconds(Config.CmdRefreshCooldownSeconds);
|
||||||
|
|
||||||
|
if (weaponSync != null)
|
||||||
|
{
|
||||||
|
var weaponTasks = new List<Task>();
|
||||||
|
|
||||||
|
weaponTasks.Add(Task.Run(async () =>
|
||||||
|
{
|
||||||
|
await weaponSync.GetWeaponPaintsFromDatabase(playerInfo);
|
||||||
|
}));
|
||||||
|
|
||||||
|
if (Config.Additional.GloveEnabled)
|
||||||
|
{
|
||||||
|
weaponTasks.Add(Task.Run(async () =>
|
||||||
|
{
|
||||||
|
await weaponSync.GetGloveFromDatabase(playerInfo);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Config.Additional.KnifeEnabled)
|
||||||
|
{
|
||||||
|
weaponTasks.Add(Task.Run(async () =>
|
||||||
|
{
|
||||||
|
await weaponSync.GetKnifeFromDatabase(playerInfo);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
Task.WaitAll(weaponTasks.ToArray());
|
||||||
|
|
||||||
|
RefreshGloves(player);
|
||||||
|
RefreshWeapons(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Localizer["wp_command_refresh_done"]))
|
||||||
|
{
|
||||||
|
player!.Print(Localizer["wp_command_refresh_done"]);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(Localizer["wp_command_cooldown"]))
|
||||||
|
{
|
||||||
|
player!.Print(Localizer["wp_command_cooldown"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnCommandWS(CCSPlayerController? player, CommandInfo command)
|
||||||
|
{
|
||||||
|
if (!Config.Additional.SkinEnabled) return;
|
||||||
|
if (!Utility.IsPlayerValid(player)) return;
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Localizer["wp_info_website"]))
|
||||||
|
{
|
||||||
|
player!.Print(Localizer["wp_info_website", Config.Website]);
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(Localizer["wp_info_refresh"]))
|
||||||
|
{
|
||||||
|
player!.Print(Localizer["wp_info_refresh"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Config.Additional.GloveEnabled)
|
||||||
|
if (!string.IsNullOrEmpty(Localizer["wp_info_glove"]))
|
||||||
|
{
|
||||||
|
player!.Print(Localizer["wp_info_glove"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Config.Additional.KnifeEnabled)
|
||||||
|
if (!string.IsNullOrEmpty(Localizer["wp_info_knife"]))
|
||||||
|
{
|
||||||
|
player!.Print(Localizer["wp_info_knife"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RegisterCommands()
|
||||||
|
{
|
||||||
|
AddCommand($"css_{Config.Additional.CommandSkin}", "Skins info", (player, info) =>
|
||||||
|
{
|
||||||
|
if (!Utility.IsPlayerValid(player)) return;
|
||||||
|
OnCommandWS(player, info);
|
||||||
|
});
|
||||||
|
AddCommand($"css_{Config.Additional.CommandRefresh}", "Skins refresh", (player, info) =>
|
||||||
|
{
|
||||||
|
if (!Utility.IsPlayerValid(player)) return;
|
||||||
|
OnCommandRefresh(player, info);
|
||||||
|
});
|
||||||
|
if (Config.Additional.CommandKillEnabled)
|
||||||
|
{
|
||||||
|
AddCommand($"css_{Config.Additional.CommandKill}", "kill yourself", (player, info) =>
|
||||||
|
{
|
||||||
|
if (player == null || !Utility.IsPlayerValid(player) || player.PlayerPawn.Value == null || !player!.PlayerPawn.IsValid) return;
|
||||||
|
|
||||||
|
player.PlayerPawn.Value.CommitSuicide(true, false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetupKnifeMenu()
|
||||||
|
{
|
||||||
|
if (!Config.Additional.KnifeEnabled || !g_bCommandsAllowed) return;
|
||||||
|
|
||||||
|
var knivesOnly = weaponList
|
||||||
|
.Where(pair => pair.Key.StartsWith("weapon_knife") || pair.Key.StartsWith("weapon_bayonet"))
|
||||||
|
.ToDictionary(pair => pair.Key, pair => pair.Value);
|
||||||
|
|
||||||
|
var giveItemMenu = new ChatMenu(Localizer["wp_knife_menu_title"]);
|
||||||
|
var handleGive = (CCSPlayerController player, ChatMenuOption option) =>
|
||||||
|
{
|
||||||
|
if (!Utility.IsPlayerValid(player)) return;
|
||||||
|
|
||||||
|
var knifeName = option.Text;
|
||||||
|
var knifeKey = knivesOnly.FirstOrDefault(x => x.Value == knifeName).Key;
|
||||||
|
if (!string.IsNullOrEmpty(knifeKey))
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(Localizer["wp_knife_menu_select"]))
|
||||||
|
{
|
||||||
|
player!.Print(Localizer["wp_knife_menu_select", knifeName]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Localizer["wp_knife_menu_kill"]) && Config.Additional.CommandKillEnabled)
|
||||||
|
{
|
||||||
|
player!.Print(Localizer["wp_knife_menu_kill"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
|
{
|
||||||
|
UserId = player.UserId,
|
||||||
|
Slot = player.Slot,
|
||||||
|
Index = (int)player.Index,
|
||||||
|
SteamId = player.SteamID.ToString(),
|
||||||
|
Name = player.PlayerName,
|
||||||
|
IpAddress = player.IpAddress?.Split(":")[0]
|
||||||
|
};
|
||||||
|
|
||||||
|
g_playersKnife[player.Slot] = knifeKey;
|
||||||
|
|
||||||
|
if (g_bCommandsAllowed && (LifeState_t)player.LifeState == LifeState_t.LIFE_ALIVE)
|
||||||
|
RefreshWeapons(player);
|
||||||
|
|
||||||
|
if (weaponSync != null)
|
||||||
|
Task.Run(async () => await weaponSync.SyncKnifeToDatabase(playerInfo, knifeKey));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
foreach (var knifePair in knivesOnly)
|
||||||
|
{
|
||||||
|
giveItemMenu.AddMenuOption(knifePair.Value, handleGive);
|
||||||
|
}
|
||||||
|
AddCommand($"css_{Config.Additional.CommandKnife}", "Knife Menu", (player, info) =>
|
||||||
|
{
|
||||||
|
if (!Utility.IsPlayerValid(player) || !g_bCommandsAllowed) return;
|
||||||
|
|
||||||
|
if (player == null || player.UserId == null) return;
|
||||||
|
|
||||||
|
if (player != null && !commandsCooldown.TryGetValue(player.Slot, out DateTime cooldownEndTime) ||
|
||||||
|
player != null && DateTime.UtcNow >= (commandsCooldown.TryGetValue(player.Slot, out cooldownEndTime) ? cooldownEndTime : DateTime.UtcNow))
|
||||||
|
{
|
||||||
|
commandsCooldown[player.Slot] = DateTime.UtcNow.AddSeconds(Config.CmdRefreshCooldownSeconds);
|
||||||
|
giveItemMenu.PostSelectAction = PostSelectAction.Close;
|
||||||
|
MenuManager.OpenChatMenu(player, giveItemMenu);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(Localizer["wp_command_cooldown"]))
|
||||||
|
{
|
||||||
|
player!.Print(Localizer["wp_command_cooldown"]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetupSkinsMenu()
|
||||||
|
{
|
||||||
|
var classNamesByWeapon = weaponList.ToDictionary(kvp => kvp.Value, kvp => kvp.Key);
|
||||||
|
var weaponSelectionMenu = new ChatMenu(Localizer["wp_skin_menu_weapon_title"]);
|
||||||
|
|
||||||
|
// Function to handle skin selection for a specific weapon
|
||||||
|
var handleWeaponSelection = (CCSPlayerController? player, ChatMenuOption option) =>
|
||||||
|
{
|
||||||
|
if (!Utility.IsPlayerValid(player)) return;
|
||||||
|
|
||||||
|
string selectedWeapon = option.Text;
|
||||||
|
if (classNamesByWeapon.TryGetValue(selectedWeapon, out string? selectedWeaponClassname))
|
||||||
|
{
|
||||||
|
if (selectedWeaponClassname == null) return;
|
||||||
|
var skinsForSelectedWeapon = skinsList?.Where(skin =>
|
||||||
|
skin != null &&
|
||||||
|
skin.TryGetValue("weapon_name", out var weaponName) &&
|
||||||
|
weaponName?.ToString() == selectedWeaponClassname
|
||||||
|
)?.ToList();
|
||||||
|
|
||||||
|
var skinSubMenu = new ChatMenu(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;
|
||||||
|
|
||||||
|
string steamId = p.SteamID.ToString();
|
||||||
|
var firstSkin = skinsList?.FirstOrDefault(skin =>
|
||||||
|
{
|
||||||
|
if (skin != null && skin.TryGetValue("weapon_name", out var weaponName))
|
||||||
|
{
|
||||||
|
return weaponName?.ToString() == selectedWeaponClassname;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
string selectedSkin = opt.Text;
|
||||||
|
string selectedPaintID = selectedSkin.Substring(selectedSkin.LastIndexOf('(') + 1).Trim(')');
|
||||||
|
|
||||||
|
if (firstSkin != null &&
|
||||||
|
firstSkin.TryGetValue("weapon_defindex", out var weaponDefIndexObj) &&
|
||||||
|
weaponDefIndexObj != null &&
|
||||||
|
int.TryParse(weaponDefIndexObj.ToString(), out var weaponDefIndex) &&
|
||||||
|
int.TryParse(selectedPaintID, out var paintID))
|
||||||
|
{
|
||||||
|
if (Config.Additional.ShowSkinImage && skinsList != null)
|
||||||
|
{
|
||||||
|
var foundSkin = skinsList.FirstOrDefault(skin =>
|
||||||
|
((int?)skin?["weapon_defindex"] ?? 0) == weaponDefIndex &&
|
||||||
|
((int?)skin?["paint"] ?? 0) == paintID &&
|
||||||
|
skin?["image"] != null
|
||||||
|
);
|
||||||
|
string image = foundSkin?["image"]?.ToString() ?? "";
|
||||||
|
PlayerWeaponImage[p.Slot] = image;
|
||||||
|
AddTimer(2.0f, () => PlayerWeaponImage.Remove(p.Slot), CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
p.Print(Localizer["wp_skin_menu_select", selectedSkin]);
|
||||||
|
|
||||||
|
if (!gPlayerWeaponsInfo[p.Slot].ContainsKey(weaponDefIndex))
|
||||||
|
{
|
||||||
|
gPlayerWeaponsInfo[p.Slot][weaponDefIndex] = new WeaponInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
gPlayerWeaponsInfo[p.Slot][weaponDefIndex].Paint = paintID;
|
||||||
|
gPlayerWeaponsInfo[p.Slot][weaponDefIndex].Wear = 0.01f;
|
||||||
|
gPlayerWeaponsInfo[p.Slot][weaponDefIndex].Seed = 0;
|
||||||
|
|
||||||
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
|
{
|
||||||
|
UserId = p.UserId,
|
||||||
|
Slot = p.Slot,
|
||||||
|
Index = (int)p.Index,
|
||||||
|
SteamId = p.SteamID.ToString(),
|
||||||
|
Name = p.PlayerName,
|
||||||
|
IpAddress = p.IpAddress?.Split(":")[0]
|
||||||
|
};
|
||||||
|
|
||||||
|
if (g_bCommandsAllowed && (LifeState_t)p.LifeState == LifeState_t.LIFE_ALIVE && weaponSync != null)
|
||||||
|
{
|
||||||
|
RefreshWeapons(player);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Task.Run(async () => await weaponSync.SyncWeaponPaintsToDatabase(playerInfo));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Utility.Log($"Error syncing weapon paints: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Add skin options to the submenu for the selected weapon
|
||||||
|
if (skinsForSelectedWeapon != null)
|
||||||
|
{
|
||||||
|
foreach (var skin in skinsForSelectedWeapon.Where(s => s != null))
|
||||||
|
{
|
||||||
|
if (skin.TryGetValue("paint_name", out var paintNameObj) && skin.TryGetValue("paint", out var paintObj))
|
||||||
|
{
|
||||||
|
var paintName = paintNameObj?.ToString();
|
||||||
|
var paint = paintObj?.ToString();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(paintName) && !string.IsNullOrEmpty(paint))
|
||||||
|
{
|
||||||
|
skinSubMenu.AddMenuOption($"{paintName} ({paint})", handleSkinSelection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (player != null && Utility.IsPlayerValid(player))
|
||||||
|
MenuManager.OpenChatMenu(player, skinSubMenu);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Add weapon options to the weapon selection menu
|
||||||
|
foreach (var weaponClass in weaponList.Keys)
|
||||||
|
{
|
||||||
|
string weaponName = weaponList[weaponClass];
|
||||||
|
weaponSelectionMenu.AddMenuOption(weaponName, handleWeaponSelection);
|
||||||
|
}
|
||||||
|
// Command to open the weapon selection menu for players
|
||||||
|
AddCommand($"css_{Config.Additional.CommandSkinSelection}", "Skins selection menu", (player, info) =>
|
||||||
|
{
|
||||||
|
if (!Utility.IsPlayerValid(player)) return;
|
||||||
|
|
||||||
|
if (player == null || player.UserId == null) return;
|
||||||
|
|
||||||
|
if (player != null && !commandsCooldown.TryGetValue(player.Slot, out DateTime cooldownEndTime) ||
|
||||||
|
player != null && DateTime.UtcNow >= (commandsCooldown.TryGetValue(player.Slot, out cooldownEndTime) ? cooldownEndTime : DateTime.UtcNow))
|
||||||
|
{
|
||||||
|
commandsCooldown[player.Slot] = DateTime.UtcNow.AddSeconds(Config.CmdRefreshCooldownSeconds);
|
||||||
|
MenuManager.OpenChatMenu(player, weaponSelectionMenu);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(Localizer["wp_command_cooldown"]))
|
||||||
|
{
|
||||||
|
player!.Print(Localizer["wp_command_cooldown"]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetupGlovesMenu()
|
||||||
|
{
|
||||||
|
var glovesSelectionMenu = new ChatMenu(Localizer["wp_glove_menu_title"]);
|
||||||
|
glovesSelectionMenu.PostSelectAction = PostSelectAction.Close;
|
||||||
|
|
||||||
|
var handleGloveSelection = (CCSPlayerController? player, ChatMenuOption option) =>
|
||||||
|
{
|
||||||
|
if (!Utility.IsPlayerValid(player) || player is null) return;
|
||||||
|
|
||||||
|
string selectedPaintName = option.Text;
|
||||||
|
|
||||||
|
var selectedGlove = glovesList.FirstOrDefault(g => g.ContainsKey("paint_name") && g["paint_name"]?.ToString() == selectedPaintName);
|
||||||
|
if (selectedGlove != null)
|
||||||
|
{
|
||||||
|
if (
|
||||||
|
selectedGlove != null &&
|
||||||
|
selectedGlove.ContainsKey("weapon_defindex") &&
|
||||||
|
selectedGlove.ContainsKey("paint") &&
|
||||||
|
int.TryParse(selectedGlove["weapon_defindex"]?.ToString(), out int weaponDefindex) &&
|
||||||
|
int.TryParse(selectedGlove["paint"]?.ToString(), out int paint)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (Config.Additional.ShowSkinImage)
|
||||||
|
{
|
||||||
|
string image = selectedGlove["image"]?.ToString() ?? "";
|
||||||
|
PlayerWeaponImage[player.Slot] = image;
|
||||||
|
AddTimer(2.0f, () => PlayerWeaponImage.Remove(player.Slot), CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
|
{
|
||||||
|
UserId = player.UserId,
|
||||||
|
Slot = player.Slot,
|
||||||
|
Index = (int)player.Index,
|
||||||
|
SteamId = player.SteamID.ToString(),
|
||||||
|
Name = player.PlayerName,
|
||||||
|
IpAddress = player.IpAddress?.Split(":")[0]
|
||||||
|
};
|
||||||
|
|
||||||
|
if (paint != 0)
|
||||||
|
{
|
||||||
|
g_playersGlove[player.Slot] = (ushort)weaponDefindex;
|
||||||
|
|
||||||
|
if (!gPlayerWeaponsInfo[player.Slot].ContainsKey(weaponDefindex))
|
||||||
|
{
|
||||||
|
WeaponInfo weaponInfo = new();
|
||||||
|
weaponInfo.Paint = paint;
|
||||||
|
gPlayerWeaponsInfo[player.Slot][weaponDefindex] = weaponInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_playersGlove.TryRemove(player.Slot, out _);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Localizer["wp_glove_menu_select"]))
|
||||||
|
{
|
||||||
|
player!.Print(Localizer["wp_glove_menu_select", selectedPaintName]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (weaponSync != null)
|
||||||
|
{
|
||||||
|
Task.Run(async () =>
|
||||||
|
{
|
||||||
|
await weaponSync.SyncGloveToDatabase(playerInfo, weaponDefindex);
|
||||||
|
|
||||||
|
if (!gPlayerWeaponsInfo[playerInfo.Slot].ContainsKey(weaponDefindex))
|
||||||
|
{
|
||||||
|
gPlayerWeaponsInfo[playerInfo.Slot][weaponDefindex] = new WeaponInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
gPlayerWeaponsInfo[playerInfo.Slot][weaponDefindex].Paint = paint;
|
||||||
|
gPlayerWeaponsInfo[playerInfo.Slot][weaponDefindex].Wear = 0.00f;
|
||||||
|
gPlayerWeaponsInfo[playerInfo.Slot][weaponDefindex].Seed = 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
RefreshGloves(player);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// Add weapon options to the weapon selection menu
|
||||||
|
foreach (var gloveObject in glovesList)
|
||||||
|
{
|
||||||
|
string paintName = gloveObject["paint_name"]?.ToString() ?? "";
|
||||||
|
|
||||||
|
if (paintName.Length > 0)
|
||||||
|
glovesSelectionMenu.AddMenuOption(paintName, handleGloveSelection);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Command to open the weapon selection menu for players
|
||||||
|
AddCommand($"css_{Config.Additional.CommandGlove}", "Gloves selection menu", (player, info) =>
|
||||||
|
{
|
||||||
|
if (!Utility.IsPlayerValid(player) || !g_bCommandsAllowed) return;
|
||||||
|
|
||||||
|
if (player == null || player.UserId == null) return;
|
||||||
|
|
||||||
|
if (player != null && !commandsCooldown.TryGetValue(player.Slot, out DateTime cooldownEndTime) ||
|
||||||
|
player != null && DateTime.UtcNow >= (commandsCooldown.TryGetValue(player.Slot, out cooldownEndTime) ? cooldownEndTime : DateTime.UtcNow))
|
||||||
|
{
|
||||||
|
commandsCooldown[player.Slot] = DateTime.UtcNow.AddSeconds(Config.CmdRefreshCooldownSeconds);
|
||||||
|
MenuManager.OpenChatMenu(player, glovesSelectionMenu);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(Localizer["wp_command_cooldown"]))
|
||||||
|
{
|
||||||
|
player!.Print(Localizer["wp_command_cooldown"]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
52
Config.cs
@@ -3,34 +3,14 @@ using System.Text.Json.Serialization;
|
|||||||
|
|
||||||
namespace WeaponPaints
|
namespace WeaponPaints
|
||||||
{
|
{
|
||||||
public class Messages
|
|
||||||
{
|
|
||||||
[JsonPropertyName("WebsiteMessageCommand")]
|
|
||||||
public string WebsiteMessageCommand { get; set; } = "Visit {WEBSITE} where you can change skins.";
|
|
||||||
[JsonPropertyName("SynchronizeMessageCommand")]
|
|
||||||
public string SynchronizeMessageCommand { get; set; } = "Type !wp to synchronize chosen skins.";
|
|
||||||
[JsonPropertyName("KnifeMessageCommand")]
|
|
||||||
public string KnifeMessageCommand { get; set; } = "Type !knife to open knife menu.";
|
|
||||||
[JsonPropertyName("CooldownRefreshCommand")]
|
|
||||||
public string CooldownRefreshCommand { get; set; } = "You can't refresh weapon paints right now.";
|
|
||||||
[JsonPropertyName("SuccessRefreshCommand")]
|
|
||||||
public string SuccessRefreshCommand { get; set; } = "Refreshing weapon paints.";
|
|
||||||
[JsonPropertyName("ChosenKnifeMenu")]
|
|
||||||
public string ChosenKnifeMenu { get; set; } = "You have chosen {KNIFE} as your knife.";
|
|
||||||
[JsonPropertyName("ChosenKnifeMenuKill")]
|
|
||||||
public string ChosenKnifeMenuKill { get; set; } = "To correctly apply skin for knife, you need to type !kill.";
|
|
||||||
[JsonPropertyName("KnifeMenuTitle")]
|
|
||||||
public string KnifeMenuTitle { get; set; } = "Knife Menu.";
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Additional
|
public class Additional
|
||||||
{
|
{
|
||||||
[JsonPropertyName("SkinVisibilityFix")]
|
|
||||||
public bool SkinVisibilityFix { get; set; } = true;
|
|
||||||
|
|
||||||
[JsonPropertyName("KnifeEnabled")]
|
[JsonPropertyName("KnifeEnabled")]
|
||||||
public bool KnifeEnabled { get; set; } = true;
|
public bool KnifeEnabled { get; set; } = true;
|
||||||
|
|
||||||
|
[JsonPropertyName("GloveEnabled")]
|
||||||
|
public bool GloveEnabled { get; set; } = true;
|
||||||
|
|
||||||
[JsonPropertyName("SkinEnabled")]
|
[JsonPropertyName("SkinEnabled")]
|
||||||
public bool SkinEnabled { get; set; } = true;
|
public bool SkinEnabled { get; set; } = true;
|
||||||
|
|
||||||
@@ -43,9 +23,15 @@ namespace WeaponPaints
|
|||||||
[JsonPropertyName("CommandKnife")]
|
[JsonPropertyName("CommandKnife")]
|
||||||
public string CommandKnife { get; set; } = "knife";
|
public string CommandKnife { get; set; } = "knife";
|
||||||
|
|
||||||
|
[JsonPropertyName("CommandGlove")]
|
||||||
|
public string CommandGlove { get; set; } = "gloves";
|
||||||
|
|
||||||
[JsonPropertyName("CommandSkin")]
|
[JsonPropertyName("CommandSkin")]
|
||||||
public string CommandSkin { get; set; } = "ws";
|
public string CommandSkin { get; set; } = "ws";
|
||||||
|
|
||||||
|
[JsonPropertyName("CommandSkinSelection")]
|
||||||
|
public string CommandSkinSelection { get; set; } = "skins";
|
||||||
|
|
||||||
[JsonPropertyName("CommandRefresh")]
|
[JsonPropertyName("CommandRefresh")]
|
||||||
public string CommandRefresh { get; set; } = "wp";
|
public string CommandRefresh { get; set; } = "wp";
|
||||||
|
|
||||||
@@ -54,11 +40,20 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
[JsonPropertyName("GiveRandomKnife")]
|
[JsonPropertyName("GiveRandomKnife")]
|
||||||
public bool GiveRandomKnife { get; set; } = false;
|
public bool GiveRandomKnife { get; set; } = false;
|
||||||
|
|
||||||
|
[JsonPropertyName("GiveRandomSkin")]
|
||||||
|
public bool GiveRandomSkin { get; set; } = false;
|
||||||
|
|
||||||
|
[JsonPropertyName("GiveKnifeAfterRemove")]
|
||||||
|
public bool GiveKnifeAfterRemove { get; set; } = false;
|
||||||
|
|
||||||
|
[JsonPropertyName("ShowSkinImage")]
|
||||||
|
public bool ShowSkinImage { get; set; } = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class WeaponPaintsConfig : BasePluginConfig
|
public class WeaponPaintsConfig : BasePluginConfig
|
||||||
{
|
{
|
||||||
public override int Version { get; set; } = 4;
|
public override int Version { get; set; } = 5;
|
||||||
|
|
||||||
[JsonPropertyName("DatabaseHost")]
|
[JsonPropertyName("DatabaseHost")]
|
||||||
public string DatabaseHost { get; set; } = "";
|
public string DatabaseHost { get; set; } = "";
|
||||||
@@ -75,9 +70,6 @@ namespace WeaponPaints
|
|||||||
[JsonPropertyName("DatabaseName")]
|
[JsonPropertyName("DatabaseName")]
|
||||||
public string DatabaseName { get; set; } = "";
|
public string DatabaseName { get; set; } = "";
|
||||||
|
|
||||||
[JsonPropertyName("GlobalShare")]
|
|
||||||
public bool GlobalShare { get; set; } = false;
|
|
||||||
|
|
||||||
[JsonPropertyName("CmdRefreshCooldownSeconds")]
|
[JsonPropertyName("CmdRefreshCooldownSeconds")]
|
||||||
public int CmdRefreshCooldownSeconds { get; set; } = 60;
|
public int CmdRefreshCooldownSeconds { get; set; } = 60;
|
||||||
|
|
||||||
@@ -87,11 +79,7 @@ namespace WeaponPaints
|
|||||||
[JsonPropertyName("Website")]
|
[JsonPropertyName("Website")]
|
||||||
public string Website { get; set; } = "example.com/skins";
|
public string Website { get; set; } = "example.com/skins";
|
||||||
|
|
||||||
[JsonPropertyName("Messages")]
|
|
||||||
public Messages Messages { get; set; } = new Messages();
|
|
||||||
|
|
||||||
[JsonPropertyName("Additional")]
|
[JsonPropertyName("Additional")]
|
||||||
public Additional Additional { get; set; } = new Additional();
|
public Additional Additional { get; set; } = new Additional();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
28
Database.cs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
using MySqlConnector;
|
||||||
|
|
||||||
|
namespace WeaponPaints
|
||||||
|
{
|
||||||
|
public class Database
|
||||||
|
{
|
||||||
|
private readonly string _dbConnectionString;
|
||||||
|
|
||||||
|
public Database(string dbConnectionString)
|
||||||
|
{
|
||||||
|
_dbConnectionString = dbConnectionString;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<MySqlConnection> GetConnectionAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var connection = new MySqlConnection(_dbConnectionString);
|
||||||
|
await connection.OpenAsync();
|
||||||
|
return connection;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
322
Events.cs
Normal file
@@ -0,0 +1,322 @@
|
|||||||
|
using CounterStrikeSharp.API;
|
||||||
|
using CounterStrikeSharp.API.Core;
|
||||||
|
using CounterStrikeSharp.API.Core.Attributes.Registration;
|
||||||
|
using CounterStrikeSharp.API.Modules.Memory;
|
||||||
|
using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;
|
||||||
|
|
||||||
|
namespace WeaponPaints
|
||||||
|
{
|
||||||
|
public partial class WeaponPaints
|
||||||
|
{
|
||||||
|
[GameEventHandler]
|
||||||
|
public HookResult OnClientFullConnect(EventPlayerConnectFull @event, GameEventInfo info)
|
||||||
|
{
|
||||||
|
CCSPlayerController? player = @event.Userid;
|
||||||
|
|
||||||
|
if (player is null || !player.IsValid || player.IsBot || player.IsHLTV || player.SteamID.ToString().Length != 17 ||
|
||||||
|
weaponSync == null || _database == null) return HookResult.Continue;
|
||||||
|
|
||||||
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
|
{
|
||||||
|
UserId = player.UserId,
|
||||||
|
Slot = player.Slot,
|
||||||
|
Index = (int)player.Index,
|
||||||
|
SteamId = player.SteamID.ToString(),
|
||||||
|
Name = player.PlayerName,
|
||||||
|
IpAddress = player.IpAddress?.Split(":")[0]
|
||||||
|
};
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
List<Task> tasks = new List<Task>();
|
||||||
|
|
||||||
|
if (Config.Additional.SkinEnabled)
|
||||||
|
{
|
||||||
|
tasks.Add(Task.Run(() => weaponSync.GetWeaponPaintsFromDatabase(playerInfo)));
|
||||||
|
}
|
||||||
|
if (Config.Additional.KnifeEnabled)
|
||||||
|
{
|
||||||
|
tasks.Add(Task.Run(() => weaponSync.GetKnifeFromDatabase(playerInfo)));
|
||||||
|
}
|
||||||
|
if (Config.Additional.GloveEnabled)
|
||||||
|
{
|
||||||
|
tasks.Add(Task.Run(() => weaponSync.GetGloveFromDatabase(playerInfo)));
|
||||||
|
}
|
||||||
|
|
||||||
|
Task.WaitAll(tasks.ToArray());
|
||||||
|
}
|
||||||
|
catch (AggregateException ex)
|
||||||
|
{
|
||||||
|
// Handle the exception
|
||||||
|
foreach (var innerException in ex.InnerExceptions)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"An error occurred for player {player}: {innerException.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return HookResult.Continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
[GameEventHandler]
|
||||||
|
public HookResult OnPlayerDisconnect(EventPlayerDisconnect @event, GameEventInfo info)
|
||||||
|
{
|
||||||
|
CCSPlayerController player = @event.Userid;
|
||||||
|
|
||||||
|
if (player is null || !player.IsValid || player.IsBot ||
|
||||||
|
player.IsHLTV || player.SteamID.ToString().Length != 17) return HookResult.Continue;
|
||||||
|
|
||||||
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
|
{
|
||||||
|
UserId = player.UserId,
|
||||||
|
Slot = player.Slot,
|
||||||
|
Index = (int)player.Index,
|
||||||
|
SteamId = player.SteamID.ToString(),
|
||||||
|
Name = player.PlayerName,
|
||||||
|
IpAddress = player.IpAddress?.Split(":")[0]
|
||||||
|
};
|
||||||
|
|
||||||
|
if (Config.Additional.SkinEnabled)
|
||||||
|
{
|
||||||
|
gPlayerWeaponsInfo.TryRemove(player.Slot, out _);
|
||||||
|
}
|
||||||
|
if (Config.Additional.KnifeEnabled)
|
||||||
|
{
|
||||||
|
g_playersKnife.TryRemove(player.Slot, out _);
|
||||||
|
}
|
||||||
|
if (Config.Additional.GloveEnabled)
|
||||||
|
{
|
||||||
|
g_playersGlove.TryRemove(player.Slot, out _);
|
||||||
|
}
|
||||||
|
|
||||||
|
commandsCooldown.Remove(player.Slot);
|
||||||
|
|
||||||
|
return HookResult.Continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GivePlayerWeaponSkin(CCSPlayerController player, CBasePlayerWeapon weapon)
|
||||||
|
{
|
||||||
|
if (!Config.Additional.SkinEnabled) return;
|
||||||
|
|
||||||
|
if (player is null || weapon is null || !weapon.IsValid || !Utility.IsPlayerValid(player)) return;
|
||||||
|
|
||||||
|
if (!gPlayerWeaponsInfo.ContainsKey(player.Slot)) return;
|
||||||
|
|
||||||
|
bool isKnife = weapon.DesignerName.Contains("knife") || weapon.DesignerName.Contains("bayonet");
|
||||||
|
|
||||||
|
if (isKnife && !g_playersKnife.ContainsKey(player.Slot) || isKnife && g_playersKnife[player.Slot] == "weapon_knife") return;
|
||||||
|
|
||||||
|
if (isKnife)
|
||||||
|
{
|
||||||
|
var newDefIndex = WeaponDefindex.FirstOrDefault(x => x.Value == g_playersKnife[player.Slot]);
|
||||||
|
if (newDefIndex.Key == 0) return;
|
||||||
|
|
||||||
|
if (weapon.AttributeManager.Item.ItemDefinitionIndex != newDefIndex.Key)
|
||||||
|
{
|
||||||
|
SubclassChange(weapon, (ushort)newDefIndex.Key);
|
||||||
|
}
|
||||||
|
|
||||||
|
weapon.AttributeManager.Item.ItemDefinitionIndex = (ushort)newDefIndex.Key;
|
||||||
|
weapon.AttributeManager.Item.EntityQuality = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;
|
||||||
|
int fallbackPaintKit = 0;
|
||||||
|
|
||||||
|
if (_config.Additional.GiveRandomSkin &&
|
||||||
|
!gPlayerWeaponsInfo[player.Slot].ContainsKey(weaponDefIndex))
|
||||||
|
{
|
||||||
|
// Random skins
|
||||||
|
weapon.AttributeManager.Item.ItemID = 16384;
|
||||||
|
weapon.AttributeManager.Item.ItemIDLow = 16384 & 0xFFFFFFFF;
|
||||||
|
weapon.AttributeManager.Item.ItemIDHigh = weapon.AttributeManager.Item.ItemIDLow >> 32;
|
||||||
|
weapon.FallbackPaintKit = GetRandomPaint(weaponDefIndex);
|
||||||
|
weapon.FallbackSeed = 0;
|
||||||
|
weapon.FallbackWear = 0.000001f;
|
||||||
|
CAttributeList_SetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, "set item texture prefab", weapon.FallbackPaintKit);
|
||||||
|
|
||||||
|
fallbackPaintKit = weapon.FallbackPaintKit;
|
||||||
|
|
||||||
|
if (fallbackPaintKit == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var foundSkin = skinsList.FirstOrDefault(skin =>
|
||||||
|
((int?)skin?["weapon_defindex"] ?? 0) == weaponDefIndex &&
|
||||||
|
((int?)skin?["paint"] ?? 0) == fallbackPaintKit &&
|
||||||
|
skin?["paint_name"] != null
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!isKnife && weapon.CBodyComponent != null && weapon.CBodyComponent.SceneNode != null)
|
||||||
|
{
|
||||||
|
var skeleton = GetSkeletonInstance(weapon.CBodyComponent.SceneNode);
|
||||||
|
|
||||||
|
int[] newPaints = { 1171, 1170, 1169, 1164, 1162, 1161, 1159, 1175, 1174, 1167, 1165, 1168, 1163, 1160, 1166, 1173 };
|
||||||
|
|
||||||
|
if (newPaints.Contains(fallbackPaintKit))
|
||||||
|
{
|
||||||
|
skeleton.ModelState.MeshGroupMask = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (skeleton.ModelState.MeshGroupMask != 2)
|
||||||
|
{
|
||||||
|
skeleton.ModelState.MeshGroupMask = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var viewModels = GetPlayerViewModels(player);
|
||||||
|
if (viewModels == null || viewModels.Length == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var viewModel = viewModels[0];
|
||||||
|
if (viewModel == null || viewModel.Value == null || viewModel.Value.Weapon == null || viewModel.Value.Weapon.Value == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Utilities.SetStateChanged(viewModel.Value, "CBaseEntity", "m_CBodyComponent");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!gPlayerWeaponsInfo[player.Slot].ContainsKey(weaponDefIndex)) return;
|
||||||
|
WeaponInfo weaponInfo = gPlayerWeaponsInfo[player.Slot][weaponDefIndex];
|
||||||
|
//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.ItemID = 16384;
|
||||||
|
weapon.AttributeManager.Item.ItemIDLow = 16384 & 0xFFFFFFFF;
|
||||||
|
weapon.AttributeManager.Item.ItemIDHigh = weapon.AttributeManager.Item.ItemIDLow >> 32;
|
||||||
|
weapon.FallbackPaintKit = weaponInfo.Paint;
|
||||||
|
weapon.FallbackSeed = weaponInfo.Seed;
|
||||||
|
weapon.FallbackWear = weaponInfo.Wear;
|
||||||
|
CAttributeList_SetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, "set item texture prefab", weapon.FallbackPaintKit);
|
||||||
|
|
||||||
|
fallbackPaintKit = weapon.FallbackPaintKit;
|
||||||
|
|
||||||
|
if (fallbackPaintKit == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var foundSkin1 = skinsList.FirstOrDefault(skin =>
|
||||||
|
((int?)skin?["weapon_defindex"] ?? 0) == weaponDefIndex &&
|
||||||
|
((int?)skin?["paint"] ?? 0) == fallbackPaintKit &&
|
||||||
|
skin?["paint_name"] != null
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!isKnife && weapon.CBodyComponent != null && weapon.CBodyComponent.SceneNode != null)
|
||||||
|
{
|
||||||
|
var skeleton = GetSkeletonInstance(weapon.CBodyComponent.SceneNode);
|
||||||
|
int[] newPaints = { 1171, 1170, 1169, 1164, 1162, 1161, 1159, 1175, 1174, 1167, 1165, 1168, 1163, 1160, 1166, 1173 };
|
||||||
|
if (newPaints.Contains(fallbackPaintKit))
|
||||||
|
{
|
||||||
|
skeleton.ModelState.MeshGroupMask = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (skeleton.ModelState.MeshGroupMask != 2)
|
||||||
|
{
|
||||||
|
skeleton.ModelState.MeshGroupMask = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var viewModels1 = GetPlayerViewModels(player);
|
||||||
|
if (viewModels1 == null || viewModels1.Length == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var viewModel1 = viewModels1[0];
|
||||||
|
if (viewModel1 == null || viewModel1.Value == null || viewModel1.Value.Weapon == null || viewModel1.Value.Weapon.Value == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Utilities.SetStateChanged(viewModel1.Value, "CBaseEntity", "m_CBodyComponent");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnMapStart(string mapName)
|
||||||
|
{
|
||||||
|
if (!Config.Additional.KnifeEnabled && !Config.Additional.SkinEnabled && !Config.Additional.GloveEnabled) return;
|
||||||
|
|
||||||
|
if (_database != null)
|
||||||
|
weaponSync = new WeaponSynchronization(_database, Config);
|
||||||
|
|
||||||
|
|
||||||
|
// needed for now
|
||||||
|
/*
|
||||||
|
AddTimer(2.0f, () =>
|
||||||
|
{
|
||||||
|
|
||||||
|
NativeAPI.IssueServerCommand("mp_t_default_melee \"\"");
|
||||||
|
NativeAPI.IssueServerCommand("mp_ct_default_melee \"\"");
|
||||||
|
|
||||||
|
//NativeAPI.IssueServerCommand("mp_equipment_reset_rounds 0");
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
private HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
|
||||||
|
{
|
||||||
|
CCSPlayerController? player = @event.Userid;
|
||||||
|
|
||||||
|
if (player is null || !player.IsValid || !Config.Additional.KnifeEnabled && !Config.Additional.GloveEnabled)
|
||||||
|
return HookResult.Continue;
|
||||||
|
|
||||||
|
CCSPlayerPawn? pawn = player.PlayerPawn.Value;
|
||||||
|
|
||||||
|
if (pawn == null || !pawn.IsValid)
|
||||||
|
return HookResult.Continue;
|
||||||
|
|
||||||
|
g_knifePickupCount[player.Slot] = 0;
|
||||||
|
|
||||||
|
//if (!PlayerHasKnife(player))
|
||||||
|
//GiveKnifeToPlayer(player);
|
||||||
|
|
||||||
|
Server.NextFrame(() =>
|
||||||
|
{
|
||||||
|
RefreshGloves(player);
|
||||||
|
});
|
||||||
|
|
||||||
|
return HookResult.Continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
private HookResult OnRoundEnd(EventRoundEnd @event, GameEventInfo info)
|
||||||
|
{
|
||||||
|
g_bCommandsAllowed = false;
|
||||||
|
|
||||||
|
return HookResult.Continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
private HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
NativeAPI.IssueServerCommand("mp_t_default_melee \"\"");
|
||||||
|
NativeAPI.IssueServerCommand("mp_ct_default_melee \"\"");
|
||||||
|
NativeAPI.IssueServerCommand("mp_equipment_reset_rounds 0");
|
||||||
|
*/
|
||||||
|
g_bCommandsAllowed = true;
|
||||||
|
|
||||||
|
return HookResult.Continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HookResult OnGiveNamedItemPost(DynamicHook hook)
|
||||||
|
{
|
||||||
|
var itemServices = hook.GetParam<CCSPlayer_ItemServices>(0);
|
||||||
|
var weapon = hook.GetReturn<CBasePlayerWeapon>(0);
|
||||||
|
if (!weapon.DesignerName.Contains("weapon"))
|
||||||
|
return HookResult.Continue;
|
||||||
|
|
||||||
|
var player = GetPlayerFromItemServices(itemServices);
|
||||||
|
if (player != null)
|
||||||
|
GivePlayerWeaponSkin(player, weapon);
|
||||||
|
|
||||||
|
return HookResult.Continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RegisterListeners()
|
||||||
|
{
|
||||||
|
RegisterListener<Listeners.OnMapStart>(OnMapStart);
|
||||||
|
|
||||||
|
RegisterEventHandler<EventPlayerSpawn>(OnPlayerSpawn);
|
||||||
|
RegisterEventHandler<EventRoundStart>(OnRoundStart, HookMode.Pre);
|
||||||
|
RegisterEventHandler<EventRoundEnd>(OnRoundEnd);
|
||||||
|
|
||||||
|
VirtualFunctions.GiveNamedItemFunc.Hook(OnGiveNamedItemPost, HookMode.Post);
|
||||||
|
|
||||||
|
//HookEntityOutput("weapon_knife", "OnPlayerPickup", OnPickup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
15
PlayerExtensions.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using CounterStrikeSharp.API.Core;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace WeaponPaints;
|
||||||
|
|
||||||
|
public static class PlayerExtensions
|
||||||
|
{
|
||||||
|
public static void Print(this CCSPlayerController controller, string message)
|
||||||
|
{
|
||||||
|
if (WeaponPaints._localizer == null) return;
|
||||||
|
StringBuilder _message = new(WeaponPaints._localizer["wp_prefix"]);
|
||||||
|
_message.Append(message);
|
||||||
|
controller.PrintToChat(_message.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
12
PlayerInfo.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
namespace WeaponPaints
|
||||||
|
{
|
||||||
|
public class PlayerInfo
|
||||||
|
{
|
||||||
|
public int Index { get; set; }
|
||||||
|
public int Slot { get; set; }
|
||||||
|
public int? UserId { get; set; }
|
||||||
|
public string? SteamId { get; set; }
|
||||||
|
public string? Name { get; set; }
|
||||||
|
public string? IpAddress { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
84
README.md
@@ -1,38 +1,39 @@
|
|||||||
# CS2 Weapon Paints
|
# CS2 Weapon Paints
|
||||||
|
|
||||||
## Description
|
## Description
|
||||||
Unfinished, unoptimized and not fully functional ugly demo weapon paints plugin for **[CSSharp](https://docs.cssharp.dev/)**.
|
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/EEg6qtNScq) where you can discus about plugin.
|
## 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.
|
||||||
[](https://ko-fi.com/E1E2G0P2O) or [](https://steamcommunity.com/tradeoffer/new/?partner=41515647&token=gW2W-nXE)
|
[](https://ko-fi.com/E1E2G0P2O) or [](https://steamcommunity.com/tradeoffer/new/?partner=41515647&token=gW2W-nXE)
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
- Changes only paint, seed and wear on weapons and knives;
|
- Changes only paint, seed and wear on weapons and knives
|
||||||
- MySQL based or global website at [weaponpaints.fun](https://weaponpaints.fun/), so you dont need MySQL/Website;
|
- MySQL based
|
||||||
- Data sync on player connect;
|
- Data syncs on player connect
|
||||||
- Added command **`!wp`** to refresh skins; ***(with cooldown in second can be configured)***
|
- Added command **`!wp`** to refresh skins ***(with cooldown in seconds can be configured)***
|
||||||
- Added command **`!ws`** to show website;
|
- Added command **`!ws`** to show website
|
||||||
- Added command **`!knife`** to show menu with knives;
|
- Added command **`!knife`** to show menu with knives
|
||||||
- Knife change is now limited to have these cvars empty **`mp_t_default_melee ""`** and **`mp_ct_default_melee ""`**;
|
- Translations support, submit a PR if you want to share your translation
|
||||||
|
|
||||||
## CS2 Server
|
## CS2 Server
|
||||||
- Compile and copy plugin to plugins, [more info here](https://docs.cssharp.dev/guides/hello-world-plugin/);
|
- Have working CounterStrikeSharp (**with RUNTIME!**)
|
||||||
- Setup **`addons/counterstrikesharp/configs/plugins/WeaponPaints/WeaponPaints.json`** set **`GlobalShare`** to **`true`** for global, or include database credentials;
|
- Download from Release and copy plugin to plugins
|
||||||
- in **`addons/counterstrikesharp/configs/core.json`** set **FollowCS2ServerGuidelines** to **`false`**;
|
- Run server with plugin, **it will generate config if installed correctly!**
|
||||||
|
- Edit `addons/counterstrikesharp/configs/`**`plugins/WeaponPaints/WeaponPaints.json`** include database credentials
|
||||||
|
- In `addons/counterstrikesharp/configs/`**`core.json`** set **FollowCS2ServerGuidelines** to **`false`**
|
||||||
|
|
||||||
## Plugin Configuration
|
## Plugin Configuration
|
||||||
<details>
|
<details>
|
||||||
<summary>Spoiler warning</summary>
|
<summary>Click to expand</summary>
|
||||||
<code><pre>{
|
<code><pre>{
|
||||||
"Version": 4, // Don't touch
|
"Version": 4, // Don't touch
|
||||||
"DatabaseHost": "", // MySQL host (required if GlobalShare = false)
|
"DatabaseHost": "", // MySQL host
|
||||||
"DatabasePort": 3306, // MySQL port (required if GlobalShare = false)
|
"DatabasePort": 3306, // MySQL port
|
||||||
"DatabaseUser": "", // MySQL username (required if GlobalShare = false)
|
"DatabaseUser": "", // MySQL username
|
||||||
"DatabasePassword": "", // MySQL user password (required if GlobalShare = false)
|
"DatabasePassword": "", // MySQL user password
|
||||||
"DatabaseName": "", // MySQL database name (required if GlobalShare = false)
|
"DatabaseName": "", // MySQL database name
|
||||||
"GlobalShare": false, // Enable or disable GlobalShare, plugin can work without mysql credentials but with shared website at weaponpaints.fun
|
|
||||||
"CmdRefreshCooldownSeconds": 60, // Cooldown time in refreshing skins (!wp command)
|
"CmdRefreshCooldownSeconds": 60, // Cooldown time in refreshing skins (!wp command)
|
||||||
"Prefix": "[WeaponPaints]", // Prefix every chat message
|
"Prefix": "[WeaponPaints]", // Prefix every chat message
|
||||||
"Website": "example.com/skins", // Website used in WebsiteMessageCommand (!ws command)
|
"Website": "example.com/skins", // Website used in WebsiteMessageCommand (!ws command)
|
||||||
@@ -43,20 +44,24 @@ Unfinished, unoptimized and not fully functional ugly demo weapon paints plugin
|
|||||||
"CooldownRefreshCommand": "You can\u0027t refresh weapon paints right now.", // Cooldown information (!wp 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
|
"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
|
"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
|
"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)
|
"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": {
|
"Additional": {
|
||||||
"SkinVisibilityFix": true, // Enable or disable fix for skin visibility
|
|
||||||
"KnifeEnabled": true, // Enable or disable knife feature
|
"KnifeEnabled": true, // Enable or disable knife feature
|
||||||
"SkinEnabled": true, // Enable or disable skin feature
|
"SkinEnabled": true, // Enable or disable skin feature
|
||||||
"CommandWpEnabled": true, // Enable or disable refreshing command
|
"CommandWpEnabled": true, // Enable or disable refreshing command
|
||||||
"CommandKillEnabled": true, // Enable or disable kill command
|
"CommandKillEnabled": true, // Enable or disable kill command
|
||||||
"CommandKnife": "knife", // Name of knife menu command, u can change to for e.g, knives
|
"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
|
"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
|
"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
|
"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
|
"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": 4 // Don't touch
|
"ConfigVersion": 4 // Don't touch
|
||||||
@@ -64,18 +69,39 @@ Unfinished, unoptimized and not fully functional ugly demo weapon paints plugin
|
|||||||
</details>
|
</details>
|
||||||
|
|
||||||
## Web install
|
## Web install
|
||||||
Disregard if the config is **`GlobalShare = true`**;
|
- Requires PHP >= 7.4 ***(Tested on php ver **`8.2.3`** and nginx webserver)***
|
||||||
- Requires PHP >= 7.4; ***(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)***
|
- Copy website to web server ***(Folder `img` not needed)***
|
||||||
- Get [Steam API Key](https://steamcommunity.com/dev/apikey);
|
- Get [Steam API Key](https://steamcommunity.com/dev/apikey)
|
||||||
- Fill in database credentials and api key in `class/config.php`;
|
- Fill in database credentials and api key in `class/config.php`
|
||||||
- Visit website and login via steam;
|
- Visit website and login via steam
|
||||||
|
|
||||||
|
## Web Features
|
||||||
|
- Basic website
|
||||||
|
- Steam login/logout
|
||||||
|
- Change knife, paint, seed and wear
|
||||||
|
|
||||||
## Known issues
|
## Known issues
|
||||||
- Issue on Windows servers, no knives are given.
|
- Issue on Windows servers, no knives are given.
|
||||||
|
- You can't change knife if it's equpied in cs2 inventory
|
||||||
|
- Can cause incompatibility with plugins/maps which manipulates weapons and knives
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
<details>
|
||||||
|
**Skins are not changing:**
|
||||||
|
Set FollowCSGOGuidelines to false in cssharp’s core.jcon config
|
||||||
|
|
||||||
|
**Database error table does not exists:**
|
||||||
|
Plugin is not loaded or configured with mysql credentials. Tables are auto-created by plugin.
|
||||||
|
|
||||||
|
**Knives are disappearing:**
|
||||||
|
Set in config GiveKnifeAfterRemove to true
|
||||||
|
|
||||||
|
**Knives are not changing for players:**
|
||||||
|
You can't change knife if you have your own equipped
|
||||||
|
</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/)
|
### 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
|
## Preview
|
||||||

|

|
||||||
|
|
||||||
|
|||||||
24
SchemaString.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using CounterStrikeSharp.API;
|
||||||
|
using CounterStrikeSharp.API.Modules.Memory;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace WeaponPaints;
|
||||||
|
|
||||||
|
public class SchemaString<TSchemaClass> : NativeObject where TSchemaClass : NativeObject
|
||||||
|
{
|
||||||
|
internal SchemaString(TSchemaClass instance, string member) : base(Schema.GetSchemaValue<nint>(instance.Handle, typeof(TSchemaClass).Name!, member))
|
||||||
|
{ }
|
||||||
|
|
||||||
|
internal unsafe void Set(string str)
|
||||||
|
{
|
||||||
|
var bytes = Encoding.UTF8.GetBytes(str);
|
||||||
|
|
||||||
|
for (var i = 0; i < bytes.Length; i++)
|
||||||
|
{
|
||||||
|
Unsafe.Write((void*)(Handle.ToInt64() + i), bytes[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Unsafe.Write((void*)(Handle.ToInt64() + bytes.Length), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
231
Utility.cs
Normal file
@@ -0,0 +1,231 @@
|
|||||||
|
using CounterStrikeSharp.API.Core;
|
||||||
|
using CounterStrikeSharp.API.Modules.Utils;
|
||||||
|
using Dapper;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using MySqlConnector;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace WeaponPaints
|
||||||
|
{
|
||||||
|
internal static class Utility
|
||||||
|
{
|
||||||
|
internal static WeaponPaintsConfig? Config { get; set; }
|
||||||
|
|
||||||
|
internal static string BuildDatabaseConnectionString()
|
||||||
|
{
|
||||||
|
if (Config == null) return string.Empty;
|
||||||
|
var builder = new MySqlConnectionStringBuilder
|
||||||
|
{
|
||||||
|
Server = Config.DatabaseHost,
|
||||||
|
UserID = Config.DatabaseUser,
|
||||||
|
Password = Config.DatabasePassword,
|
||||||
|
Database = Config.DatabaseName,
|
||||||
|
Port = (uint)Config.DatabasePort,
|
||||||
|
Pooling = true
|
||||||
|
};
|
||||||
|
|
||||||
|
return builder.ConnectionString;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static async Task CheckDatabaseTables()
|
||||||
|
{
|
||||||
|
if (WeaponPaints._database is null) return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await using var connection = await WeaponPaints._database.GetConnectionAsync();
|
||||||
|
|
||||||
|
await using var transaction = await connection.BeginTransactionAsync();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string[] createTableQueries = new[]
|
||||||
|
{
|
||||||
|
@"CREATE TABLE IF NOT EXISTS `wp_player_skins` (
|
||||||
|
`steamid` varchar(64) 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
|
||||||
|
) ENGINE=InnoDB",
|
||||||
|
@"CREATE TABLE IF NOT EXISTS `wp_player_knife` (
|
||||||
|
`steamid` varchar(64) NOT NULL,
|
||||||
|
`knife` varchar(64) NOT NULL,
|
||||||
|
UNIQUE (`steamid`)
|
||||||
|
) ENGINE = InnoDB",
|
||||||
|
@"CREATE TABLE IF NOT EXISTS `wp_player_gloves` (
|
||||||
|
`steamid` varchar(64) NOT NULL,
|
||||||
|
`weapon_defindex` int(11) NOT NULL,
|
||||||
|
UNIQUE (`steamid`)
|
||||||
|
) ENGINE=InnoDB"
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (var query in createTableQueries)
|
||||||
|
{
|
||||||
|
await connection.ExecuteAsync(query, transaction: transaction);
|
||||||
|
}
|
||||||
|
|
||||||
|
await transaction.CommitAsync();
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
await transaction.RollbackAsync();
|
||||||
|
throw new Exception("[WeaponPaints] Unable to create tables!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw new Exception("[WeaponPaints] Unknown MySQL exception! " + ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static bool IsPlayerValid(CCSPlayerController? player)
|
||||||
|
{
|
||||||
|
if (player is null) return false;
|
||||||
|
|
||||||
|
return (player is not null && player.IsValid && !player.IsBot && !player.IsHLTV && player.UserId.HasValue
|
||||||
|
&& WeaponPaints.weaponSync != null && player.Connected == PlayerConnectedState.PlayerConnected && player.SteamID.ToString().Length == 17);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void LoadSkinsFromFile(string filePath)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string json = File.ReadAllText(filePath);
|
||||||
|
var deserializedSkins = JsonConvert.DeserializeObject<List<JObject>>(json);
|
||||||
|
WeaponPaints.skinsList = deserializedSkins ?? new List<JObject>();
|
||||||
|
}
|
||||||
|
catch (FileNotFoundException)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void LoadGlovesFromFile(string filePath)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string json = File.ReadAllText(filePath);
|
||||||
|
var deserializedSkins = JsonConvert.DeserializeObject<List<JObject>>(json);
|
||||||
|
WeaponPaints.glovesList = deserializedSkins ?? new List<JObject>();
|
||||||
|
}
|
||||||
|
catch (FileNotFoundException)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void Log(string message)
|
||||||
|
{
|
||||||
|
Console.BackgroundColor = ConsoleColor.DarkGray;
|
||||||
|
Console.ForegroundColor = ConsoleColor.Cyan;
|
||||||
|
Console.WriteLine("[WeaponPaints] " + message);
|
||||||
|
Console.ResetColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static string ReplaceTags(string message)
|
||||||
|
{
|
||||||
|
if (message.Contains('{'))
|
||||||
|
{
|
||||||
|
string modifiedValue = message;
|
||||||
|
if (Config != null)
|
||||||
|
{
|
||||||
|
modifiedValue = modifiedValue.Replace("{WEBSITE}", Config.Website);
|
||||||
|
}
|
||||||
|
foreach (FieldInfo field in typeof(ChatColors).GetFields())
|
||||||
|
{
|
||||||
|
string pattern = $"{{{field.Name}}}";
|
||||||
|
if (message.Contains(pattern, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
modifiedValue = modifiedValue.Replace(pattern, field.GetValue(null)!.ToString(), StringComparison.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return modifiedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static async Task CheckVersion(string version, ILogger logger)
|
||||||
|
{
|
||||||
|
using (HttpClient client = new HttpClient())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
HttpResponseMessage response = await client.GetAsync("https://raw.githubusercontent.com/Nereziel/cs2-WeaponPaints/main/VERSION").ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
string remoteVersion = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||||
|
remoteVersion = remoteVersion.Trim();
|
||||||
|
|
||||||
|
int comparisonResult = string.Compare(version, remoteVersion);
|
||||||
|
|
||||||
|
if (comparisonResult < 0)
|
||||||
|
{
|
||||||
|
logger.LogWarning("Plugin is outdated! Check https://github.com/Nereziel/cs2-WeaponPaints");
|
||||||
|
}
|
||||||
|
else if (comparisonResult > 0)
|
||||||
|
{
|
||||||
|
logger.LogInformation("Probably dev version detected");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logger.LogInformation("Plugin is up to date");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logger.LogWarning("Failed to check version");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (HttpRequestException ex)
|
||||||
|
{
|
||||||
|
logger.LogError(ex, "Failed to connect to the version server.");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
logger.LogError(ex, "An error occurred while checking version.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void ShowAd(string moduleVersion)
|
||||||
|
{
|
||||||
|
Console.WriteLine(" ");
|
||||||
|
Console.WriteLine(" _ _ _______ _______ _______ _______ __ _ _______ _______ ___ __ _ _______ _______ ");
|
||||||
|
Console.WriteLine("| | _ | || || _ || || || | | || || _ || | | | | || || |");
|
||||||
|
Console.WriteLine("| || || || ___|| |_| || _ || _ || |_| || _ || |_| || | | |_| ||_ _|| _____|");
|
||||||
|
Console.WriteLine("| || |___ | || |_| || | | || || |_| || || | | | | | | |_____ ");
|
||||||
|
Console.WriteLine("| || ___|| || ___|| |_| || _ || ___|| || | | _ | | | |_____ |");
|
||||||
|
Console.WriteLine("| _ || |___ | _ || | | || | | || | | _ || | | | | | | | _____| |");
|
||||||
|
Console.WriteLine("|__| |__||_______||__| |__||___| |_______||_| |__||___| |__| |__||___| |_| |__| |___| |_______|");
|
||||||
|
Console.WriteLine(" >> Version: " + moduleVersion);
|
||||||
|
Console.WriteLine(" >> GitHub: https://github.com/Nereziel/cs2-WeaponPaints");
|
||||||
|
Console.WriteLine(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*(
|
||||||
|
internal static void TestDatabaseConnection()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new MySqlConnection(BuildDatabaseConnectionString());
|
||||||
|
connection.Open();
|
||||||
|
|
||||||
|
if (connection.State != System.Data.ConnectionState.Open)
|
||||||
|
{
|
||||||
|
throw new Exception("[WeaponPaints] Unable connect to database!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw new Exception("[WeaponPaints] Unknown mysql exception! " + ex.Message);
|
||||||
|
}
|
||||||
|
CheckDatabaseTables();
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
523
WeaponAction.cs
Normal file
@@ -0,0 +1,523 @@
|
|||||||
|
using CounterStrikeSharp.API;
|
||||||
|
using CounterStrikeSharp.API.Core;
|
||||||
|
using CounterStrikeSharp.API.Modules.Memory;
|
||||||
|
using CounterStrikeSharp.API.Modules.Timers;
|
||||||
|
using CounterStrikeSharp.API.Modules.Utils;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace WeaponPaints
|
||||||
|
{
|
||||||
|
public partial class WeaponPaints
|
||||||
|
{
|
||||||
|
internal static void ChangeWeaponAttributes(CBasePlayerWeapon? weapon, CCSPlayerController? player, bool isKnife = false)
|
||||||
|
{
|
||||||
|
if (player is null || weapon is null || !weapon.IsValid || !Utility.IsPlayerValid(player)) return;
|
||||||
|
|
||||||
|
if (!gPlayerWeaponsInfo.ContainsKey(player.Slot)) return;
|
||||||
|
|
||||||
|
if (isKnife && !g_playersKnife.ContainsKey(player.Slot) || isKnife && g_playersKnife[player.Slot] == "weapon_knife") return;
|
||||||
|
|
||||||
|
if (isKnife)
|
||||||
|
{
|
||||||
|
var newDefIndex = WeaponDefindex.FirstOrDefault(x => x.Value == g_playersKnife[player.Slot]);
|
||||||
|
if (newDefIndex.Key == 0) return;
|
||||||
|
|
||||||
|
if (weapon.AttributeManager.Item.ItemDefinitionIndex != newDefIndex.Key)
|
||||||
|
{
|
||||||
|
SubclassChange(weapon, (ushort)newDefIndex.Key);
|
||||||
|
}
|
||||||
|
|
||||||
|
weapon.AttributeManager.Item.ItemDefinitionIndex = (ushort)newDefIndex.Key;
|
||||||
|
weapon.AttributeManager.Item.EntityQuality = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;
|
||||||
|
int fallbackPaintKit = 0;
|
||||||
|
|
||||||
|
if (_config.Additional.GiveRandomSkin &&
|
||||||
|
!gPlayerWeaponsInfo[player.Slot].ContainsKey(weaponDefIndex))
|
||||||
|
{
|
||||||
|
// Random skins
|
||||||
|
weapon.AttributeManager.Item.ItemID = 16384;
|
||||||
|
weapon.AttributeManager.Item.ItemIDLow = 16384 & 0xFFFFFFFF;
|
||||||
|
weapon.AttributeManager.Item.ItemIDHigh = weapon.AttributeManager.Item.ItemIDLow >> 32;
|
||||||
|
weapon.FallbackPaintKit = GetRandomPaint(weaponDefIndex);
|
||||||
|
weapon.FallbackSeed = 0;
|
||||||
|
weapon.FallbackWear = 0.000001f;
|
||||||
|
CAttributeList_SetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, "set item texture prefab", weapon.FallbackPaintKit);
|
||||||
|
|
||||||
|
fallbackPaintKit = weapon.FallbackPaintKit;
|
||||||
|
|
||||||
|
if (fallbackPaintKit == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var foundSkin = skinsList.FirstOrDefault(skin =>
|
||||||
|
((int?)skin?["weapon_defindex"] ?? 0) == weaponDefIndex &&
|
||||||
|
((int?)skin?["paint"] ?? 0) == fallbackPaintKit &&
|
||||||
|
skin?["paint_name"] != null
|
||||||
|
);
|
||||||
|
/*
|
||||||
|
string skinName = foundSkin?["paint_name"]?.ToString() ?? "";
|
||||||
|
if (!string.IsNullOrEmpty(skinName))
|
||||||
|
new SchemaString<CEconItemView>(weapon.AttributeManager.Item, "m_szCustomName").Set(skinName);
|
||||||
|
*/
|
||||||
|
if (!isKnife && weapon.CBodyComponent != null && weapon.CBodyComponent.SceneNode != null)
|
||||||
|
{
|
||||||
|
var skeleton = GetSkeletonInstance(weapon.CBodyComponent.SceneNode);
|
||||||
|
|
||||||
|
int[] newPaints = { 1171, 1170, 1169, 1164, 1162, 1161, 1159, 1175, 1174, 1167, 1165, 1168, 1163, 1160, 1166, 1173 };
|
||||||
|
|
||||||
|
if (newPaints.Contains(fallbackPaintKit))
|
||||||
|
{
|
||||||
|
skeleton.ModelState.MeshGroupMask = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (skeleton.ModelState.MeshGroupMask != 2)
|
||||||
|
{
|
||||||
|
skeleton.ModelState.MeshGroupMask = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var viewModels = GetPlayerViewModels(player);
|
||||||
|
if (viewModels == null || viewModels.Length == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var viewModel = viewModels[0];
|
||||||
|
if (viewModel == null || viewModel.Value == null || viewModel.Value.Weapon == null || viewModel.Value.Weapon.Value == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Utilities.SetStateChanged(viewModel.Value, "CBaseEntity", "m_CBodyComponent");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!gPlayerWeaponsInfo[player.Slot].ContainsKey(weaponDefIndex)) return;
|
||||||
|
WeaponInfo weaponInfo = gPlayerWeaponsInfo[player.Slot][weaponDefIndex];
|
||||||
|
//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.ItemID = 16384;
|
||||||
|
weapon.AttributeManager.Item.ItemIDLow = 16384 & 0xFFFFFFFF;
|
||||||
|
weapon.AttributeManager.Item.ItemIDHigh = weapon.AttributeManager.Item.ItemIDLow >> 32;
|
||||||
|
weapon.FallbackPaintKit = weaponInfo.Paint;
|
||||||
|
weapon.FallbackSeed = weaponInfo.Seed;
|
||||||
|
weapon.FallbackWear = weaponInfo.Wear;
|
||||||
|
CAttributeList_SetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, "set item texture prefab", weapon.FallbackPaintKit);
|
||||||
|
|
||||||
|
fallbackPaintKit = weapon.FallbackPaintKit;
|
||||||
|
|
||||||
|
if (fallbackPaintKit == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var foundSkin1 = skinsList.FirstOrDefault(skin =>
|
||||||
|
((int?)skin?["weapon_defindex"] ?? 0) == weaponDefIndex &&
|
||||||
|
((int?)skin?["paint"] ?? 0) == fallbackPaintKit &&
|
||||||
|
skin?["paint_name"] != null
|
||||||
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
var skinName1 = foundSkin1?["paint_name"]?.ToString() ?? "";
|
||||||
|
if (!string.IsNullOrEmpty(skinName1))
|
||||||
|
new SchemaString<CEconItemView>(weapon.AttributeManager.Item, "m_szCustomName").Set(skinName1);
|
||||||
|
*/
|
||||||
|
if (!isKnife && weapon.CBodyComponent != null && weapon.CBodyComponent.SceneNode != null)
|
||||||
|
{
|
||||||
|
var skeleton = GetSkeletonInstance(weapon.CBodyComponent.SceneNode);
|
||||||
|
int[] newPaints = { 1171, 1170, 1169, 1164, 1162, 1161, 1159, 1175, 1174, 1167, 1165, 1168, 1163, 1160, 1166, 1173 };
|
||||||
|
if (newPaints.Contains(fallbackPaintKit))
|
||||||
|
{
|
||||||
|
skeleton.ModelState.MeshGroupMask = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (skeleton.ModelState.MeshGroupMask != 2)
|
||||||
|
{
|
||||||
|
skeleton.ModelState.MeshGroupMask = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var viewModels1 = GetPlayerViewModels(player);
|
||||||
|
if (viewModels1 == null || viewModels1.Length == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var viewModel1 = viewModels1[0];
|
||||||
|
if (viewModel1 == null || viewModel1.Value == null || viewModel1.Value.Weapon == null || viewModel1.Value.Weapon.Value == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Utilities.SetStateChanged(viewModel1.Value, "CBaseEntity", "m_CBodyComponent");
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void GiveKnifeToPlayer(CCSPlayerController? player)
|
||||||
|
{
|
||||||
|
if (!_config.Additional.KnifeEnabled || player == null || !player.IsValid) return;
|
||||||
|
|
||||||
|
if (PlayerHasKnife(player)) return;
|
||||||
|
|
||||||
|
string knifeToGive;
|
||||||
|
if (g_playersKnife.TryGetValue(player.Slot, out var knife))
|
||||||
|
{
|
||||||
|
knifeToGive = knife;
|
||||||
|
}
|
||||||
|
else if (_config.Additional.GiveRandomKnife)
|
||||||
|
{
|
||||||
|
var knifeTypes = weaponList.Where(pair => pair.Key.StartsWith("weapon_knife") || pair.Key.StartsWith("weapon_bayonet")).ToList();
|
||||||
|
|
||||||
|
if (knifeTypes.Count == 0)
|
||||||
|
{
|
||||||
|
Utility.Log("No valid knife types found.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Random random = new();
|
||||||
|
int index = random.Next(knifeTypes.Count);
|
||||||
|
knifeToGive = knifeTypes[index].Key;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
knifeToGive = (CsTeam)player.TeamNum == CsTeam.Terrorist ? "weapon_knife_t" : "weapon_knife";
|
||||||
|
}
|
||||||
|
|
||||||
|
player.GiveNamedItem(knifeToGive);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static bool PlayerHasKnife(CCSPlayerController? player)
|
||||||
|
{
|
||||||
|
if (!_config.Additional.KnifeEnabled) return false;
|
||||||
|
|
||||||
|
if (player == null || !player.IsValid || player.PlayerPawn == null || !player.PlayerPawn.IsValid)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player.PlayerPawn.Value == null || player.PlayerPawn.Value.WeaponServices == null || player.PlayerPawn.Value.ItemServices == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var weapons = player.PlayerPawn.Value.WeaponServices?.MyWeapons;
|
||||||
|
if (weapons == null) return false;
|
||||||
|
foreach (var weapon in weapons)
|
||||||
|
{
|
||||||
|
if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid)
|
||||||
|
{
|
||||||
|
if (weapon.Value.DesignerName.Contains("knife") || weapon.Value.DesignerName.Contains("bayonet"))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void RefreshWeapons(CCSPlayerController? player)
|
||||||
|
{
|
||||||
|
if (!g_bCommandsAllowed) return;
|
||||||
|
if (player == null || !player.IsValid || player.PlayerPawn?.Value == null || (LifeState_t)player.LifeState != LifeState_t.LIFE_ALIVE)
|
||||||
|
return;
|
||||||
|
if (player.PlayerPawn.Value.WeaponServices == null || player.PlayerPawn.Value.ItemServices == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var weapons = player.PlayerPawn.Value.WeaponServices.MyWeapons;
|
||||||
|
|
||||||
|
if (weapons == null || weapons.Count == 0)
|
||||||
|
return;
|
||||||
|
if (player.Team == CsTeam.None || player.Team == CsTeam.Spectator)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int playerTeam = player.TeamNum;
|
||||||
|
|
||||||
|
//Dictionary<string, (int, int)> weaponsWithAmmo = new Dictionary<string, (int, int)>();
|
||||||
|
Dictionary<string, List<(int, int)>> weaponsWithAmmo = new Dictionary<string, List<(int, int)>>();
|
||||||
|
|
||||||
|
// Iterate through each weapon
|
||||||
|
foreach (var weapon in weapons)
|
||||||
|
{
|
||||||
|
if (weapon == null || !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;
|
||||||
|
if (weapon.Value.OwnerEntity == null) continue;
|
||||||
|
if (!weapon.Value.OwnerEntity.IsValid) continue;
|
||||||
|
if (gun == null) continue;
|
||||||
|
if (gun.Entity == null) continue;
|
||||||
|
if (!gun.IsValid) continue;
|
||||||
|
if (!gun.VisibleinPVS) continue;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string? weaponByDefindex = null;
|
||||||
|
|
||||||
|
CCSWeaponBaseVData? weaponData = weapon.Value.As<CCSWeaponBase>().VData;
|
||||||
|
|
||||||
|
if (weaponData == null) continue;
|
||||||
|
|
||||||
|
if (weaponData.GearSlot == gear_slot_t.GEAR_SLOT_RIFLE || weaponData.GearSlot == gear_slot_t.GEAR_SLOT_PISTOL)
|
||||||
|
{
|
||||||
|
if (!WeaponDefindex.TryGetValue(weapon.Value.AttributeManager.Item.ItemDefinitionIndex, out weaponByDefindex))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
int clip1 = weapon.Value.Clip1;
|
||||||
|
int reservedAmmo = weapon.Value.ReserveAmmo[0];
|
||||||
|
|
||||||
|
if (!weaponsWithAmmo.ContainsKey(weaponByDefindex))
|
||||||
|
{
|
||||||
|
weaponsWithAmmo.Add(weaponByDefindex, new List<(int, int)>());
|
||||||
|
}
|
||||||
|
|
||||||
|
weaponsWithAmmo[weaponByDefindex].Add((clip1, reservedAmmo));
|
||||||
|
|
||||||
|
if (gun == null || gun.VData == null) return;
|
||||||
|
|
||||||
|
weapon.Value.Remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.LogWarning(ex.Message);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
player.ExecuteClientCommand("slot 3");
|
||||||
|
player.ExecuteClientCommand("slot 3");
|
||||||
|
|
||||||
|
var weapon = player.PlayerPawn.Value.WeaponServices.ActiveWeapon;
|
||||||
|
if (weapon is null || !weapon.IsValid || weapon.Value == null) return;
|
||||||
|
CCSWeaponBaseVData? weaponData = weapon.Value.As<CCSWeaponBase>().VData;
|
||||||
|
|
||||||
|
if (weapon.Value.DesignerName.Contains("knife") || weaponData?.GearSlot == gear_slot_t.GEAR_SLOT_KNIFE)
|
||||||
|
{
|
||||||
|
CCSWeaponBaseGun gun = weapon.Value.As<CCSWeaponBaseGun>();
|
||||||
|
|
||||||
|
AddTimer(0.3f, () =>
|
||||||
|
{
|
||||||
|
if (player.TeamNum != playerTeam) return;
|
||||||
|
|
||||||
|
player.ExecuteClientCommand("slot 3");
|
||||||
|
gun = weapon.Value.As<CCSWeaponBaseGun>();
|
||||||
|
player.DropActiveWeapon();
|
||||||
|
|
||||||
|
AddTimer(0.7f, () =>
|
||||||
|
{
|
||||||
|
if (player.TeamNum != playerTeam) return;
|
||||||
|
|
||||||
|
if (gun == null || !gun.IsValid || gun.State != CSWeaponState_t.WEAPON_NOT_CARRIED) return;
|
||||||
|
|
||||||
|
gun.Remove();
|
||||||
|
});
|
||||||
|
|
||||||
|
GiveKnifeToPlayer(player);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.LogWarning($"Cannot remove knife: {ex.Message}");
|
||||||
|
}
|
||||||
|
|
||||||
|
AddTimer(0.6f, () =>
|
||||||
|
{
|
||||||
|
if (!g_bCommandsAllowed) return;
|
||||||
|
|
||||||
|
foreach (var entry in weaponsWithAmmo)
|
||||||
|
{
|
||||||
|
foreach (var ammo in entry.Value)
|
||||||
|
{
|
||||||
|
var newWeapon = new CBasePlayerWeapon(player.GiveNamedItem(entry.Key));
|
||||||
|
Server.NextFrame(() =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (newWeapon != null)
|
||||||
|
{
|
||||||
|
newWeapon.Clip1 = ammo.Item1;
|
||||||
|
newWeapon.ReserveAmmo[0] = ammo.Item2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.LogWarning("Error setting weapon properties: " + ex.Message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}, TimerFlags.STOP_ON_MAPCHANGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
internal void RefreshKnife(CCSPlayerController? player)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
if (player == null || !player.IsValid || player.PlayerPawn?.Value == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (player.PlayerPawn.Value.WeaponServices == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var weapons = player.PlayerPawn.Value.WeaponServices.MyWeapons;
|
||||||
|
if (weapons != null && weapons.Count > 0)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
player.ExecuteClientCommand("slot 3");
|
||||||
|
player.ExecuteClientCommand("slot 3");
|
||||||
|
|
||||||
|
var weapon = player.PlayerPawn.Value.WeaponServices.ActiveWeapon;
|
||||||
|
if (weapon is null || !weapon.IsValid || weapon.Value == null) return;
|
||||||
|
CCSWeaponBaseVData? weaponData = weapon.Value.As<CCSWeaponBase>().VData;
|
||||||
|
|
||||||
|
if (weapon.Value.DesignerName.Contains("knife") || weaponData?.GearSlot == gear_slot_t.GEAR_SLOT_KNIFE)
|
||||||
|
{
|
||||||
|
AddTimer(0.2f, () =>
|
||||||
|
{
|
||||||
|
player.ExecuteClientCommand("slot 3");
|
||||||
|
player.DropActiveWeapon();
|
||||||
|
|
||||||
|
AddTimer(0.6f, () =>
|
||||||
|
{
|
||||||
|
if (weapon.IsValid)
|
||||||
|
weapon.Value.Remove();
|
||||||
|
GiveKnifeToPlayer(player);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.LogWarning($"Cannot remove knife: {ex.Message}");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
foreach (var weapon in weapons)
|
||||||
|
{
|
||||||
|
if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid && weapon.Index > 0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
private static void RefreshGloves(CCSPlayerController player)
|
||||||
|
{
|
||||||
|
if (!Utility.IsPlayerValid(player) || (LifeState_t)player.LifeState != LifeState_t.LIFE_ALIVE) return;
|
||||||
|
|
||||||
|
CCSPlayerPawn? pawn = player.PlayerPawn.Value;
|
||||||
|
if (pawn == null || !pawn.IsValid || pawn.LifeState != (byte)LifeState_t.LIFE_ALIVE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
string model = pawn.CBodyComponent?.SceneNode?.GetSkeletonInstance()?.ModelState.ModelName ?? string.Empty;
|
||||||
|
if (!string.IsNullOrEmpty(model))
|
||||||
|
{
|
||||||
|
pawn.SetModel("characters/models/tm_jumpsuit/tm_jumpsuit_varianta.vmdl");
|
||||||
|
pawn.SetModel(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
Instance.AddTimer(0.06f, () =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (player == null || !player.IsValid)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (pawn == null || !pawn.IsValid || pawn.LifeState != (byte)LifeState_t.LIFE_ALIVE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (g_playersGlove.TryGetValue(player.Slot, out var gloveInfo) && gloveInfo != 0)
|
||||||
|
{
|
||||||
|
CCSPlayerPawn? pawn = player.PlayerPawn.Value;
|
||||||
|
if (pawn == null || !pawn.IsValid || pawn.LifeState != (byte)LifeState_t.LIFE_ALIVE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
WeaponInfo weaponInfo = gPlayerWeaponsInfo[player.Slot][gloveInfo];
|
||||||
|
|
||||||
|
CEconItemView item = pawn.EconGloves;
|
||||||
|
item.ItemDefinitionIndex = gloveInfo;
|
||||||
|
item.ItemIDLow = 16384 & 0xFFFFFFFF;
|
||||||
|
item.ItemIDHigh = 16384;
|
||||||
|
|
||||||
|
CAttributeList_SetOrAddAttributeValueByName.Invoke(item.NetworkedDynamicAttributes.Handle, "set item texture prefab", weaponInfo.Paint);
|
||||||
|
CAttributeList_SetOrAddAttributeValueByName.Invoke(item.NetworkedDynamicAttributes.Handle, "set item texture seed", weaponInfo.Seed);
|
||||||
|
CAttributeList_SetOrAddAttributeValueByName.Invoke(item.NetworkedDynamicAttributes.Handle, "set item texture wear", weaponInfo.Wear);
|
||||||
|
|
||||||
|
item.Initialized = true;
|
||||||
|
|
||||||
|
CBaseModelEntity_SetBodygroup.Invoke(pawn, "default_gloves", 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception) { }
|
||||||
|
}, TimerFlags.STOP_ON_MAPCHANGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int GetRandomPaint(int defindex)
|
||||||
|
{
|
||||||
|
if (skinsList == null || skinsList.Count == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
Random rnd = new Random();
|
||||||
|
|
||||||
|
// Filter weapons by the provided defindex
|
||||||
|
var filteredWeapons = skinsList.Where(w => w["weapon_defindex"]?.ToString() == defindex.ToString()).ToList();
|
||||||
|
|
||||||
|
if (filteredWeapons.Count == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
var randomWeapon = filteredWeapons[rnd.Next(filteredWeapons.Count)];
|
||||||
|
|
||||||
|
if (int.TryParse(randomWeapon["paint"]?.ToString(), out int paintValue))
|
||||||
|
return paintValue;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SubclassChange(CBasePlayerWeapon weapon, ushort itemD)
|
||||||
|
{
|
||||||
|
var SubclassChangeFunc = VirtualFunction.Create<nint, string, int>(
|
||||||
|
GameData.GetSignature("ChangeSubclass")
|
||||||
|
);
|
||||||
|
|
||||||
|
SubclassChangeFunc(weapon.Handle, itemD.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CCSPlayerController? GetPlayerFromItemServices(CCSPlayer_ItemServices itemServices)
|
||||||
|
{
|
||||||
|
var pawn = itemServices.Pawn.Value;
|
||||||
|
if (pawn == null || !pawn.IsValid || !pawn.Controller.IsValid || pawn.Controller.Value == null) return null;
|
||||||
|
var player = new CCSPlayerController(pawn.Controller.Value.Handle);
|
||||||
|
if (!Utility.IsPlayerValid(player)) return null;
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static CSkeletonInstance GetSkeletonInstance(CGameSceneNode node)
|
||||||
|
{
|
||||||
|
Func<nint, nint> GetSkeletonInstance = VirtualFunction.Create<nint, nint>(node.Handle, 8);
|
||||||
|
return new CSkeletonInstance(GetSkeletonInstance(node.Handle));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static unsafe CHandle<CBaseViewModel>[]? GetPlayerViewModels(CCSPlayerController player)
|
||||||
|
{
|
||||||
|
if (player.PlayerPawn.Value == null || player.PlayerPawn.Value.ViewModelServices == null) return null;
|
||||||
|
CCSPlayer_ViewModelServices viewModelServices = new CCSPlayer_ViewModelServices(player.PlayerPawn.Value.ViewModelServices!.Handle);
|
||||||
|
return GetFixedArray<CHandle<CBaseViewModel>>(viewModelServices.Handle, "CCSPlayer_ViewModelServices", "m_hViewModel", 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static unsafe T[] GetFixedArray<T>(nint pointer, string @class, string member, int length) where T : CHandle<CBaseViewModel>
|
||||||
|
{
|
||||||
|
nint ptr = pointer + Schema.GetSchemaOffset(@class, member);
|
||||||
|
Span<nint> references = MemoryMarshal.CreateSpan(ref ptr, length);
|
||||||
|
T[] values = new T[length];
|
||||||
|
|
||||||
|
for (int i = 0; i < length; i++)
|
||||||
|
{
|
||||||
|
values[i] = (T)Activator.CreateInstance(typeof(T), references[i])!;
|
||||||
|
}
|
||||||
|
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
9
WeaponInfo.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
namespace WeaponPaints
|
||||||
|
{
|
||||||
|
public class WeaponInfo
|
||||||
|
{
|
||||||
|
public int Paint { get; set; }
|
||||||
|
public int Seed { get; set; } = 0;
|
||||||
|
public float Wear { get; set; } = 0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
956
WeaponPaints.cs
@@ -1,778 +1,258 @@
|
|||||||
using CounterStrikeSharp.API;
|
using CounterStrikeSharp.API;
|
||||||
using CounterStrikeSharp.API.Core;
|
using CounterStrikeSharp.API.Core;
|
||||||
using CounterStrikeSharp.API.Core.Attributes;
|
using CounterStrikeSharp.API.Core.Attributes;
|
||||||
using CounterStrikeSharp.API.Modules.Commands;
|
using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;
|
||||||
using CounterStrikeSharp.API.Modules.Entities;
|
using Microsoft.Extensions.Localization;
|
||||||
using CounterStrikeSharp.API.Modules.Memory;
|
using Microsoft.Extensions.Logging;
|
||||||
using CounterStrikeSharp.API.Modules.Menu;
|
|
||||||
using CounterStrikeSharp.API.Modules.Utils;
|
|
||||||
using MySqlConnector;
|
using MySqlConnector;
|
||||||
using Dapper;
|
|
||||||
using System.Runtime.ExceptionServices;
|
|
||||||
using System.Reflection;
|
|
||||||
using CounterStrikeSharp.API.Modules.Cvars;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
|
||||||
namespace WeaponPaints;
|
namespace WeaponPaints;
|
||||||
[MinimumApiVersion(55)]
|
|
||||||
public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
[MinimumApiVersion(178)]
|
||||||
|
public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
||||||
{
|
{
|
||||||
public override string ModuleName => "WeaponPaints";
|
internal static WeaponPaints Instance { get; private set; } = new();
|
||||||
public override string ModuleDescription => "Connector for web-based player chosen wepaon paints, and standalone for knife.";
|
|
||||||
public override string ModuleAuthor => "Nereziel";
|
internal static readonly Dictionary<string, string> weaponList = new()
|
||||||
public override string ModuleVersion => "1.0";
|
{
|
||||||
|
{"weapon_deagle", "Desert Eagle"},
|
||||||
|
{"weapon_elite", "Dual Berettas"},
|
||||||
|
{"weapon_fiveseven", "Five-SeveN"},
|
||||||
|
{"weapon_glock", "Glock-18"},
|
||||||
|
{"weapon_ak47", "AK-47"},
|
||||||
|
{"weapon_aug", "AUG"},
|
||||||
|
{"weapon_awp", "AWP"},
|
||||||
|
{"weapon_famas", "FAMAS"},
|
||||||
|
{"weapon_g3sg1", "G3SG1"},
|
||||||
|
{"weapon_galilar", "Galil AR"},
|
||||||
|
{"weapon_m249", "M249"},
|
||||||
|
{"weapon_m4a1", "M4A1"},
|
||||||
|
{"weapon_mac10", "MAC-10"},
|
||||||
|
{"weapon_p90", "P90"},
|
||||||
|
{"weapon_mp5sd", "MP5-SD"},
|
||||||
|
{"weapon_ump45", "UMP-45"},
|
||||||
|
{"weapon_xm1014", "XM1014"},
|
||||||
|
{"weapon_bizon", "PP-Bizon"},
|
||||||
|
{"weapon_mag7", "MAG-7"},
|
||||||
|
{"weapon_negev", "Negev"},
|
||||||
|
{"weapon_sawedoff", "Sawed-Off"},
|
||||||
|
{"weapon_tec9", "Tec-9"},
|
||||||
|
{"weapon_taser", "Zeus x27"},
|
||||||
|
{"weapon_hkp2000", "P2000"},
|
||||||
|
{"weapon_mp7", "MP7"},
|
||||||
|
{"weapon_mp9", "MP9"},
|
||||||
|
{"weapon_nova", "Nova"},
|
||||||
|
{"weapon_p250", "P250"},
|
||||||
|
{"weapon_scar20", "SCAR-20"},
|
||||||
|
{"weapon_sg556", "SG 553"},
|
||||||
|
{"weapon_ssg08", "SSG 08"},
|
||||||
|
{"weapon_m4a1_silencer", "M4A1-S"},
|
||||||
|
{"weapon_usp_silencer", "USP-S"},
|
||||||
|
{"weapon_cz75a", "CZ75-Auto"},
|
||||||
|
{"weapon_revolver", "R8 Revolver"},
|
||||||
|
{ "weapon_knife", "Default Knife" },
|
||||||
|
{ "weapon_knife_m9_bayonet", "M9 Bayonet" },
|
||||||
|
{ "weapon_knife_karambit", "Karambit" },
|
||||||
|
{ "weapon_bayonet", "Bayonet" },
|
||||||
|
{ "weapon_knife_survival_bowie", "Bowie Knife" },
|
||||||
|
{ "weapon_knife_butterfly", "Butterfly Knife" },
|
||||||
|
{ "weapon_knife_falchion", "Falchion Knife" },
|
||||||
|
{ "weapon_knife_flip", "Flip Knife" },
|
||||||
|
{ "weapon_knife_gut", "Gut Knife" },
|
||||||
|
{ "weapon_knife_tactical", "Huntsman Knife" },
|
||||||
|
{ "weapon_knife_push", "Shadow Daggers" },
|
||||||
|
{ "weapon_knife_gypsy_jackknife", "Navaja Knife" },
|
||||||
|
{ "weapon_knife_stiletto", "Stiletto Knife" },
|
||||||
|
{ "weapon_knife_widowmaker", "Talon Knife" },
|
||||||
|
{ "weapon_knife_ursus", "Ursus Knife" },
|
||||||
|
{ "weapon_knife_css", "Classic Knife" },
|
||||||
|
{ "weapon_knife_cord", "Paracord Knife" },
|
||||||
|
{ "weapon_knife_canis", "Survival Knife" },
|
||||||
|
{ "weapon_knife_outdoor", "Nomad Knife" },
|
||||||
|
{ "weapon_knife_skeleton", "Skeleton Knife" },
|
||||||
|
{ "weapon_knife_kukri", "Kukri Knife" }
|
||||||
|
};
|
||||||
|
|
||||||
|
internal static WeaponPaintsConfig _config = new WeaponPaintsConfig();
|
||||||
|
internal static IStringLocalizer? _localizer;
|
||||||
|
internal static Dictionary<int, int> g_knifePickupCount = new Dictionary<int, int>();
|
||||||
|
internal static ConcurrentDictionary<int, string> g_playersKnife = new ConcurrentDictionary<int, string>();
|
||||||
|
internal static ConcurrentDictionary<int, ushort> g_playersGlove = new ConcurrentDictionary<int, ushort>();
|
||||||
|
internal static ConcurrentDictionary<int, ConcurrentDictionary<int, WeaponInfo>> gPlayerWeaponsInfo = new ConcurrentDictionary<int, ConcurrentDictionary<int, WeaponInfo>>();
|
||||||
|
internal static List<JObject> skinsList = new List<JObject>();
|
||||||
|
internal static List<JObject> glovesList = new List<JObject>();
|
||||||
|
internal static WeaponSynchronization? weaponSync;
|
||||||
|
public static bool g_bCommandsAllowed = true;
|
||||||
|
internal Dictionary<int, string> PlayerWeaponImage = new();
|
||||||
|
|
||||||
|
internal static Dictionary<int, DateTime> commandsCooldown = new Dictionary<int, DateTime>();
|
||||||
|
internal static Database? _database;
|
||||||
|
|
||||||
|
internal static MemoryFunctionVoid<nint, string, float> CAttributeList_SetOrAddAttributeValueByName = new(GameData.GetSignature("CAttributeList_SetOrAddAttributeValueByName"));
|
||||||
|
internal static MemoryFunctionVoid<CBaseModelEntity, string, UInt64> CBaseModelEntity_SetBodygroup = new(GameData.GetSignature("CBaseModelEntity_SetBodygroup"));
|
||||||
|
|
||||||
|
public static Dictionary<int, string> WeaponDefindex { get; } = new Dictionary<int, string>
|
||||||
|
{
|
||||||
|
{ 1, "weapon_deagle" },
|
||||||
|
{ 2, "weapon_elite" },
|
||||||
|
{ 3, "weapon_fiveseven" },
|
||||||
|
{ 4, "weapon_glock" },
|
||||||
|
{ 7, "weapon_ak47" },
|
||||||
|
{ 8, "weapon_aug" },
|
||||||
|
{ 9, "weapon_awp" },
|
||||||
|
{ 10, "weapon_famas" },
|
||||||
|
{ 11, "weapon_g3sg1" },
|
||||||
|
{ 13, "weapon_galilar" },
|
||||||
|
{ 14, "weapon_m249" },
|
||||||
|
{ 16, "weapon_m4a1" },
|
||||||
|
{ 17, "weapon_mac10" },
|
||||||
|
{ 19, "weapon_p90" },
|
||||||
|
{ 23, "weapon_mp5sd" },
|
||||||
|
{ 24, "weapon_ump45" },
|
||||||
|
{ 25, "weapon_xm1014" },
|
||||||
|
{ 26, "weapon_bizon" },
|
||||||
|
{ 27, "weapon_mag7" },
|
||||||
|
{ 28, "weapon_negev" },
|
||||||
|
{ 29, "weapon_sawedoff" },
|
||||||
|
{ 30, "weapon_tec9" },
|
||||||
|
{ 31, "weapon_taser" },
|
||||||
|
{ 32, "weapon_hkp2000" },
|
||||||
|
{ 33, "weapon_mp7" },
|
||||||
|
{ 34, "weapon_mp9" },
|
||||||
|
{ 35, "weapon_nova" },
|
||||||
|
{ 36, "weapon_p250" },
|
||||||
|
{ 38, "weapon_scar20" },
|
||||||
|
{ 39, "weapon_sg556" },
|
||||||
|
{ 40, "weapon_ssg08" },
|
||||||
|
{ 60, "weapon_m4a1_silencer" },
|
||||||
|
{ 61, "weapon_usp_silencer" },
|
||||||
|
{ 63, "weapon_cz75a" },
|
||||||
|
{ 64, "weapon_revolver" },
|
||||||
|
{ 500, "weapon_bayonet" },
|
||||||
|
{ 503, "weapon_knife_css" },
|
||||||
|
{ 505, "weapon_knife_flip" },
|
||||||
|
{ 506, "weapon_knife_gut" },
|
||||||
|
{ 507, "weapon_knife_karambit" },
|
||||||
|
{ 508, "weapon_knife_m9_bayonet" },
|
||||||
|
{ 509, "weapon_knife_tactical" },
|
||||||
|
{ 512, "weapon_knife_falchion" },
|
||||||
|
{ 514, "weapon_knife_survival_bowie" },
|
||||||
|
{ 515, "weapon_knife_butterfly" },
|
||||||
|
{ 516, "weapon_knife_push" },
|
||||||
|
{ 517, "weapon_knife_cord" },
|
||||||
|
{ 518, "weapon_knife_canis" },
|
||||||
|
{ 519, "weapon_knife_ursus" },
|
||||||
|
{ 520, "weapon_knife_gypsy_jackknife" },
|
||||||
|
{ 521, "weapon_knife_outdoor" },
|
||||||
|
{ 522, "weapon_knife_stiletto" },
|
||||||
|
{ 523, "weapon_knife_widowmaker" },
|
||||||
|
{ 525, "weapon_knife_skeleton" },
|
||||||
|
{ 526, "weapon_knife_kukri" }
|
||||||
|
};
|
||||||
|
|
||||||
public WeaponPaintsConfig Config { get; set; } = new();
|
public WeaponPaintsConfig Config { get; set; } = new();
|
||||||
|
public override string ModuleAuthor => "Nereziel & daffyy";
|
||||||
|
public override string ModuleDescription => "Skin, gloves and knife selector, standalone and web-based";
|
||||||
|
public override string ModuleName => "WeaponPaints";
|
||||||
|
public override string ModuleVersion => "2.0a";
|
||||||
|
|
||||||
private string DatabaseConnectionString = string.Empty;
|
public static WeaponPaintsConfig GetWeaponPaintsConfig()
|
||||||
private Uri GlobalShareApi = new Uri("https://weaponpaints.fun/api.php");
|
|
||||||
|
|
||||||
public bool IsMatchZy = false;
|
|
||||||
public int GlobalShareServerId = 0;
|
|
||||||
|
|
||||||
private DateTime[] commandCooldown = new DateTime[Server.MaxPlayers];
|
|
||||||
private Dictionary<ulong, Dictionary<nint, int>> gPlayerWeaponPaints = new();
|
|
||||||
private Dictionary<ulong, Dictionary<nint, int>> gPlayerWeaponSeed = new();
|
|
||||||
private Dictionary<ulong, Dictionary<nint, float>> gPlayerWeaponWear = new();
|
|
||||||
private Dictionary<int, string> g_playersKnife = new();
|
|
||||||
private static readonly Dictionary<string, string> knifeTypes = new()
|
|
||||||
{
|
{
|
||||||
{ "m9", "weapon_knife_m9_bayonet" }, { "karambit", "weapon_knife_karambit" },
|
return _config;
|
||||||
{ "bayonet", "weapon_bayonet" }, { "bowie", "weapon_knife_survival_bowie" },
|
}
|
||||||
{ "butterfly", "weapon_knife_butterfly" }, { "falchion", "weapon_knife_falchion" },
|
|
||||||
{ "flip", "weapon_knife_flip" }, { "gut", "weapon_knife_gut" },
|
|
||||||
{ "tactical", "weapon_knife_tactical" }, { "shadow", "weapon_knife_push" },
|
|
||||||
{ "navaja", "weapon_knife_gypsy_jackknife" }, { "stiletto", "weapon_knife_stiletto" },
|
|
||||||
{ "talon", "weapon_knife_widowmaker" }, { "ursus", "weapon_knife_ursus" },
|
|
||||||
{ "css", "weapon_knife_css" }, { "paracord", "weapon_knife_cord" },
|
|
||||||
{ "survival", "weapon_knife_canis" }, { "nomad", "weapon_knife_outdoor" },
|
|
||||||
{ "skeleton", "weapon_knife_skeleton" }, { "default", "weapon_knife" }
|
|
||||||
};
|
|
||||||
private static readonly List<string> weaponList = new()
|
|
||||||
{
|
|
||||||
"weapon_deagle", "weapon_elite", "weapon_fiveseven", "weapon_glock",
|
|
||||||
"weapon_ak47", "weapon_aug", "weapon_awp", "weapon_famas",
|
|
||||||
"weapon_g3sg1", "weapon_galilar", "weapon_m249", "weapon_m4a1",
|
|
||||||
"weapon_mac10", "weapon_p90", "weapon_mp5sd", "weapon_ump45",
|
|
||||||
"weapon_xm1014", "weapon_bizon", "weapon_mag7", "weapon_negev",
|
|
||||||
"weapon_sawedoff", "weapon_tec9", "weapon_hkp2000", "weapon_mp7",
|
|
||||||
"weapon_mp9", "weapon_nova", "weapon_p250", "weapon_scar20",
|
|
||||||
"weapon_sg556", "weapon_ssg08", "weapon_m4a1_silencer", "weapon_usp_silencer",
|
|
||||||
"weapon_cz75a", "weapon_revolver", "weapon_bayonet", "weapon_knife"
|
|
||||||
};
|
|
||||||
public override void Load(bool hotReload)
|
public override void Load(bool hotReload)
|
||||||
{
|
{
|
||||||
SetGlobalExceptionHandler();
|
Instance = this;
|
||||||
if (!Config.GlobalShare)
|
|
||||||
{
|
|
||||||
BuildDatabaseConnectionString();
|
|
||||||
TestDatabaseConnection();
|
|
||||||
}
|
|
||||||
RegisterListener<Listeners.OnEntitySpawned>(OnEntitySpawned);
|
|
||||||
RegisterListener<Listeners.OnClientPutInServer>(OnClientPutInServer);
|
|
||||||
RegisterListener<Listeners.OnClientDisconnect>(OnClientDisconnect);
|
|
||||||
RegisterListener<Listeners.OnMapStart>(OnMapStart);
|
|
||||||
RegisterEventHandler<EventPlayerSpawn>(OnPlayerSpawn);
|
|
||||||
RegisterEventHandler<EventRoundStart>(OnRoundStart, HookMode.Pre);
|
|
||||||
RegisterEventHandler<EventItemPickup>(OnItemPickup, HookMode.Pre);
|
|
||||||
|
|
||||||
if (hotReload)
|
if (hotReload)
|
||||||
{
|
{
|
||||||
OnMapStart(string.Empty);
|
OnMapStart(string.Empty);
|
||||||
Task.Run(async () =>
|
|
||||||
|
foreach (var player in Utilities.GetPlayers())
|
||||||
{
|
{
|
||||||
for (int i = 1; i <= Server.MaxPlayers; i++)
|
if (weaponSync == null || player is null || !player.IsValid || player.SteamID.ToString().Length != 17 || !player.PawnIsAlive || player.IsBot ||
|
||||||
|
player.IsHLTV || player.Connected != PlayerConnectedState.PlayerConnected)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
g_knifePickupCount[(int)player.Slot] = 0;
|
||||||
|
gPlayerWeaponsInfo.TryRemove((int)player.Slot, out _);
|
||||||
|
g_playersKnife.TryRemove((int)player.Slot, out _);
|
||||||
|
|
||||||
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
{
|
{
|
||||||
if (Config.Additional.KnifeEnabled)
|
UserId = player.UserId,
|
||||||
await GetKnifeFromDatabase(i);
|
Slot = player.Slot,
|
||||||
if (Config.Additional.SkinEnabled)
|
Index = (int)player.Slot,
|
||||||
await GetWeaponPaintsFromDatabase(i);
|
SteamId = player?.SteamID.ToString(),
|
||||||
|
Name = player?.PlayerName,
|
||||||
|
IpAddress = player?.IpAddress?.Split(":")[0]
|
||||||
|
};
|
||||||
|
|
||||||
|
if (Config.Additional.SkinEnabled)
|
||||||
|
{
|
||||||
|
Task.Run(() => weaponSync.GetWeaponPaintsFromDatabase(playerInfo));
|
||||||
}
|
}
|
||||||
});
|
if (Config.Additional.KnifeEnabled)
|
||||||
|
{
|
||||||
|
Task.Run(() => weaponSync.GetKnifeFromDatabase(playerInfo));
|
||||||
|
}
|
||||||
|
if (Config.Additional.GloveEnabled)
|
||||||
|
{
|
||||||
|
Task.Run(() => weaponSync.GetGloveFromDatabase(playerInfo));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.Additional.KnifeEnabled)
|
Utility.LoadSkinsFromFile(ModuleDirectory + "/skins.json");
|
||||||
SetupMenus();
|
Utility.LoadGlovesFromFile(ModuleDirectory + "/gloves.json");
|
||||||
|
|
||||||
|
if (Config.Additional.KnifeEnabled)
|
||||||
|
SetupKnifeMenu();
|
||||||
|
if (Config.Additional.SkinEnabled)
|
||||||
|
SetupSkinsMenu();
|
||||||
|
if (Config.Additional.GloveEnabled)
|
||||||
|
SetupGlovesMenu();
|
||||||
|
|
||||||
|
RegisterListeners();
|
||||||
RegisterCommands();
|
RegisterCommands();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnConfigParsed(WeaponPaintsConfig config)
|
public void OnConfigParsed(WeaponPaintsConfig config)
|
||||||
{
|
{
|
||||||
if (!config.GlobalShare)
|
if (config.DatabaseHost.Length < 1 || config.DatabaseName.Length < 1 || config.DatabaseUser.Length < 1)
|
||||||
{
|
{
|
||||||
if (config.DatabaseHost.Length < 1 || config.DatabaseName.Length < 1 || config.DatabaseUser.Length < 1)
|
Logger.LogError("You need to setup Database credentials in config!");
|
||||||
{
|
throw new Exception("[WeaponPaints] You need to setup Database credentials in config!");
|
||||||
throw new Exception("You need to setup Database credentials in config!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Config = config;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void BuildDatabaseConnectionString()
|
|
||||||
{
|
|
||||||
var builder = new MySqlConnectionStringBuilder
|
var builder = new MySqlConnectionStringBuilder
|
||||||
{
|
{
|
||||||
Server = Config.DatabaseHost,
|
Server = config.DatabaseHost,
|
||||||
UserID = Config.DatabaseUser,
|
UserID = config.DatabaseUser,
|
||||||
Password = Config.DatabasePassword,
|
Password = config.DatabasePassword,
|
||||||
Database = Config.DatabaseName,
|
Database = config.DatabaseName,
|
||||||
Port = (uint)Config.DatabasePort,
|
Port = (uint)config.DatabasePort,
|
||||||
|
Pooling = true
|
||||||
};
|
};
|
||||||
|
|
||||||
DatabaseConnectionString = builder.ConnectionString;
|
_database = new(builder.ConnectionString);
|
||||||
|
|
||||||
|
_ = Utility.CheckDatabaseTables();
|
||||||
|
|
||||||
|
Config = config;
|
||||||
|
_config = config;
|
||||||
|
_localizer = Localizer;
|
||||||
|
|
||||||
|
Utility.Config = config;
|
||||||
|
Utility.ShowAd(ModuleVersion);
|
||||||
|
Task.Run(async () => await Utility.CheckVersion(ModuleVersion, Logger));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TestDatabaseConnection()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new MySqlConnection(DatabaseConnectionString);
|
|
||||||
connection.Open();
|
|
||||||
|
|
||||||
if (connection.State != System.Data.ConnectionState.Open)
|
|
||||||
{
|
|
||||||
throw new Exception("Unable connect to database!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
throw new Exception("Unknown mysql exception! " + ex.Message);
|
|
||||||
}
|
|
||||||
CheckDatabaseTables();
|
|
||||||
}
|
|
||||||
|
|
||||||
async private void CheckDatabaseTables()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new MySqlConnection(DatabaseConnectionString);
|
|
||||||
await connection.OpenAsync();
|
|
||||||
|
|
||||||
using var transaction = await connection.BeginTransactionAsync();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
string createTable1 = "CREATE TABLE IF NOT EXISTS `wp_player_skins` (`steamid` varchar(64) NOT NULL, `weapon_defindex` int(6) NOT NULL, `weapon_paint_id` int(6) NOT NULL, `weapon_wear` float NOT NULL DEFAULT 0.0001, `weapon_seed` int(16) NOT NULL DEFAULT 0) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci";
|
|
||||||
string createTable2 = "CREATE TABLE IF NOT EXISTS `wp_player_knife` (`steamid` varchar(64) NOT NULL, `knife` varchar(64) NOT NULL, UNIQUE (`steamid`)) ENGINE = InnoDB";
|
|
||||||
|
|
||||||
await connection.ExecuteAsync(createTable1, transaction: transaction);
|
|
||||||
await connection.ExecuteAsync(createTable2, transaction: transaction);
|
|
||||||
|
|
||||||
await transaction.CommitAsync();
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
await transaction.RollbackAsync();
|
|
||||||
throw new Exception("Unable to create tables!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
throw new Exception("Unknown mysql exception! " + ex.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// TODO: fix for map which change mp_t_default_melee
|
|
||||||
/*private HookResult OnRoundPreStart(EventRoundPrestart @event, GameEventInfo info)
|
|
||||||
{
|
|
||||||
NativeAPI.IssueServerCommand("mp_t_default_melee \"\"");
|
|
||||||
NativeAPI.IssueServerCommand("mp_ct_default_melee \"\"");
|
|
||||||
return HookResult.Continue;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
public override void Unload(bool hotReload)
|
public override void Unload(bool hotReload)
|
||||||
{
|
{
|
||||||
RemoveGlobalExceptionHandler();
|
|
||||||
base.Unload(hotReload);
|
base.Unload(hotReload);
|
||||||
}
|
}
|
||||||
private void GlobalExceptionHandler(object? sender, FirstChanceExceptionEventArgs @event)
|
}
|
||||||
{
|
|
||||||
Log(@event.Exception.ToString());
|
|
||||||
}
|
|
||||||
private void SetGlobalExceptionHandler()
|
|
||||||
{
|
|
||||||
AppDomain.CurrentDomain.FirstChanceException += this.GlobalExceptionHandler;
|
|
||||||
}
|
|
||||||
private void RemoveGlobalExceptionHandler()
|
|
||||||
{
|
|
||||||
AppDomain.CurrentDomain.FirstChanceException -= this.GlobalExceptionHandler;
|
|
||||||
}
|
|
||||||
private void RegisterCommands()
|
|
||||||
{
|
|
||||||
AddCommand($"css_{Config.Additional.CommandSkin}", "Skins info", (player, info) => { if (player == null) return; OnCommandWS(player, info); });
|
|
||||||
AddCommand($"css_{Config.Additional.CommandRefresh}", "Skins refresh", (player, info) => { if (player == null) return; OnCommandRefresh(player, info); });
|
|
||||||
if (Config.Additional.CommandKillEnabled)
|
|
||||||
{
|
|
||||||
AddCommand($"css_{Config.Additional.CommandKill}", "kill yourself", (player, info) =>
|
|
||||||
{
|
|
||||||
if (player == null || !player.IsValid || !player.PlayerPawn.IsValid)
|
|
||||||
return;
|
|
||||||
|
|
||||||
player.PlayerPawn.Value.CommitSuicide(true, false);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void IncompatibilityCheck()
|
|
||||||
{
|
|
||||||
// MatchZy
|
|
||||||
if (Directory.Exists(Path.GetDirectoryName(ModuleDirectory) + "/MatchZy"))
|
|
||||||
{
|
|
||||||
Console.WriteLine("[WeaponPaints] Incompatibility found: MatchZy");
|
|
||||||
IsMatchZy = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnMapStart(string mapName)
|
|
||||||
{
|
|
||||||
if (!Config.Additional.KnifeEnabled) return;
|
|
||||||
// TODO
|
|
||||||
// needed for now
|
|
||||||
AddTimer(2.0f, () =>
|
|
||||||
{
|
|
||||||
NativeAPI.IssueServerCommand("mp_t_default_melee \"\"");
|
|
||||||
NativeAPI.IssueServerCommand("mp_ct_default_melee \"\"");
|
|
||||||
IncompatibilityCheck();
|
|
||||||
});
|
|
||||||
if (Config.GlobalShare)
|
|
||||||
GlobalShareConnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void GlobalShareConnect()
|
|
||||||
{
|
|
||||||
if (!Config.GlobalShare) return;
|
|
||||||
|
|
||||||
var values = new Dictionary<string, string>
|
|
||||||
{
|
|
||||||
{ "server_address", $"{ConVar.Find("ip")!.StringValue}:{ConVar.Find("hostport")!.GetPrimitiveValue<int>().ToString()}" },
|
|
||||||
{ "server_hostname", ConVar.Find("hostname")!.StringValue }
|
|
||||||
};
|
|
||||||
|
|
||||||
using (var httpClient = new HttpClient())
|
|
||||||
{
|
|
||||||
httpClient.BaseAddress = GlobalShareApi;
|
|
||||||
var formContent = new FormUrlEncodedContent(values);
|
|
||||||
|
|
||||||
Task<HttpResponseMessage> responseTask = httpClient.PostAsync("", formContent);
|
|
||||||
responseTask.Wait();
|
|
||||||
HttpResponseMessage response = responseTask.Result;
|
|
||||||
|
|
||||||
if (response.IsSuccessStatusCode)
|
|
||||||
{
|
|
||||||
Task<string> responseBodyTask = response.Content.ReadAsStringAsync();
|
|
||||||
responseBodyTask.Wait();
|
|
||||||
string responseBody = responseBodyTask.Result;
|
|
||||||
GlobalShareServerId = Int32.Parse(responseBody);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new Exception("Unable to retrieve serverid from GlobalShare!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Console.WriteLine("[WeaponPaints] GlobalShare ONLINE");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnClientPutInServer(int playerSlot)
|
|
||||||
{
|
|
||||||
int playerIndex = playerSlot + 1;
|
|
||||||
Task.Run(async () =>
|
|
||||||
{
|
|
||||||
if (Config.Additional.KnifeEnabled)
|
|
||||||
await GetKnifeFromDatabase(playerIndex);
|
|
||||||
if (Config.Additional.SkinEnabled)
|
|
||||||
await GetWeaponPaintsFromDatabase(playerIndex);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
private void OnClientDisconnect(int playerSlot)
|
|
||||||
{
|
|
||||||
CCSPlayerController player = Utilities.GetPlayerFromSlot(playerSlot);
|
|
||||||
if (!player.IsValid || player.IsBot) return;
|
|
||||||
// TODO: Clean up after player
|
|
||||||
if (Config.Additional.KnifeEnabled)
|
|
||||||
g_playersKnife.Remove((int)player.EntityIndex!.Value.Value);
|
|
||||||
if (Config.Additional.SkinEnabled)
|
|
||||||
gPlayerWeaponPaints.Remove(new SteamID(player.SteamID).SteamId64);
|
|
||||||
}
|
|
||||||
|
|
||||||
private HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
|
|
||||||
{
|
|
||||||
var player = @event.Userid;
|
|
||||||
if (!player.IsValid || !player.PlayerPawn.IsValid)
|
|
||||||
{
|
|
||||||
return HookResult.Continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.Additional.KnifeEnabled)
|
|
||||||
{
|
|
||||||
GiveKnifeToPlayer(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return HookResult.Continue;
|
|
||||||
}
|
|
||||||
private HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info)
|
|
||||||
{
|
|
||||||
if (!IsMatchZy) return HookResult.Continue;
|
|
||||||
|
|
||||||
NativeAPI.IssueServerCommand("mp_t_default_melee \"\"");
|
|
||||||
NativeAPI.IssueServerCommand("mp_ct_default_melee \"\"");
|
|
||||||
|
|
||||||
return HookResult.Continue;
|
|
||||||
}
|
|
||||||
private HookResult OnItemPickup(EventItemPickup @event, GameEventInfo info)
|
|
||||||
{
|
|
||||||
if (@event.Defindex == 42 || @event.Defindex == 59)
|
|
||||||
{
|
|
||||||
CCSPlayerController player = @event.Userid;
|
|
||||||
|
|
||||||
if (player.IsValid && !player.IsBot && @event.Item == "knife")
|
|
||||||
{
|
|
||||||
if (g_playersKnife.ContainsKey((int)player.EntityIndex!.Value.Value)
|
|
||||||
&&
|
|
||||||
g_playersKnife[(int)player.EntityIndex!.Value.Value] != "weapon_knife")
|
|
||||||
{
|
|
||||||
RefreshPlayerKnife(player, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return HookResult.Continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnEntitySpawned(CEntityInstance entity)
|
|
||||||
{
|
|
||||||
if (!Config.Additional.SkinEnabled) return;
|
|
||||||
var designerName = entity.DesignerName;
|
|
||||||
if (!weaponList.Contains(designerName)) return;
|
|
||||||
bool isKnife = false;
|
|
||||||
var weapon = new CBasePlayerWeapon(entity.Handle);
|
|
||||||
|
|
||||||
if (designerName.Contains("knife") || designerName.Contains("bayonet"))
|
|
||||||
{
|
|
||||||
isKnife = true;
|
|
||||||
}
|
|
||||||
Server.NextFrame(() =>
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!weapon.IsValid) return;
|
|
||||||
if (weapon.OwnerEntity.Value == null) return;
|
|
||||||
if (!weapon.OwnerEntity.Value.EntityIndex.HasValue) return;
|
|
||||||
int weaponOwner = (int)weapon.OwnerEntity.Value.EntityIndex.Value.Value;
|
|
||||||
var pawn = new CBasePlayerPawn(NativeAPI.GetEntityFromIndex(weaponOwner));
|
|
||||||
if (!pawn.IsValid) return;
|
|
||||||
var playerIndex = (int)pawn.Controller.Value.EntityIndex!.Value.Value;
|
|
||||||
var player = Utilities.GetPlayerFromIndex(playerIndex);
|
|
||||||
if (player == null || !player.IsValid || player.IsBot) return;
|
|
||||||
// TODO: Remove knife crashes here, needs another solution
|
|
||||||
/*if (isKnife && g_playersKnife[(int)player.EntityIndex!.Value.Value] != "weapon_knife" && (weapon.AttributeManager.Item.ItemDefinitionIndex == 42 || weapon.AttributeManager.Item.ItemDefinitionIndex == 59))
|
|
||||||
{
|
|
||||||
RemoveKnifeFromPlayer(player);
|
|
||||||
return;
|
|
||||||
}*/
|
|
||||||
var steamId = new SteamID(player.SteamID);
|
|
||||||
if (!gPlayerWeaponPaints.ContainsKey(steamId.SteamId64)) return;
|
|
||||||
if (!gPlayerWeaponPaints[steamId.SteamId64].ContainsKey(weapon.AttributeManager.Item.ItemDefinitionIndex)) return;
|
|
||||||
//Log($"Apply on {weapon.DesignerName}({weapon.AttributeManager.Item.ItemDefinitionIndex}) paint {gPlayerWeaponPaints[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex]} seed {gPlayerWeaponSeed[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex]} wear {gPlayerWeaponWear[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex]}");
|
|
||||||
weapon.AttributeManager.Item.ItemID = 16384;
|
|
||||||
weapon.AttributeManager.Item.ItemIDLow = 16384 & 0xFFFFFFFF;
|
|
||||||
weapon.AttributeManager.Item.ItemIDHigh = weapon.AttributeManager.Item.ItemIDLow >> 32;
|
|
||||||
weapon.FallbackPaintKit = gPlayerWeaponPaints[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex];
|
|
||||||
weapon.FallbackSeed = gPlayerWeaponSeed[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex];
|
|
||||||
weapon.FallbackWear = gPlayerWeaponWear[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex];
|
|
||||||
if (!isKnife && weapon.CBodyComponent != null && weapon.CBodyComponent.SceneNode != null)
|
|
||||||
{
|
|
||||||
var skeleton = GetSkeletonInstance(weapon.CBodyComponent.SceneNode);
|
|
||||||
skeleton.ModelState.MeshGroupMask = 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception) { }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
public void GiveKnifeToPlayer(CCSPlayerController? player)
|
|
||||||
{
|
|
||||||
if (!Config.Additional.KnifeEnabled) return;
|
|
||||||
if (player == null || !player.IsValid) return;
|
|
||||||
|
|
||||||
if (g_playersKnife.TryGetValue((int)player.EntityIndex!.Value.Value, out var knife))
|
|
||||||
{
|
|
||||||
player.GiveNamedItem(knife);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (Config.Additional.GiveRandomKnife)
|
|
||||||
{
|
|
||||||
Random random = new Random();
|
|
||||||
int index = random.Next(knifeTypes.Count);
|
|
||||||
player.GiveNamedItem(knifeTypes.Values.ElementAt(index));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
player.GiveNamedItem((CsTeam)player.TeamNum == CsTeam.Terrorist ? "weapon_knife_t" : "weapon_knife");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void RemoveKnifeFromPlayer(CCSPlayerController? player)
|
|
||||||
{
|
|
||||||
if (player == null || !player.IsValid || !player.PawnIsAlive) return;
|
|
||||||
var weapons = player.PlayerPawn.Value.WeaponServices!.MyWeapons;
|
|
||||||
foreach (var weapon in weapons)
|
|
||||||
{
|
|
||||||
if (weapon.IsValid && weapon.Value.IsValid)
|
|
||||||
{
|
|
||||||
//if (weapon.Value.AttributeManager.Item.ItemDefinitionIndex == 42 || weapon.Value.AttributeManager.Item.ItemDefinitionIndex == 59)
|
|
||||||
if (weapon.Value.DesignerName.Contains("knife"))
|
|
||||||
{
|
|
||||||
weapon.Value.Remove();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void RefreshPlayerKnife(CCSPlayerController? player, bool remove = false)
|
|
||||||
{
|
|
||||||
if (player == null || !player.IsValid || !player.PawnIsAlive) return;
|
|
||||||
|
|
||||||
if (remove == true)
|
|
||||||
RemoveKnifeFromPlayer(player);
|
|
||||||
|
|
||||||
AddTimer(0.2f, () =>
|
|
||||||
{
|
|
||||||
if (!PlayerHasKnife(player))
|
|
||||||
GiveKnifeToPlayer(player);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (Config.Additional.SkinVisibilityFix)
|
|
||||||
{
|
|
||||||
AddTimer(0.2f, () => NativeAPI.IssueClientCommand((int)player.EntityIndex!.Value.Value - 1, "slot3"));
|
|
||||||
AddTimer(0.3f, () => NativeAPI.IssueClientCommand((int)player.EntityIndex!.Value.Value - 1, "slot2"));
|
|
||||||
AddTimer(0.36f, () => NativeAPI.IssueClientCommand((int)player.EntityIndex!.Value.Value - 1, "slot1"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public bool PlayerHasKnife(CCSPlayerController? player)
|
|
||||||
{
|
|
||||||
if (!Config.Additional.KnifeEnabled) return false;
|
|
||||||
|
|
||||||
if (player == null || !player.IsValid || !player.PawnIsAlive)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var weapons = player.PlayerPawn.Value.WeaponServices!.MyWeapons;
|
|
||||||
if (weapons == null) return false;
|
|
||||||
foreach (var weapon in weapons)
|
|
||||||
{
|
|
||||||
if (weapon.IsValid && weapon.Value.IsValid)
|
|
||||||
{
|
|
||||||
if (weapon.Value.DesignerName.Contains("knife"))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
private void SetupMenus()
|
|
||||||
{
|
|
||||||
if (!Config.Additional.KnifeEnabled) return;
|
|
||||||
var giveItemMenu = new ChatMenu(ReplaceTags(Config.Messages.KnifeMenuTitle));
|
|
||||||
var handleGive = (CCSPlayerController player, ChatMenuOption option) =>
|
|
||||||
{
|
|
||||||
string temp = "";
|
|
||||||
if (knifeTypes.TryGetValue(option.Text, out var knife))
|
|
||||||
{
|
|
||||||
g_playersKnife[(int)player.EntityIndex!.Value.Value] = knifeTypes[option.Text];
|
|
||||||
if (!string.IsNullOrEmpty(Config.Messages.ChosenKnifeMenu))
|
|
||||||
{
|
|
||||||
temp = $"{Config.Prefix} {Config.Messages.ChosenKnifeMenu}".Replace("{KNIFE}", option.Text);
|
|
||||||
player.PrintToChat(ReplaceTags(temp));
|
|
||||||
}
|
|
||||||
if (!string.IsNullOrEmpty(Config.Messages.ChosenKnifeMenuKill) && Config.Additional.CommandKillEnabled)
|
|
||||||
{
|
|
||||||
temp = $"{Config.Prefix} {Config.Messages.ChosenKnifeMenuKill}";
|
|
||||||
player.PrintToChat(ReplaceTags(temp));
|
|
||||||
}
|
|
||||||
Task.Run(() => SyncKnifeToDatabase((int)player.EntityIndex!.Value.Value, knife));
|
|
||||||
RemoveKnifeFromPlayer(player);
|
|
||||||
AddTimer(0.1f, () => GiveKnifeToPlayer(player));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
foreach (var knife in knifeTypes)
|
|
||||||
{
|
|
||||||
giveItemMenu.AddMenuOption(knife.Key, handleGive);
|
|
||||||
}
|
|
||||||
AddCommand($"css_{Config.Additional.CommandKnife}", "Knife Menu", (player, info) => { if (player == null) return; ChatMenus.OpenMenu(player, giveItemMenu); });
|
|
||||||
}
|
|
||||||
// [ConsoleCommand($"css_{Config.Additional.CommandRefresh}", "refreshskins")]
|
|
||||||
public void OnCommandRefresh(CCSPlayerController? player, CommandInfo command)
|
|
||||||
{
|
|
||||||
if (!Config.Additional.CommandWpEnabled || !Config.Additional.SkinEnabled) return;
|
|
||||||
if (player == null) return;
|
|
||||||
string temp = "";
|
|
||||||
int playerIndex = (int)player.EntityIndex!.Value.Value;
|
|
||||||
if (commandCooldown != null && DateTime.UtcNow >= commandCooldown[playerIndex].AddSeconds(Config.CmdRefreshCooldownSeconds))
|
|
||||||
{
|
|
||||||
commandCooldown[playerIndex] = DateTime.UtcNow;
|
|
||||||
Task.Run(async () => await GetWeaponPaintsFromDatabase(playerIndex));
|
|
||||||
if (Config.Additional.KnifeEnabled)
|
|
||||||
{
|
|
||||||
Task.Run(async () => await GetKnifeFromDatabase(playerIndex));
|
|
||||||
RemoveKnifeFromPlayer(player);
|
|
||||||
AddTimer(0.2f, () => GiveKnifeToPlayer(player));
|
|
||||||
}
|
|
||||||
if (!string.IsNullOrEmpty(Config.Messages.SuccessRefreshCommand))
|
|
||||||
{
|
|
||||||
temp = $"{Config.Prefix} {Config.Messages.SuccessRefreshCommand}";
|
|
||||||
player.PrintToChat(ReplaceTags(temp));
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!string.IsNullOrEmpty(Config.Messages.CooldownRefreshCommand))
|
|
||||||
{
|
|
||||||
temp = $"{Config.Prefix} {Config.Messages.CooldownRefreshCommand}";
|
|
||||||
player.PrintToChat(ReplaceTags(temp));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// [ConsoleCommand($"css_{Config.Additional.CommandSkin}", "weaponskins")]
|
|
||||||
public void OnCommandWS(CCSPlayerController? player, CommandInfo command)
|
|
||||||
{
|
|
||||||
if (!Config.Additional.SkinEnabled) return;
|
|
||||||
if (player == null) return;
|
|
||||||
|
|
||||||
string temp = "";
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(Config.Messages.WebsiteMessageCommand))
|
|
||||||
{
|
|
||||||
temp = $"{Config.Prefix} {Config.Messages.WebsiteMessageCommand}";
|
|
||||||
player.PrintToChat(ReplaceTags(temp));
|
|
||||||
}
|
|
||||||
if (!string.IsNullOrEmpty(Config.Messages.SynchronizeMessageCommand))
|
|
||||||
{
|
|
||||||
temp = $"{Config.Prefix} {Config.Messages.SynchronizeMessageCommand}";
|
|
||||||
player.PrintToChat(ReplaceTags(temp));
|
|
||||||
}
|
|
||||||
if (!Config.Additional.KnifeEnabled) return;
|
|
||||||
if (!string.IsNullOrEmpty(Config.Messages.KnifeMessageCommand))
|
|
||||||
{
|
|
||||||
temp = $"{Config.Prefix} {Config.Messages.KnifeMessageCommand}";
|
|
||||||
player.PrintToChat(ReplaceTags(temp));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static CSkeletonInstance GetSkeletonInstance(CGameSceneNode node)
|
|
||||||
{
|
|
||||||
Func<nint, nint> GetSkeletonInstance = VirtualFunction.Create<nint, nint>(node.Handle, 8);
|
|
||||||
return new CSkeletonInstance(GetSkeletonInstance(node.Handle));
|
|
||||||
}
|
|
||||||
private async Task GetWeaponPaintsFromDatabase(int playerIndex)
|
|
||||||
{
|
|
||||||
if (!Config.Additional.SkinEnabled) return;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
CCSPlayerController player = Utilities.GetPlayerFromIndex(playerIndex);
|
|
||||||
if (player == null || !player.IsValid || player.IsBot) return;
|
|
||||||
var steamId = new SteamID(player.SteamID);
|
|
||||||
|
|
||||||
if (Config.GlobalShare)
|
|
||||||
{
|
|
||||||
var values = new Dictionary<string, string>
|
|
||||||
{
|
|
||||||
{ "server_id", GlobalShareServerId.ToString() },
|
|
||||||
{ "steamid", steamId.SteamId64.ToString() },
|
|
||||||
{ "skins", "1" }
|
|
||||||
};
|
|
||||||
UriBuilder builder = new UriBuilder(GlobalShareApi);
|
|
||||||
builder.Query = string.Join("&", values.Select(p => $"{Uri.EscapeDataString(p.Key)}={Uri.EscapeDataString(p.Value)}"));
|
|
||||||
|
|
||||||
using (var httpClient = new HttpClient())
|
|
||||||
{
|
|
||||||
httpClient.BaseAddress = GlobalShareApi;
|
|
||||||
var formContent = new FormUrlEncodedContent(values);
|
|
||||||
HttpResponseMessage response = await httpClient.GetAsync(builder.Uri);
|
|
||||||
|
|
||||||
if (response.IsSuccessStatusCode)
|
|
||||||
{
|
|
||||||
string responseBody = await response.Content.ReadAsStringAsync();
|
|
||||||
JArray jsonArray = JArray.Parse(responseBody);
|
|
||||||
if (jsonArray.Count > 0)
|
|
||||||
{
|
|
||||||
gPlayerWeaponPaints[steamId.SteamId64] = new Dictionary<nint, int>();
|
|
||||||
gPlayerWeaponWear[steamId.SteamId64] = new Dictionary<nint, float>();
|
|
||||||
gPlayerWeaponSeed[steamId.SteamId64] = new Dictionary<nint, int>();
|
|
||||||
|
|
||||||
foreach (var weapon in jsonArray)
|
|
||||||
{
|
|
||||||
int weaponDefIndex = weapon["weapon_defindex"].Value<int>();
|
|
||||||
int weaponPaintId = weapon["weapon_paint_id"].Value<int>();
|
|
||||||
float weaponWear = weapon["weapon_wear"].Value<float>();
|
|
||||||
int weaponSeed = weapon["weapon_seed"].Value<int>();
|
|
||||||
|
|
||||||
gPlayerWeaponPaints[steamId.SteamId64][weaponDefIndex] = weaponPaintId;
|
|
||||||
gPlayerWeaponWear[steamId.SteamId64][weaponDefIndex] = weaponWear;
|
|
||||||
gPlayerWeaponSeed[steamId.SteamId64][weaponDefIndex] = weaponSeed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
using (var connection = new MySqlConnection(DatabaseConnectionString))
|
|
||||||
{
|
|
||||||
await connection.OpenAsync();
|
|
||||||
|
|
||||||
string query = "SELECT * FROM `wp_player_skins` WHERE `steamid` = @steamid";
|
|
||||||
|
|
||||||
IEnumerable<dynamic> PlayerSkins = await connection.QueryAsync<dynamic>(query, new { steamid = steamId.SteamId64.ToString() });
|
|
||||||
|
|
||||||
if (PlayerSkins != null && PlayerSkins.AsList().Count > 0)
|
|
||||||
{
|
|
||||||
gPlayerWeaponPaints[steamId.SteamId64] = new Dictionary<nint, int>();
|
|
||||||
gPlayerWeaponWear[steamId.SteamId64] = new Dictionary<nint, float>();
|
|
||||||
gPlayerWeaponSeed[steamId.SteamId64] = new Dictionary<nint, int>();
|
|
||||||
|
|
||||||
PlayerSkins.ToList().ForEach(row =>
|
|
||||||
{
|
|
||||||
int weaponDefIndex = row.weapon_defindex ?? default(int);
|
|
||||||
int weaponPaintId = row.weapon_paint_id ?? default(int);
|
|
||||||
float weaponWear = row.weapon_wear ?? default(float);
|
|
||||||
int weaponSeed = row.weapon_seed ?? default(int);
|
|
||||||
|
|
||||||
gPlayerWeaponPaints[steamId.SteamId64][weaponDefIndex] = weaponPaintId;
|
|
||||||
gPlayerWeaponWear[steamId.SteamId64][weaponDefIndex] = weaponWear;
|
|
||||||
gPlayerWeaponSeed[steamId.SteamId64][weaponDefIndex] = weaponSeed;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Log(e.Message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private async Task GetKnifeFromDatabase(int playerIndex)
|
|
||||||
{
|
|
||||||
if (!Config.Additional.KnifeEnabled) return;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
CCSPlayerController player = Utilities.GetPlayerFromIndex(playerIndex);
|
|
||||||
if (player == null || !player.IsValid || player.IsBot) return;
|
|
||||||
var steamId = new SteamID(player.SteamID);
|
|
||||||
|
|
||||||
if (Config.GlobalShare)
|
|
||||||
{
|
|
||||||
var values = new Dictionary<string, string>
|
|
||||||
{
|
|
||||||
{ "server_id", GlobalShareServerId.ToString() },
|
|
||||||
{ "steamid", steamId.SteamId64.ToString() },
|
|
||||||
{ "knife", "1" }
|
|
||||||
};
|
|
||||||
UriBuilder builder = new UriBuilder(GlobalShareApi);
|
|
||||||
builder.Query = string.Join("&", values.Select(p => $"{Uri.EscapeDataString(p.Key)}={Uri.EscapeDataString(p.Value)}"));
|
|
||||||
|
|
||||||
using (var httpClient = new HttpClient())
|
|
||||||
{
|
|
||||||
httpClient.BaseAddress = GlobalShareApi;
|
|
||||||
var formContent = new FormUrlEncodedContent(values);
|
|
||||||
HttpResponseMessage response = await httpClient.GetAsync(builder.Uri);
|
|
||||||
|
|
||||||
if (response.IsSuccessStatusCode)
|
|
||||||
{
|
|
||||||
string result = await response.Content.ReadAsStringAsync();
|
|
||||||
if (!string.IsNullOrEmpty(result))
|
|
||||||
{
|
|
||||||
g_playersKnife[playerIndex] = result;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
using (var connection = new MySqlConnection(DatabaseConnectionString))
|
|
||||||
{
|
|
||||||
await connection.OpenAsync();
|
|
||||||
string query = "SELECT `knife` FROM `wp_player_knife` WHERE `steamid` = @steamid";
|
|
||||||
string? PlayerKnife = await connection.QueryFirstOrDefaultAsync<string>(query, new { steamid = steamId.SteamId64.ToString() });
|
|
||||||
|
|
||||||
if (PlayerKnife != null)
|
|
||||||
{
|
|
||||||
g_playersKnife[playerIndex] = PlayerKnife;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//Log($"{player.PlayerName} has this knife -> {g_playersKnife[playerIndex]}");
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Log(e.Message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private async Task SyncKnifeToDatabase(int playerIndex, string knife)
|
|
||||||
{
|
|
||||||
if (!Config.Additional.KnifeEnabled) return;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
CCSPlayerController player = Utilities.GetPlayerFromIndex(playerIndex);
|
|
||||||
if (player == null || !player.IsValid) return;
|
|
||||||
var steamId = new SteamID(player.SteamID);
|
|
||||||
|
|
||||||
using var connection = new MySqlConnection(DatabaseConnectionString);
|
|
||||||
await connection.OpenAsync();
|
|
||||||
string query = "INSERT INTO `wp_player_knife` (`steamid`, `knife`) VALUES(@steamid, @newKnife) ON DUPLICATE KEY UPDATE `knife` = @newKnife";
|
|
||||||
await connection.ExecuteAsync(query, new { steamid = steamId.SteamId64.ToString(), newKnife = knife });
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Log(e.Message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private string ReplaceTags(string message)
|
|
||||||
{
|
|
||||||
if (message.Contains('{'))
|
|
||||||
{
|
|
||||||
string modifiedValue = message;
|
|
||||||
modifiedValue = modifiedValue.Replace("{WEBSITE}", Config.Website);
|
|
||||||
foreach (FieldInfo field in typeof(ChatColors).GetFields())
|
|
||||||
{
|
|
||||||
string pattern = $"{{{field.Name}}}";
|
|
||||||
if (message.Contains(pattern, StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
modifiedValue = modifiedValue.Replace(pattern, field.GetValue(null)!.ToString(), StringComparison.OrdinalIgnoreCase);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return modifiedValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void Log(string message)
|
|
||||||
{
|
|
||||||
Console.BackgroundColor = ConsoleColor.DarkGray;
|
|
||||||
Console.ForegroundColor = ConsoleColor.Cyan;
|
|
||||||
Console.WriteLine(message);
|
|
||||||
Console.ResetColor();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -5,19 +5,21 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CounterStrikeSharp.API" Version="*" />
|
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.179" />
|
||||||
<PackageReference Include="Dapper" Version="2.1.21" />
|
<PackageReference Include="Dapper" Version="2.1.28" />
|
||||||
<PackageReference Include="MySqlConnector" Version="2.3.1" />
|
<PackageReference Include="MySqlConnector" Version="2.3.5" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="CounterStrikeSharp.API">
|
<None Update="lang\**\*.*" CopyToOutputDirectory="PreserveNewest" />
|
||||||
<HintPath>deps\CounterStrikeSharp.API.dll</HintPath>
|
</ItemGroup>
|
||||||
</Reference>
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Update="gamedata\*.*" CopyToOutputDirectory="PreserveNewest" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
179
WeaponSynchronization.cs
Normal file
@@ -0,0 +1,179 @@
|
|||||||
|
using Dapper;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
|
||||||
|
namespace WeaponPaints
|
||||||
|
{
|
||||||
|
internal class WeaponSynchronization
|
||||||
|
{
|
||||||
|
private readonly WeaponPaintsConfig _config;
|
||||||
|
private readonly Database _database;
|
||||||
|
|
||||||
|
internal WeaponSynchronization(Database database, WeaponPaintsConfig config)
|
||||||
|
{
|
||||||
|
_database = database;
|
||||||
|
_config = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task GetKnifeFromDatabase(PlayerInfo player)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!_config.Additional.KnifeEnabled || string.IsNullOrEmpty(player?.SteamId))
|
||||||
|
return;
|
||||||
|
|
||||||
|
await using var connection = await _database.GetConnectionAsync();
|
||||||
|
string query = "SELECT `knife` FROM `wp_player_knife` WHERE `steamid` = @steamid";
|
||||||
|
string? playerKnife = await connection.QueryFirstOrDefaultAsync<string>(query, new { steamid = player.SteamId });
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(playerKnife))
|
||||||
|
{
|
||||||
|
WeaponPaints.g_playersKnife[player.Slot] = playerKnife;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Utility.Log($"An error occurred in GetKnifeFromDatabase: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task GetGloveFromDatabase(PlayerInfo player)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!_config.Additional.GloveEnabled || string.IsNullOrEmpty(player?.SteamId))
|
||||||
|
return;
|
||||||
|
|
||||||
|
await using var connection = await _database.GetConnectionAsync();
|
||||||
|
string query = "SELECT `weapon_defindex` FROM `wp_player_gloves` WHERE `steamid` = @steamid";
|
||||||
|
ushort? gloveData = await connection.QueryFirstOrDefaultAsync<ushort?>(query, new { steamid = player.SteamId });
|
||||||
|
|
||||||
|
if (gloveData != null)
|
||||||
|
{
|
||||||
|
WeaponPaints.g_playersGlove[player.Slot] = gloveData.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Utility.Log($"An error occurred in GetGloveFromDatabase: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task GetWeaponPaintsFromDatabase(PlayerInfo player)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!_config.Additional.SkinEnabled || player == null || string.IsNullOrEmpty(player.SteamId))
|
||||||
|
return;
|
||||||
|
|
||||||
|
await using var connection = await _database.GetConnectionAsync();
|
||||||
|
string query = "SELECT * FROM `wp_player_skins` WHERE `steamid` = @steamid";
|
||||||
|
var playerSkins = await connection.QueryAsync<dynamic>(query, new { steamid = player.SteamId });
|
||||||
|
|
||||||
|
if (playerSkins == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var weaponInfos = new ConcurrentDictionary<int, WeaponInfo>();
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
WeaponInfo weaponInfo = new WeaponInfo
|
||||||
|
{
|
||||||
|
Paint = weaponPaintId,
|
||||||
|
Seed = weaponSeed,
|
||||||
|
Wear = weaponWear
|
||||||
|
};
|
||||||
|
|
||||||
|
weaponInfos[weaponDefIndex] = weaponInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
WeaponPaints.gPlayerWeaponsInfo[player.Slot] = weaponInfos;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Utility.Log($"An error occurred in GetWeaponPaintsFromDatabase: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal async Task SyncKnifeToDatabase(PlayerInfo player, string knife)
|
||||||
|
{
|
||||||
|
if (!_config.Additional.KnifeEnabled || player == null || string.IsNullOrEmpty(player.SteamId) || string.IsNullOrEmpty(knife)) return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await using var connection = await _database.GetConnectionAsync();
|
||||||
|
string query = "INSERT INTO `wp_player_knife` (`steamid`, `knife`) VALUES(@steamid, @newKnife) ON DUPLICATE KEY UPDATE `knife` = @newKnife";
|
||||||
|
await connection.ExecuteAsync(query, new { steamid = player.SteamId, newKnife = knife });
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Utility.Log($"Error syncing knife to database: {e.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal async Task SyncGloveToDatabase(PlayerInfo player, int defindex)
|
||||||
|
{
|
||||||
|
if (!_config.Additional.GloveEnabled || player == null || string.IsNullOrEmpty(player.SteamId)) return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await using var connection = await _database.GetConnectionAsync();
|
||||||
|
string query = "INSERT INTO `wp_player_gloves` (`steamid`, `weapon_defindex`) VALUES(@steamid, @weapon_defindex) ON DUPLICATE KEY UPDATE `weapon_defindex` = @weapon_defindex";
|
||||||
|
await connection.ExecuteAsync(query, new { steamid = player.SteamId, weapon_defindex = defindex });
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Utility.Log($"Error syncing glove to database: {e.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal async Task SyncWeaponPaintsToDatabase(PlayerInfo player)
|
||||||
|
{
|
||||||
|
if (player == null || string.IsNullOrEmpty(player.SteamId) || !WeaponPaints.gPlayerWeaponsInfo.TryGetValue(player.Slot, out var weaponsInfo))
|
||||||
|
return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await using var connection = await _database.GetConnectionAsync();
|
||||||
|
|
||||||
|
foreach (var weaponInfoPair in weaponsInfo)
|
||||||
|
{
|
||||||
|
int weaponDefIndex = weaponInfoPair.Key;
|
||||||
|
WeaponInfo weaponInfo = weaponInfoPair.Value;
|
||||||
|
|
||||||
|
int paintId = weaponInfo.Paint;
|
||||||
|
float wear = weaponInfo.Wear;
|
||||||
|
int seed = weaponInfo.Seed;
|
||||||
|
|
||||||
|
string queryCheckExistence = "SELECT COUNT(*) FROM `wp_player_skins` WHERE `steamid` = @steamid AND `weapon_defindex` = @weaponDefIndex";
|
||||||
|
|
||||||
|
int existingRecordCount = await connection.ExecuteScalarAsync<int>(queryCheckExistence, new { steamid = player.SteamId, weaponDefIndex });
|
||||||
|
|
||||||
|
string query;
|
||||||
|
object parameters;
|
||||||
|
if (existingRecordCount > 0)
|
||||||
|
{
|
||||||
|
query = "UPDATE `wp_player_skins` SET `weapon_paint_id` = @paintId, `weapon_wear` = @wear, `weapon_seed` = @seed WHERE `steamid` = @steamid AND `weapon_defindex` = @weaponDefIndex";
|
||||||
|
parameters = new { steamid = player.SteamId, weaponDefIndex, paintId, wear, seed };
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
query = "INSERT INTO `wp_player_skins` (`steamid`, `weapon_defindex`, `weapon_paint_id`, `weapon_wear`, `weapon_seed`) " +
|
||||||
|
"VALUES (@steamid, @weaponDefIndex, @paintId, @wear, @seed)";
|
||||||
|
parameters = new { steamid = player.SteamId, weaponDefIndex, paintId, wear, seed };
|
||||||
|
}
|
||||||
|
|
||||||
|
await connection.ExecuteAsync(query, parameters);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Utility.Log($"Error syncing weapon paints to database: {e.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
23
gamedata/weaponpaints.json
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"ChangeSubclass": {
|
||||||
|
"signatures": {
|
||||||
|
"library": "server",
|
||||||
|
"windows": "\\x48\\x89\\x5C\\x24\\x08\\x57\\x48\\x83\\xEC\\x20\\x48\\x8B\\xDA\\x48\\x8B\\xF9\\xE8\\x2A\\x2A\\x2A\\x2A\\x84\\xC0\\x74\\x2A\\x41\\xB0\\x01",
|
||||||
|
"linux": "\\x55\\x48\\x89\\xE5\\x41\\x57\\x41\\x56\\x41\\x55\\x49\\x89\\xF5\\x41\\x54\\x49\\x89\\xFC\\x53\\x48\\x81\\xEC\\xA8\\x00\\x00\\x00"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"CAttributeList_SetOrAddAttributeValueByName": {
|
||||||
|
"signatures": {
|
||||||
|
"library": "server",
|
||||||
|
"windows": "\\x40\\x53\\x41\\x56\\x41\\x57\\x48\\x81\\xEC\\x90\\x00\\x00\\x00\\x0F\\x29\\x74\\x24\\x70",
|
||||||
|
"linux": "\\x55\\x48\\x89\\xE5\\x41\\x57\\x41\\x56\\x49\\x89\\xFE\\x41\\x55\\x41\\x54\\x49\\x89\\xF4\\x53\\x48\\x83\\xEC\\x78"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"CBaseModelEntity_SetBodygroup": {
|
||||||
|
"signatures": {
|
||||||
|
"library": "server",
|
||||||
|
"windows": "\\x48\\x89\\x5C\\x24\\x08\\x48\\x89\\x74\\x24\\x10\\x57\\x48\\x83\\xEC\\x20\\x41\\x8B\\xF8\\x48\\x8B\\xF2\\x48\\x8B\\xD9\\xE8\\x2A\\x2A\\x2A\\x2A",
|
||||||
|
"linux": "\\x55\\x48\\x89\\xE5\\x41\\x56\\x49\\x89\\xF6\\x41\\x55\\x41\\x89\\xD5\\x41\\x54\\x49\\x89\\xFC\\x48\\x83\\xEC\\x08"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
17
lang/en.json
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"wp_prefix": "{lightblue}[WeaponPaints] {default}",
|
||||||
|
"wp_info_website": "Visit {lime}{0}{default} where you can change skins",
|
||||||
|
"wp_info_refresh": "Type {lime}!wp{default} to synchronize chosen skins",
|
||||||
|
"wp_info_knife": "Type {lime}!knife{default} to open knife menu",
|
||||||
|
"wp_info_glove": "Type {lime}!gloves{default} to open gloves menu",
|
||||||
|
"wp_command_cooldown": "{lightred}You can't refresh weapon paints right now",
|
||||||
|
"wp_command_refresh_done": "{lime}Refreshing weapon paints",
|
||||||
|
"wp_knife_menu_select": "You have chosen {lime}{0}{default} as your knife",
|
||||||
|
"wp_knife_menu_kill": "",
|
||||||
|
"wp_knife_menu_title": "Knife Menu",
|
||||||
|
"wp_glove_menu_select": "You have chosen {lime}{0}{default} as your glove",
|
||||||
|
"wp_glove_menu_title": "Gloves Menu",
|
||||||
|
"wp_skin_menu_weapon_title": "Weapon Menu",
|
||||||
|
"wp_skin_menu_skin_title": "Select skin for {lime}{0}{default}",
|
||||||
|
"wp_skin_menu_select": "You have chosen {lime}{0}{default} as your skin"
|
||||||
|
}
|
||||||
17
lang/lv.json
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"wp_prefix": "{lightblue}[WeaponPaints] {default}",
|
||||||
|
"wp_info_website": "Apmeklējiet {lime}{0}{default}, kur varat mainīt ādas",
|
||||||
|
"wp_info_refresh": "Ievadiet {lime}!wp{default}, lai sinhronizētu izvēlētās ādas",
|
||||||
|
"wp_info_knife": "Ievadiet {lime}!knife{default}, lai atvērtu nazis izvēlni",
|
||||||
|
"wp_info_glove": "Ievadiet {lime}!gloves{default}, lai atvērtu cimdi izvēlni",
|
||||||
|
"wp_command_cooldown": "{lightred}Šobrīd jūs nevarat atjaunot ieroču ādas",
|
||||||
|
"wp_command_refresh_done": "{lime}Atjauno ieroču ādas",
|
||||||
|
"wp_knife_menu_select": "Jūs esat izvēlējies {lime}{0}{default} kā savu nazi",
|
||||||
|
"wp_knife_menu_kill": "",
|
||||||
|
"wp_knife_menu_title": "Nazis Izvēlne",
|
||||||
|
"wp_glove_menu_select": "Jūs esat izvēlējies {lime}{0}{default} kā savus cimdus",
|
||||||
|
"wp_glove_menu_title": "Cimdu Izvēlne",
|
||||||
|
"wp_skin_menu_weapon_title": "Ieroču Izvēlne",
|
||||||
|
"wp_skin_menu_skin_title": "Izvēlieties ādu {lime}{0}{default}",
|
||||||
|
"wp_skin_menu_select": "Jūs esat izvēlējies {lime}{0}{default} kā savu ādu"
|
||||||
|
}
|
||||||
17
lang/pl.json
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"wp_prefix": "{lightblue}[WeaponPaints] {default}",
|
||||||
|
"wp_info_website": "Odwiedź {lime}{0}{default}, gdzie możesz zmieniać skórki",
|
||||||
|
"wp_info_refresh": "Wpisz {lime}!wp{default}, aby zsynchronizować wybrane skórki",
|
||||||
|
"wp_info_knife": "Wpisz {lime}!knife{default}, aby otworzyć menu noży",
|
||||||
|
"wp_info_glove": "Wpisz {lime}!gloves{default}, aby otworzyć menu rękawiczek",
|
||||||
|
"wp_command_cooldown": "{lightred}Nie możesz teraz odświeżyć skórek broni",
|
||||||
|
"wp_command_refresh_done": "{lime}Odświeżanie skórek broni",
|
||||||
|
"wp_knife_menu_select": "Wybrałeś {lime}{0}{default} jako swój nóż",
|
||||||
|
"wp_knife_menu_kill": "{lime}Wybrane skiny będą ustawione dopiero po ponownym wejściu na serwer lub wpisaniu komendy {orange}!kill",
|
||||||
|
"wp_knife_menu_title": "Menu Noży",
|
||||||
|
"wp_glove_menu_select": "Wybrałeś {lime}{0}{default} jako swoje rękawiczki",
|
||||||
|
"wp_glove_menu_title": "Menu Rękawiczek",
|
||||||
|
"wp_skin_menu_weapon_title": "Menu Broni",
|
||||||
|
"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ę"
|
||||||
|
}
|
||||||
17
lang/pt-BR.json
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"wp_prefix": "{lightblue}[WeaponPaints] {default}",
|
||||||
|
"wp_info_website": "Visite {lime}{0}{default}, onde você pode alterar skins",
|
||||||
|
"wp_info_refresh": "Digite {lime}!wp{default} para sincronizar as skins selecionadas",
|
||||||
|
"wp_info_knife": "Digite {lime}!knife{default} para abrir o menu de facas",
|
||||||
|
"wp_info_glove": "Digite {lime}!gloves{default} para abrir o menu de luvas",
|
||||||
|
"wp_command_cooldown": "{lightred}Você não pode atualizar as skins de arma agora",
|
||||||
|
"wp_command_refresh_done": "{lime}Atualizando as skins de arma",
|
||||||
|
"wp_knife_menu_select": "Você escolheu {lime}{0}{default} como sua faca",
|
||||||
|
"wp_knife_menu_kill": "",
|
||||||
|
"wp_knife_menu_title": "Menu de Facas",
|
||||||
|
"wp_glove_menu_select": "Você escolheu {lime}{0}{default} como suas luvas",
|
||||||
|
"wp_glove_menu_title": "Menu de Luvas",
|
||||||
|
"wp_skin_menu_weapon_title": "Menu de Armas",
|
||||||
|
"wp_skin_menu_skin_title": "Selecione uma skin para {lime}{0}{default}",
|
||||||
|
"wp_skin_menu_select": "Você escolheu {lime}{0}{default} como sua skin"
|
||||||
|
}
|
||||||
17
lang/pt-PT.json
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"wp_prefix": "{lightblue}[WeaponPaints] {default}",
|
||||||
|
"wp_info_website": "Visite {lime}{0}{default}, onde pode alterar skins",
|
||||||
|
"wp_info_refresh": "Digite {lime}!wp{default} para sincronizar as skins selecionadas",
|
||||||
|
"wp_info_knife": "Digite {lime}!knife{default} para abrir o menu de facas",
|
||||||
|
"wp_info_glove": "Digite {lime}!gloves{default} para abrir o menu de luvas",
|
||||||
|
"wp_command_cooldown": "{lightred}Você não pode atualizar as skins de arma agora",
|
||||||
|
"wp_command_refresh_done": "{lime}Atualizando as skins de arma",
|
||||||
|
"wp_knife_menu_select": "Você escolheu {lime}{0}{default} como sua faca",
|
||||||
|
"wp_knife_menu_kill": "",
|
||||||
|
"wp_knife_menu_title": "Menu de Facas",
|
||||||
|
"wp_glove_menu_select": "Você escolheu {lime}{0}{default} como suas luvas",
|
||||||
|
"wp_glove_menu_title": "Menu de Luvas",
|
||||||
|
"wp_skin_menu_weapon_title": "Menu de Armas",
|
||||||
|
"wp_skin_menu_skin_title": "Selecione uma skin para {lime}{0}{default}",
|
||||||
|
"wp_skin_menu_select": "Você escolheu {lime}{0}{default} como sua skin"
|
||||||
|
}
|
||||||
17
lang/ru.json
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"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_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_skin_menu_weapon_title": "Меню Оружия",
|
||||||
|
"wp_skin_menu_skin_title": "Выберите скин для {lime}{0}{default}",
|
||||||
|
"wp_skin_menu_select": "Вы выбрали {lime}{0}{default} в качестве вашего скина"
|
||||||
|
}
|
||||||
17
lang/tr.json
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"wp_prefix": "{lightblue}[WeaponPaints] {default}",
|
||||||
|
"wp_info_website": "Ziyaret edin {lime}{0}{default}, burada skinleri değiştirebilirsiniz",
|
||||||
|
"wp_info_refresh": "Senkronize edilen skinleri görmek için {lime}!wp{default} yazın",
|
||||||
|
"wp_info_knife": "Bıçak menüsünü açmak için {lime}!knife{default} yazın",
|
||||||
|
"wp_info_glove": "Eldiven menüsünü açmak için {lime}!gloves{default} yazın",
|
||||||
|
"wp_command_cooldown": "{lightred}Şu anda silah skinlerini yenileyemezsiniz",
|
||||||
|
"wp_command_refresh_done": "{lime}Silah skinleri yenileniyor",
|
||||||
|
"wp_knife_menu_select": "{lime}{0}{default} olarak bıçağınızı seçtiniz",
|
||||||
|
"wp_knife_menu_kill": "",
|
||||||
|
"wp_knife_menu_title": "Bıçak Menüsü",
|
||||||
|
"wp_glove_menu_select": "{lime}{0}{default} olarak eldiveninizi seçtiniz",
|
||||||
|
"wp_glove_menu_title": "Eldiven Menüsü",
|
||||||
|
"wp_skin_menu_weapon_title": "Silah Menüsü",
|
||||||
|
"wp_skin_menu_skin_title": "{lime}{0}{default} için bir skin seçin",
|
||||||
|
"wp_skin_menu_select": "{lime}{0}{default} olarak bir skin seçtiniz"
|
||||||
|
}
|
||||||
17
lang/ua.json
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"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_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_skin_menu_weapon_title": "Меню Зброї",
|
||||||
|
"wp_skin_menu_skin_title": "Виберіть шкіру для {lime}{0}{default}",
|
||||||
|
"wp_skin_menu_select": "Ви вибрали {lime}{0}{default} як вашу шкіру"
|
||||||
|
}
|
||||||
17
lang/zh-cn.json
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"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_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_skin_menu_weapon_title": "武器菜单",
|
||||||
|
"wp_skin_menu_skin_title": "为 {lime}{0}{default} 选择皮肤",
|
||||||
|
"wp_skin_menu_select": "您已选择 {lime}{0}{default} 作为您的皮肤"
|
||||||
|
}
|
||||||
@@ -5,6 +5,8 @@ define('DB_NAME', '');
|
|||||||
define('DB_USER', '');
|
define('DB_USER', '');
|
||||||
define('DB_PASS', '');
|
define('DB_PASS', '');
|
||||||
|
|
||||||
|
define('WEB_STYLE_DARK', true);
|
||||||
|
|
||||||
define('STEAM_API_KEY', '');
|
define('STEAM_API_KEY', '');
|
||||||
define('STEAM_DOMAIN_NAME', '');
|
define('STEAM_DOMAIN_NAME', '');
|
||||||
define('STEAM_LOGOUT_PAGE', '');
|
define('STEAM_LOGOUT_PAGE', '');
|
||||||
|
|||||||
@@ -4,7 +4,14 @@ class DataBase {
|
|||||||
private $PDO;
|
private $PDO;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->PDO = new PDO("mysql:host=".DB_HOST."; port=".DB_PORT."; dbname=".DB_NAME, DB_USER, DB_PASS, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
|
try {
|
||||||
|
$this->PDO = new PDO("mysql:host=".DB_HOST."; port=".DB_PORT."; dbname=".DB_NAME, DB_USER, DB_PASS, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
|
||||||
|
}
|
||||||
|
catch(PDOException $ex)
|
||||||
|
{
|
||||||
|
echo "<div style='display: flex; flex-direction: column;align-items: center;justify-content: center;text-align: center;'><h2>Problem with database!</h2>";
|
||||||
|
die("<pre style='padding: 10px;text-wrap: balance; border: 2px solid #ed6bd3;background: #252525; color: #ed6bd3; width: 50%;'>" . $ex . "</pre>");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public function select($query, $bindings = []) {
|
public function select($query, $bindings = []) {
|
||||||
$STH = $this->PDO->prepare($query);
|
$STH = $this->PDO->prepare($query);
|
||||||
|
|||||||
@@ -62,7 +62,8 @@ class UtilsClass
|
|||||||
521,
|
521,
|
||||||
522,
|
522,
|
||||||
523,
|
523,
|
||||||
525
|
525,
|
||||||
|
526
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
continue;
|
continue;
|
||||||
@@ -88,7 +89,11 @@ class UtilsClass
|
|||||||
$selected = [];
|
$selected = [];
|
||||||
|
|
||||||
foreach ($temp as $weapon) {
|
foreach ($temp as $weapon) {
|
||||||
$selected[$weapon['weapon_defindex']] = $weapon['weapon_paint_id'];
|
$selected[$weapon['weapon_defindex']] = [
|
||||||
|
'weapon_paint_id' => $weapon['weapon_paint_id'],
|
||||||
|
'weapon_seed' => $weapon['weapon_seed'],
|
||||||
|
'weapon_wear' => $weapon['weapon_wear'],
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $selected;
|
return $selected;
|
||||||
|
|||||||
434
website/data/gloves.json
Normal file
@@ -0,0 +1,434 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"weapon_defindex": 4725,
|
||||||
|
"paint": "10085",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/studded_brokenfang_gloves-10085.png",
|
||||||
|
"paint_name": "★ Broken Fang Gloves | Jade"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 4725,
|
||||||
|
"paint": "10086",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/studded_brokenfang_gloves-10086.png",
|
||||||
|
"paint_name": "★ Broken Fang Gloves | Yellow-banded"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 4725,
|
||||||
|
"paint": "10087",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/studded_brokenfang_gloves-10087.png",
|
||||||
|
"paint_name": "★ Broken Fang Gloves | Needle Point"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 4725,
|
||||||
|
"paint": "10088",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/studded_brokenfang_gloves-10088.png",
|
||||||
|
"paint_name": "★ Broken Fang Gloves | Unhinged"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5027,
|
||||||
|
"paint": "10006",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/studded_bloodhound_gloves-10006.png",
|
||||||
|
"paint_name": "★ Bloodhound Gloves | Charred"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5027,
|
||||||
|
"paint": "10007",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/studded_bloodhound_gloves-10007.png",
|
||||||
|
"paint_name": "★ Bloodhound Gloves | Snakebite"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5027,
|
||||||
|
"paint": "10008",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/studded_bloodhound_gloves-10008.png",
|
||||||
|
"paint_name": "★ Bloodhound Gloves | Bronzed"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5027,
|
||||||
|
"paint": "10039",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/studded_bloodhound_gloves-10039.png",
|
||||||
|
"paint_name": "★ Bloodhound Gloves | Guerrilla"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5030,
|
||||||
|
"paint": "10018",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/sporty_gloves-10018.png",
|
||||||
|
"paint_name": "★ Sport Gloves | Superconductor"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5030,
|
||||||
|
"paint": "10019",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/sporty_gloves-10019.png",
|
||||||
|
"paint_name": "★ Sport Gloves | Arid"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5030,
|
||||||
|
"paint": "10037",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/sporty_gloves-10037.png",
|
||||||
|
"paint_name": "★ Sport Gloves | Pandora's Box"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5030,
|
||||||
|
"paint": "10038",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/sporty_gloves-10038.png",
|
||||||
|
"paint_name": "★ Sport Gloves | Hedge Maze"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5030,
|
||||||
|
"paint": "10045",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/sporty_gloves-10045.png",
|
||||||
|
"paint_name": "★ Sport Gloves | Amphibious"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5030,
|
||||||
|
"paint": "10046",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/sporty_gloves-10046.png",
|
||||||
|
"paint_name": "★ Sport Gloves | Bronze Morph"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5030,
|
||||||
|
"paint": "10047",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/sporty_gloves-10047.png",
|
||||||
|
"paint_name": "★ Sport Gloves | Omega"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5030,
|
||||||
|
"paint": "10048",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/sporty_gloves-10048.png",
|
||||||
|
"paint_name": "★ Sport Gloves | Vice"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5030,
|
||||||
|
"paint": "10073",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/sporty_gloves-10073.png",
|
||||||
|
"paint_name": "★ Sport Gloves | Slingshot"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5030,
|
||||||
|
"paint": "10074",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/sporty_gloves-10074.png",
|
||||||
|
"paint_name": "★ Sport Gloves | Big Game"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5030,
|
||||||
|
"paint": "10075",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/sporty_gloves-10075.png",
|
||||||
|
"paint_name": "★ Sport Gloves | Scarlet Shamagh"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5030,
|
||||||
|
"paint": "10076",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/sporty_gloves-10076.png",
|
||||||
|
"paint_name": "★ Sport Gloves | Nocts"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5031,
|
||||||
|
"paint": "10013",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/slick_gloves-10013.png",
|
||||||
|
"paint_name": "★ Driver Gloves | Lunar Weave"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5031,
|
||||||
|
"paint": "10015",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/slick_gloves-10015.png",
|
||||||
|
"paint_name": "★ Driver Gloves | Convoy"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5031,
|
||||||
|
"paint": "10016",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/slick_gloves-10016.png",
|
||||||
|
"paint_name": "★ Driver Gloves | Crimson Weave"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5031,
|
||||||
|
"paint": "10040",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/slick_gloves-10040.png",
|
||||||
|
"paint_name": "★ Driver Gloves | Diamondback"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5031,
|
||||||
|
"paint": "10041",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/slick_gloves-10041.png",
|
||||||
|
"paint_name": "★ Driver Gloves | King Snake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5031,
|
||||||
|
"paint": "10042",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/slick_gloves-10042.png",
|
||||||
|
"paint_name": "★ Driver Gloves | Imperial Plaid"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5031,
|
||||||
|
"paint": "10043",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/slick_gloves-10043.png",
|
||||||
|
"paint_name": "★ Driver Gloves | Overtake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5031,
|
||||||
|
"paint": "10044",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/slick_gloves-10044.png",
|
||||||
|
"paint_name": "★ Driver Gloves | Racing Green"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5031,
|
||||||
|
"paint": "10069",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/slick_gloves-10069.png",
|
||||||
|
"paint_name": "★ Driver Gloves | Rezan the Red"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5031,
|
||||||
|
"paint": "10070",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/slick_gloves-10070.png",
|
||||||
|
"paint_name": "★ Driver Gloves | Snow Leopard"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5031,
|
||||||
|
"paint": "10071",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/slick_gloves-10071.png",
|
||||||
|
"paint_name": "★ Driver Gloves | Queen Jaguar"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5031,
|
||||||
|
"paint": "10072",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/slick_gloves-10072.png",
|
||||||
|
"paint_name": "★ Driver Gloves | Black Tie"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5032,
|
||||||
|
"paint": "10009",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/leather_handwraps-10009.png",
|
||||||
|
"paint_name": "★ Hand Wraps | Leather"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5032,
|
||||||
|
"paint": "10010",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/leather_handwraps-10010.png",
|
||||||
|
"paint_name": "★ Hand Wraps | Spruce DDPAT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5032,
|
||||||
|
"paint": "10021",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/leather_handwraps-10021.png",
|
||||||
|
"paint_name": "★ Hand Wraps | Slaughter"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5032,
|
||||||
|
"paint": "10036",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/leather_handwraps-10036.png",
|
||||||
|
"paint_name": "★ Hand Wraps | Badlands"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5032,
|
||||||
|
"paint": "10053",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/leather_handwraps-10053.png",
|
||||||
|
"paint_name": "★ Hand Wraps | Cobalt Skulls"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5032,
|
||||||
|
"paint": "10054",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/leather_handwraps-10054.png",
|
||||||
|
"paint_name": "★ Hand Wraps | Overprint"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5032,
|
||||||
|
"paint": "10055",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/leather_handwraps-10055.png",
|
||||||
|
"paint_name": "★ Hand Wraps | Duct Tape"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5032,
|
||||||
|
"paint": "10056",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/leather_handwraps-10056.png",
|
||||||
|
"paint_name": "★ Hand Wraps | Arboreal"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5032,
|
||||||
|
"paint": "10081",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/leather_handwraps-10081.png",
|
||||||
|
"paint_name": "★ Hand Wraps | Desert Shamagh"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5032,
|
||||||
|
"paint": "10082",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/leather_handwraps-10082.png",
|
||||||
|
"paint_name": "★ Hand Wraps | Giraffe"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5032,
|
||||||
|
"paint": "10083",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/leather_handwraps-10083.png",
|
||||||
|
"paint_name": "★ Hand Wraps | Constrictor"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5032,
|
||||||
|
"paint": "10084",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/leather_handwraps-10084.png",
|
||||||
|
"paint_name": "★ Hand Wraps | CAUTION!"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5033,
|
||||||
|
"paint": "10024",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/motorcycle_gloves-10024.png",
|
||||||
|
"paint_name": "★ Moto Gloves | Eclipse"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5033,
|
||||||
|
"paint": "10026",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/motorcycle_gloves-10026.png",
|
||||||
|
"paint_name": "★ Moto Gloves | Spearmint"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5033,
|
||||||
|
"paint": "10027",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/motorcycle_gloves-10027.png",
|
||||||
|
"paint_name": "★ Moto Gloves | Boom!"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5033,
|
||||||
|
"paint": "10028",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/motorcycle_gloves-10028.png",
|
||||||
|
"paint_name": "★ Moto Gloves | Cool Mint"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5033,
|
||||||
|
"paint": "10049",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/motorcycle_gloves-10049.png",
|
||||||
|
"paint_name": "★ Moto Gloves | POW!"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5033,
|
||||||
|
"paint": "10050",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/motorcycle_gloves-10050.png",
|
||||||
|
"paint_name": "★ Moto Gloves | Turtle"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5033,
|
||||||
|
"paint": "10051",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/motorcycle_gloves-10051.png",
|
||||||
|
"paint_name": "★ Moto Gloves | Transport"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5033,
|
||||||
|
"paint": "10052",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/motorcycle_gloves-10052.png",
|
||||||
|
"paint_name": "★ Moto Gloves | Polygon"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5033,
|
||||||
|
"paint": "10077",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/motorcycle_gloves-10077.png",
|
||||||
|
"paint_name": "★ Moto Gloves | Finish Line"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5033,
|
||||||
|
"paint": "10078",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/motorcycle_gloves-10078.png",
|
||||||
|
"paint_name": "★ Moto Gloves | Smoke Out"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5033,
|
||||||
|
"paint": "10079",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/motorcycle_gloves-10079.png",
|
||||||
|
"paint_name": "★ Moto Gloves | Blood Pressure"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5033,
|
||||||
|
"paint": "10080",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/motorcycle_gloves-10080.png",
|
||||||
|
"paint_name": "★ Moto Gloves | 3rd Commando Company"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5034,
|
||||||
|
"paint": "10030",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/specialist_gloves-10030.png",
|
||||||
|
"paint_name": "★ Specialist Gloves | Forest DDPAT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5034,
|
||||||
|
"paint": "10033",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/specialist_gloves-10033.png",
|
||||||
|
"paint_name": "★ Specialist Gloves | Crimson Kimono"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5034,
|
||||||
|
"paint": "10034",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/specialist_gloves-10034.png",
|
||||||
|
"paint_name": "★ Specialist Gloves | Emerald Web"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5034,
|
||||||
|
"paint": "10035",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/specialist_gloves-10035.png",
|
||||||
|
"paint_name": "★ Specialist Gloves | Foundation"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5034,
|
||||||
|
"paint": "10061",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/specialist_gloves-10061.png",
|
||||||
|
"paint_name": "★ Specialist Gloves | Crimson Web"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5034,
|
||||||
|
"paint": "10062",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/specialist_gloves-10062.png",
|
||||||
|
"paint_name": "★ Specialist Gloves | Buckshot"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5034,
|
||||||
|
"paint": "10063",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/specialist_gloves-10063.png",
|
||||||
|
"paint_name": "★ Specialist Gloves | Fade"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5034,
|
||||||
|
"paint": "10064",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/specialist_gloves-10064.png",
|
||||||
|
"paint_name": "★ Specialist Gloves | Mogul"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5034,
|
||||||
|
"paint": "10065",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/specialist_gloves-10065.png",
|
||||||
|
"paint_name": "★ Specialist Gloves | Marble Fade"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5034,
|
||||||
|
"paint": "10066",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/specialist_gloves-10066.png",
|
||||||
|
"paint_name": "★ Specialist Gloves | Lt. Commander"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5034,
|
||||||
|
"paint": "10067",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/specialist_gloves-10067.png",
|
||||||
|
"paint_name": "★ Specialist Gloves | Tiger Strike"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5034,
|
||||||
|
"paint": "10068",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/specialist_gloves-10068.png",
|
||||||
|
"paint_name": "★ Specialist Gloves | Field Agent"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5035,
|
||||||
|
"paint": "10057",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/studded_hydra_gloves-10057.png",
|
||||||
|
"paint_name": "★ Hydra Gloves | Emerald"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5035,
|
||||||
|
"paint": "10058",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/studded_hydra_gloves-10058.png",
|
||||||
|
"paint_name": "★ Hydra Gloves | Mangrove"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5035,
|
||||||
|
"paint": "10059",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/studded_hydra_gloves-10059.png",
|
||||||
|
"paint_name": "★ Hydra Gloves | Rattler"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"weapon_defindex": 5035,
|
||||||
|
"paint": "10060",
|
||||||
|
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/studded_hydra_gloves-10060.png",
|
||||||
|
"paint_name": "★ Hydra Gloves | Case Hardened"
|
||||||
|
}
|
||||||
|
]
|
||||||
12078
website/data/skins.json
@@ -8,7 +8,7 @@ $weapons = array (
|
|||||||
"weapon_aug" => 8,
|
"weapon_aug" => 8,
|
||||||
"weapon_awp" => 9,
|
"weapon_awp" => 9,
|
||||||
"weapon_famas" => 10,
|
"weapon_famas" => 10,
|
||||||
"weapon_g3sg1" => 10,
|
"weapon_g3sg1" => 11,
|
||||||
"weapon_galilar" => 13,
|
"weapon_galilar" => 13,
|
||||||
"weapon_m249" => 14,
|
"weapon_m249" => 14,
|
||||||
"weapon_m4a1" => 16,
|
"weapon_m4a1" => 16,
|
||||||
@@ -53,7 +53,14 @@ $weapons = array (
|
|||||||
"weapon_knife_stiletto" => 522,
|
"weapon_knife_stiletto" => 522,
|
||||||
"weapon_knife_widowmaker" => 523,
|
"weapon_knife_widowmaker" => 523,
|
||||||
"weapon_knife_skeleton" => 525);
|
"weapon_knife_skeleton" => 525);
|
||||||
$json = json_decode(file_get_contents('skins.json'));
|
|
||||||
|
|
||||||
|
|
||||||
|
$
|
||||||
|
|
||||||
|
$json = json_decode(file_get_contents('https://bymykel.github.io/CSGO-API/api/en/skins.json'));
|
||||||
|
|
||||||
|
die(var_dump($json));
|
||||||
echo "<pre>";
|
echo "<pre>";
|
||||||
foreach($json as $skin)
|
foreach($json as $skin)
|
||||||
{
|
{
|
||||||
|
|||||||
BIN
website/img/skins/leather_handwraps-10009.png
Normal file
|
After Width: | Height: | Size: 169 KiB |
BIN
website/img/skins/leather_handwraps-10010.png
Normal file
|
After Width: | Height: | Size: 171 KiB |
BIN
website/img/skins/leather_handwraps-10021.png
Normal file
|
After Width: | Height: | Size: 162 KiB |
BIN
website/img/skins/leather_handwraps-10036.png
Normal file
|
After Width: | Height: | Size: 163 KiB |
BIN
website/img/skins/leather_handwraps-10053.png
Normal file
|
After Width: | Height: | Size: 168 KiB |
BIN
website/img/skins/leather_handwraps-10054.png
Normal file
|
After Width: | Height: | Size: 175 KiB |
BIN
website/img/skins/leather_handwraps-10055.png
Normal file
|
After Width: | Height: | Size: 182 KiB |
BIN
website/img/skins/leather_handwraps-10056.png
Normal file
|
After Width: | Height: | Size: 166 KiB |
BIN
website/img/skins/leather_handwraps-10081.png
Normal file
|
After Width: | Height: | Size: 171 KiB |
BIN
website/img/skins/leather_handwraps-10082.png
Normal file
|
After Width: | Height: | Size: 179 KiB |
BIN
website/img/skins/leather_handwraps-10083.png
Normal file
|
After Width: | Height: | Size: 179 KiB |
BIN
website/img/skins/leather_handwraps-10084.png
Normal file
|
After Width: | Height: | Size: 169 KiB |
BIN
website/img/skins/motorcycle_gloves-10024.png
Normal file
|
After Width: | Height: | Size: 232 KiB |
BIN
website/img/skins/motorcycle_gloves-10026.png
Normal file
|
After Width: | Height: | Size: 237 KiB |
BIN
website/img/skins/motorcycle_gloves-10027.png
Normal file
|
After Width: | Height: | Size: 241 KiB |
BIN
website/img/skins/motorcycle_gloves-10028.png
Normal file
|
After Width: | Height: | Size: 239 KiB |
BIN
website/img/skins/motorcycle_gloves-10049.png
Normal file
|
After Width: | Height: | Size: 242 KiB |
BIN
website/img/skins/motorcycle_gloves-10050.png
Normal file
|
After Width: | Height: | Size: 232 KiB |
BIN
website/img/skins/motorcycle_gloves-10051.png
Normal file
|
After Width: | Height: | Size: 238 KiB |
BIN
website/img/skins/motorcycle_gloves-10052.png
Normal file
|
After Width: | Height: | Size: 238 KiB |
BIN
website/img/skins/motorcycle_gloves-10077.png
Normal file
|
After Width: | Height: | Size: 239 KiB |
BIN
website/img/skins/motorcycle_gloves-10078.png
Normal file
|
After Width: | Height: | Size: 235 KiB |
BIN
website/img/skins/motorcycle_gloves-10079.png
Normal file
|
After Width: | Height: | Size: 240 KiB |
BIN
website/img/skins/motorcycle_gloves-10080.png
Normal file
|
After Width: | Height: | Size: 231 KiB |
BIN
website/img/skins/slick_gloves-10013.png
Normal file
|
After Width: | Height: | Size: 215 KiB |
BIN
website/img/skins/slick_gloves-10015.png
Normal file
|
After Width: | Height: | Size: 217 KiB |
BIN
website/img/skins/slick_gloves-10016.png
Normal file
|
After Width: | Height: | Size: 215 KiB |
BIN
website/img/skins/slick_gloves-10040.png
Normal file
|
After Width: | Height: | Size: 232 KiB |
BIN
website/img/skins/slick_gloves-10041.png
Normal file
|
After Width: | Height: | Size: 244 KiB |
BIN
website/img/skins/slick_gloves-10042.png
Normal file
|
After Width: | Height: | Size: 218 KiB |
BIN
website/img/skins/slick_gloves-10043.png
Normal file
|
After Width: | Height: | Size: 228 KiB |
BIN
website/img/skins/slick_gloves-10044.png
Normal file
|
After Width: | Height: | Size: 218 KiB |
BIN
website/img/skins/slick_gloves-10069.png
Normal file
|
After Width: | Height: | Size: 224 KiB |
BIN
website/img/skins/slick_gloves-10070.png
Normal file
|
After Width: | Height: | Size: 235 KiB |
BIN
website/img/skins/slick_gloves-10071.png
Normal file
|
After Width: | Height: | Size: 227 KiB |
BIN
website/img/skins/slick_gloves-10072.png
Normal file
|
After Width: | Height: | Size: 216 KiB |
BIN
website/img/skins/specialist_gloves-10030.png
Normal file
|
After Width: | Height: | Size: 246 KiB |
BIN
website/img/skins/specialist_gloves-10033.png
Normal file
|
After Width: | Height: | Size: 244 KiB |
BIN
website/img/skins/specialist_gloves-10034.png
Normal file
|
After Width: | Height: | Size: 253 KiB |
BIN
website/img/skins/specialist_gloves-10035.png
Normal file
|
After Width: | Height: | Size: 260 KiB |
BIN
website/img/skins/specialist_gloves-10061.png
Normal file
|
After Width: | Height: | Size: 246 KiB |
BIN
website/img/skins/specialist_gloves-10062.png
Normal file
|
After Width: | Height: | Size: 246 KiB |
BIN
website/img/skins/specialist_gloves-10063.png
Normal file
|
After Width: | Height: | Size: 245 KiB |
BIN
website/img/skins/specialist_gloves-10064.png
Normal file
|
After Width: | Height: | Size: 256 KiB |
BIN
website/img/skins/specialist_gloves-10065.png
Normal file
|
After Width: | Height: | Size: 252 KiB |
BIN
website/img/skins/specialist_gloves-10066.png
Normal file
|
After Width: | Height: | Size: 257 KiB |
BIN
website/img/skins/specialist_gloves-10067.png
Normal file
|
After Width: | Height: | Size: 259 KiB |
BIN
website/img/skins/specialist_gloves-10068.png
Normal file
|
After Width: | Height: | Size: 253 KiB |
BIN
website/img/skins/sporty_gloves-10018.png
Normal file
|
After Width: | Height: | Size: 256 KiB |
BIN
website/img/skins/sporty_gloves-10019.png
Normal file
|
After Width: | Height: | Size: 249 KiB |
BIN
website/img/skins/sporty_gloves-10037.png
Normal file
|
After Width: | Height: | Size: 248 KiB |
BIN
website/img/skins/sporty_gloves-10038.png
Normal file
|
After Width: | Height: | Size: 239 KiB |
BIN
website/img/skins/sporty_gloves-10045.png
Normal file
|
After Width: | Height: | Size: 257 KiB |
BIN
website/img/skins/sporty_gloves-10046.png
Normal file
|
After Width: | Height: | Size: 249 KiB |
BIN
website/img/skins/sporty_gloves-10047.png
Normal file
|
After Width: | Height: | Size: 269 KiB |
BIN
website/img/skins/sporty_gloves-10048.png
Normal file
|
After Width: | Height: | Size: 258 KiB |
BIN
website/img/skins/sporty_gloves-10073.png
Normal file
|
After Width: | Height: | Size: 251 KiB |
BIN
website/img/skins/sporty_gloves-10074.png
Normal file
|
After Width: | Height: | Size: 236 KiB |
BIN
website/img/skins/sporty_gloves-10075.png
Normal file
|
After Width: | Height: | Size: 234 KiB |
BIN
website/img/skins/sporty_gloves-10076.png
Normal file
|
After Width: | Height: | Size: 199 KiB |
BIN
website/img/skins/studded_bloodhound_gloves-10006.png
Normal file
|
After Width: | Height: | Size: 176 KiB |
BIN
website/img/skins/studded_bloodhound_gloves-10007.png
Normal file
|
After Width: | Height: | Size: 187 KiB |
BIN
website/img/skins/studded_bloodhound_gloves-10008.png
Normal file
|
After Width: | Height: | Size: 200 KiB |
BIN
website/img/skins/studded_bloodhound_gloves-10039.png
Normal file
|
After Width: | Height: | Size: 184 KiB |
BIN
website/img/skins/studded_brokenfang_gloves-10085.png
Normal file
|
After Width: | Height: | Size: 201 KiB |
BIN
website/img/skins/studded_brokenfang_gloves-10086.png
Normal file
|
After Width: | Height: | Size: 196 KiB |