Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d83783b7af | ||
|
|
8e7b4a2d40 | ||
|
|
e0fce7a4b4 | ||
|
|
8f0e8a0a63 | ||
|
|
eb6cdfc98d | ||
|
|
56537971ad |
8
.github/workflows/build.yml
vendored
@@ -60,10 +60,12 @@ jobs:
|
|||||||
${{ env.OUTPUT_PATH }}/Microsoft.Extensions.DependencyModel.dll \
|
${{ env.OUTPUT_PATH }}/Microsoft.Extensions.DependencyModel.dll \
|
||||||
- name: Copy skins.json
|
- name: Copy skins.json
|
||||||
run: cp website/data/skins.json ${{ env.OUTPUT_PATH }}/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
|
||||||
run: zip -r "${{ env.PROJECT_NAME }}.zip" "${{ env.OUTPUT_PATH }}" gamedata/
|
uses: thedoctor0/zip-release@0.7.5
|
||||||
|
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/
|
||||||
|
|||||||
3
.gitignore
vendored
@@ -1,4 +1,5 @@
|
|||||||
|
|
||||||
.vs/
|
.vs/
|
||||||
bin/
|
bin/
|
||||||
obj/
|
obj/
|
||||||
website/getskins.php
|
.test/
|
||||||
|
|||||||
351
Commands.cs
@@ -8,59 +8,47 @@ namespace WeaponPaints
|
|||||||
{
|
{
|
||||||
private void OnCommandRefresh(CCSPlayerController? player, CommandInfo command)
|
private void OnCommandRefresh(CCSPlayerController? player, CommandInfo command)
|
||||||
{
|
{
|
||||||
if (!Config.Additional.CommandWpEnabled || !Config.Additional.SkinEnabled || !g_bCommandsAllowed) return;
|
if (!Config.AdditionalSetting.CommandWpEnabled || !Config.AdditionalSetting.SkinEnabled || !g_bCommandsAllowed) return;
|
||||||
if (!Utility.IsPlayerValid(player)) return;
|
if (!Utility.IsPlayerValid(player)) return;
|
||||||
|
if (player == null || !player.IsValid || player.UserId == null || player.Index <= 0 || player.IsBot) return;
|
||||||
if (player == null || !player.IsValid || player.UserId == null || player.IsBot) return;
|
|
||||||
|
|
||||||
PlayerInfo playerInfo = new PlayerInfo
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
{
|
{
|
||||||
UserId = player.UserId,
|
UserId = player.UserId,
|
||||||
Slot = player.Slot,
|
|
||||||
Index = (int)player.Index,
|
Index = (int)player.Index,
|
||||||
SteamId = player?.SteamID.ToString(),
|
SteamId = player?.AuthorizedSteamID?.SteamId64,
|
||||||
Name = player?.PlayerName,
|
Name = player?.PlayerName,
|
||||||
IpAddress = player?.IpAddress?.Split(":")[0]
|
IpAddress = player?.IpAddress?.Split(":")[0]
|
||||||
};
|
};
|
||||||
|
|
||||||
try
|
if (!commandsCooldown.TryGetValue((int)player!.UserId, out DateTime cooldownEndTime) ||
|
||||||
|
DateTime.UtcNow >= (commandsCooldown.TryGetValue((int)player.UserId, out cooldownEndTime) ? cooldownEndTime : DateTime.UtcNow))
|
||||||
{
|
{
|
||||||
if (player != null && !commandsCooldown.TryGetValue(player.Slot, out DateTime cooldownEndTime) ||
|
commandsCooldown[(int)player.UserId] = DateTime.UtcNow.AddSeconds(Config.CmdRefreshCooldownSeconds);
|
||||||
player != null && DateTime.UtcNow >= (commandsCooldown.TryGetValue(player.Slot, out cooldownEndTime) ? cooldownEndTime : DateTime.UtcNow))
|
if (weaponSync != null)
|
||||||
|
Task.Run(async () => await weaponSync.GetWeaponPaintsFromDatabase(playerInfo));
|
||||||
|
if (Config.AdditionalSetting.KnifeEnabled)
|
||||||
{
|
{
|
||||||
commandsCooldown[player.Slot] = DateTime.UtcNow.AddSeconds(Config.CmdRefreshCooldownSeconds);
|
|
||||||
|
|
||||||
if (weaponSync != null)
|
if (weaponSync != null)
|
||||||
{
|
Task.Run(async () => await weaponSync.GetKnifeFromDatabase(playerInfo));
|
||||||
Task.Run(async () => await weaponSync.GetWeaponPaintsFromDatabase(playerInfo));
|
|
||||||
|
|
||||||
if (Config.Additional.GloveEnabled)
|
RefreshWeapons(player);
|
||||||
Task.Run(async () => await weaponSync.GetGloveFromDatabase(playerInfo));
|
|
||||||
|
|
||||||
if (Config.Additional.KnifeEnabled)
|
|
||||||
Task.Run(async () => await weaponSync.GetKnifeFromDatabase(playerInfo));
|
|
||||||
|
|
||||||
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"]))
|
if (!string.IsNullOrEmpty(Localizer["wp_command_refresh_done"]))
|
||||||
{
|
{
|
||||||
player!.Print(Localizer["wp_command_cooldown"]);
|
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)
|
private void OnCommandWS(CCSPlayerController? player, CommandInfo command)
|
||||||
{
|
{
|
||||||
if (!Config.Additional.SkinEnabled) return;
|
if (!Config.AdditionalSetting.SkinEnabled) return;
|
||||||
if (!Utility.IsPlayerValid(player)) return;
|
if (!Utility.IsPlayerValid(player)) return;
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(Localizer["wp_info_website"]))
|
if (!string.IsNullOrEmpty(Localizer["wp_info_website"]))
|
||||||
@@ -71,35 +59,28 @@ namespace WeaponPaints
|
|||||||
{
|
{
|
||||||
player!.Print(Localizer["wp_info_refresh"]);
|
player!.Print(Localizer["wp_info_refresh"]);
|
||||||
}
|
}
|
||||||
|
if (!Config.AdditionalSetting.KnifeEnabled) return;
|
||||||
if (Config.Additional.GloveEnabled)
|
if (!string.IsNullOrEmpty(Localizer["wp_info_knife"]))
|
||||||
if (!string.IsNullOrEmpty(Localizer["wp_info_glove"]))
|
{
|
||||||
{
|
player!.Print(Localizer["wp_info_knife"]);
|
||||||
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()
|
private void RegisterCommands()
|
||||||
{
|
{
|
||||||
AddCommand($"css_{Config.Additional.CommandSkin}", "Skins info", (player, info) =>
|
AddCommand($"css_{Config.AdditionalSetting.CommandSkin}", "Skins info", (player, info) =>
|
||||||
{
|
{
|
||||||
if (!Utility.IsPlayerValid(player)) return;
|
if (!Utility.IsPlayerValid(player)) return;
|
||||||
OnCommandWS(player, info);
|
OnCommandWS(player, info);
|
||||||
});
|
});
|
||||||
AddCommand($"css_{Config.Additional.CommandRefresh}", "Skins refresh", (player, info) =>
|
AddCommand($"css_{Config.AdditionalSetting.CommandRefresh}", "Skins refresh", (player, info) =>
|
||||||
{
|
{
|
||||||
if (!Utility.IsPlayerValid(player)) return;
|
if (!Utility.IsPlayerValid(player) || !g_bCommandsAllowed) return;
|
||||||
OnCommandRefresh(player, info);
|
OnCommandRefresh(player, info);
|
||||||
});
|
});
|
||||||
if (Config.Additional.CommandKillEnabled)
|
if (Config.AdditionalSetting.CommandKillEnabled)
|
||||||
{
|
{
|
||||||
AddCommand($"css_{Config.Additional.CommandKill}", "kill yourself", (player, info) =>
|
AddCommand($"css_{Config.AdditionalSetting.CommandKill}", "kill yourself", (player, info) =>
|
||||||
{
|
{
|
||||||
if (player == null || !Utility.IsPlayerValid(player) || player.PlayerPawn.Value == null || !player!.PlayerPawn.IsValid) return;
|
if (player == null || !Utility.IsPlayerValid(player) || player.PlayerPawn.Value == null || !player!.PlayerPawn.IsValid) return;
|
||||||
|
|
||||||
@@ -110,67 +91,68 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
private void SetupKnifeMenu()
|
private void SetupKnifeMenu()
|
||||||
{
|
{
|
||||||
if (!Config.Additional.KnifeEnabled || !g_bCommandsAllowed) return;
|
if (!Config.AdditionalSetting.KnifeEnabled || !g_bCommandsAllowed) return;
|
||||||
|
|
||||||
var knivesOnly = weaponList
|
var knivesOnly = weaponList
|
||||||
.Where(pair => pair.Key.StartsWith("weapon_knife") || pair.Key.StartsWith("weapon_bayonet"))
|
.Where(pair => pair.Key.StartsWith("weapon_knife") || pair.Key.StartsWith("weapon_bayonet"))
|
||||||
.ToDictionary(pair => pair.Key, pair => pair.Value);
|
.ToDictionary(pair => pair.Key, pair => pair.Value);
|
||||||
|
|
||||||
var giveItemMenu = new ChatMenu(Localizer["wp_knife_menu_title"]);
|
var giveItemMenu = new ChatMenu(Localizer["wp_knife_menu_title"]);
|
||||||
var handleGive = (CCSPlayerController player, ChatMenuOption option) =>
|
var handleGive = (CCSPlayerController? player, ChatMenuOption option) =>
|
||||||
{
|
{
|
||||||
if (!Utility.IsPlayerValid(player)) return;
|
if (Utility.IsPlayerValid(player))
|
||||||
|
|
||||||
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"]))
|
if (player == null) return;
|
||||||
|
var knifeName = option.Text;
|
||||||
|
var knifeKey = knivesOnly.FirstOrDefault(x => x.Value == knifeName).Key;
|
||||||
|
if (!string.IsNullOrEmpty(knifeKey))
|
||||||
{
|
{
|
||||||
player!.Print(Localizer["wp_knife_menu_select", knifeName]);
|
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.AdditionalSetting.CommandKillEnabled)
|
||||||
|
{
|
||||||
|
player!.Print(Localizer["wp_knife_menu_kill"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
|
{
|
||||||
|
UserId = player.UserId,
|
||||||
|
Index = (int)player.Index,
|
||||||
|
SteamId = player?.AuthorizedSteamID?.SteamId64,
|
||||||
|
Name = player?.PlayerName,
|
||||||
|
IpAddress = player?.IpAddress?.Split(":")[0]
|
||||||
|
};
|
||||||
|
|
||||||
|
g_playersKnife[(int)player!.Index] = knifeKey;
|
||||||
|
|
||||||
|
if (player!.PawnIsAlive && g_bCommandsAllowed)
|
||||||
|
{
|
||||||
|
RefreshWeapons(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (weaponSync != null)
|
||||||
|
Task.Run(async () => await weaponSync.SyncKnifeToDatabase(playerInfo, knifeKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
foreach (var knifePair in knivesOnly)
|
||||||
{
|
{
|
||||||
giveItemMenu.AddMenuOption(knifePair.Value, handleGive);
|
giveItemMenu.AddMenuOption(knifePair.Value, handleGive);
|
||||||
}
|
}
|
||||||
AddCommand($"css_{Config.Additional.CommandKnife}", "Knife Menu", (player, info) =>
|
AddCommand($"css_{Config.AdditionalSetting.CommandKnife}", "Knife Menu", (player, info) =>
|
||||||
{
|
{
|
||||||
if (!Utility.IsPlayerValid(player) || !g_bCommandsAllowed) return;
|
if (!Utility.IsPlayerValid(player) || !g_bCommandsAllowed) return;
|
||||||
|
|
||||||
if (player == null || player.UserId == null) return;
|
if (player == null || player.UserId == null) return;
|
||||||
|
|
||||||
if (player != null && !commandsCooldown.TryGetValue(player.Slot, out DateTime cooldownEndTime) ||
|
if (!commandsCooldown.TryGetValue((int)player.UserId, out DateTime cooldownEndTime) ||
|
||||||
player != null && DateTime.UtcNow >= (commandsCooldown.TryGetValue(player.Slot, out cooldownEndTime) ? cooldownEndTime : DateTime.UtcNow))
|
DateTime.UtcNow >= (commandsCooldown.TryGetValue((int)player.UserId, out cooldownEndTime) ? cooldownEndTime : DateTime.UtcNow))
|
||||||
{
|
{
|
||||||
commandsCooldown[player.Slot] = DateTime.UtcNow.AddSeconds(Config.CmdRefreshCooldownSeconds);
|
commandsCooldown[(int)player.UserId] = DateTime.UtcNow.AddSeconds(Config.CmdRefreshCooldownSeconds);
|
||||||
giveItemMenu.PostSelectAction = PostSelectAction.Close;
|
ChatMenus.OpenMenu(player, giveItemMenu);
|
||||||
MenuManager.OpenChatMenu(player, giveItemMenu);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrEmpty(Localizer["wp_command_cooldown"]))
|
if (!string.IsNullOrEmpty(Localizer["wp_command_cooldown"]))
|
||||||
@@ -190,6 +172,7 @@ namespace WeaponPaints
|
|||||||
{
|
{
|
||||||
if (!Utility.IsPlayerValid(player)) return;
|
if (!Utility.IsPlayerValid(player)) return;
|
||||||
|
|
||||||
|
int playerIndex = (int)player!.Index;
|
||||||
string selectedWeapon = option.Text;
|
string selectedWeapon = option.Text;
|
||||||
if (classNamesByWeapon.TryGetValue(selectedWeapon, out string? selectedWeaponClassname))
|
if (classNamesByWeapon.TryGetValue(selectedWeapon, out string? selectedWeaponClassname))
|
||||||
{
|
{
|
||||||
@@ -201,15 +184,17 @@ namespace WeaponPaints
|
|||||||
)?.ToList();
|
)?.ToList();
|
||||||
|
|
||||||
var skinSubMenu = new ChatMenu(Localizer["wp_skin_menu_skin_title", selectedWeapon]);
|
var skinSubMenu = new ChatMenu(Localizer["wp_skin_menu_skin_title", selectedWeapon]);
|
||||||
skinSubMenu.PostSelectAction = PostSelectAction.Close;
|
|
||||||
|
|
||||||
// Function to handle skin selection for the chosen weapon
|
// Function to handle skin selection for the chosen weapon
|
||||||
var handleSkinSelection = (CCSPlayerController p, ChatMenuOption opt) =>
|
var handleSkinSelection = (CCSPlayerController? p, ChatMenuOption opt) =>
|
||||||
{
|
{
|
||||||
if (!Utility.IsPlayerValid(p)) return;
|
if (p == null || !p.IsValid || p.Index <= 0) return;
|
||||||
|
|
||||||
|
playerIndex = (int)p.Index;
|
||||||
|
|
||||||
string steamId = p.SteamID.ToString();
|
if (p.AuthorizedSteamID == null) return;
|
||||||
|
|
||||||
|
string steamId = p.AuthorizedSteamID.SteamId64.ToString();
|
||||||
var firstSkin = skinsList?.FirstOrDefault(skin =>
|
var firstSkin = skinsList?.FirstOrDefault(skin =>
|
||||||
{
|
{
|
||||||
if (skin != null && skin.TryGetValue("weapon_name", out var weaponName))
|
if (skin != null && skin.TryGetValue("weapon_name", out var weaponName))
|
||||||
@@ -218,51 +203,39 @@ namespace WeaponPaints
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
string selectedSkin = opt.Text;
|
string selectedSkin = opt.Text;
|
||||||
string selectedPaintID = selectedSkin.Split('(')[1].Trim(')').Trim();
|
string selectedPaintID = selectedSkin.Split('(')[1].Trim(')').Trim();
|
||||||
|
|
||||||
if (firstSkin != null &&
|
if (firstSkin != null &&
|
||||||
firstSkin.TryGetValue("weapon_defindex", out var weaponDefIndexObj) &&
|
firstSkin.TryGetValue("weapon_defindex", out var weaponDefIndexObj) &&
|
||||||
weaponDefIndexObj != null &&
|
weaponDefIndexObj != null &&
|
||||||
int.TryParse(weaponDefIndexObj.ToString(), out var weaponDefIndex) &&
|
ushort.TryParse(weaponDefIndexObj.ToString(), out var weaponDefIndex) &&
|
||||||
int.TryParse(selectedPaintID, out var paintID))
|
ushort.TryParse(selectedPaintID, out var paintID))
|
||||||
{
|
{
|
||||||
if (Config.Additional.ShowSkinImage && skinsList != null)
|
p!.Print(Localizer["wp_skin_menu_select", selectedSkin]);
|
||||||
{
|
|
||||||
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[playerIndex].TryGetValue(weaponDefIndex, out _))
|
||||||
|
{
|
||||||
|
gPlayerWeaponsInfo[playerIndex][weaponDefIndex] = new WeaponInfo();
|
||||||
|
}
|
||||||
|
|
||||||
if (!gPlayerWeaponsInfo[p.Slot].ContainsKey(weaponDefIndex))
|
gPlayerWeaponsInfo[playerIndex][weaponDefIndex].Paint = paintID;
|
||||||
{
|
gPlayerWeaponsInfo[playerIndex][weaponDefIndex].Wear = 0.00001f;
|
||||||
gPlayerWeaponsInfo[p.Slot][weaponDefIndex] = new WeaponInfo();
|
gPlayerWeaponsInfo[playerIndex][weaponDefIndex].Seed = 0;
|
||||||
}
|
|
||||||
|
|
||||||
gPlayerWeaponsInfo[p.Slot][weaponDefIndex].Paint = paintID;
|
|
||||||
gPlayerWeaponsInfo[p.Slot][weaponDefIndex].Wear = 0.01f;
|
|
||||||
gPlayerWeaponsInfo[p.Slot][weaponDefIndex].Seed = 0;
|
|
||||||
|
|
||||||
PlayerInfo playerInfo = new PlayerInfo
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
{
|
{
|
||||||
UserId = p.UserId,
|
UserId = player.UserId,
|
||||||
Index = (int)p.Index,
|
Index = (int)player.Index,
|
||||||
SteamId = p.SteamID.ToString(),
|
SteamId = player?.AuthorizedSteamID?.SteamId64,
|
||||||
Name = p.PlayerName,
|
Name = player?.PlayerName,
|
||||||
IpAddress = p.IpAddress?.Split(":")[0]
|
IpAddress = player?.IpAddress?.Split(":")[0]
|
||||||
};
|
};
|
||||||
|
|
||||||
if (g_bCommandsAllowed && (LifeState_t)p.LifeState == LifeState_t.LIFE_ALIVE)
|
if (!Config.GlobalShare)
|
||||||
{
|
{
|
||||||
RefreshWeapons(player);
|
if (weaponSync != null)
|
||||||
|
Task.Run(async () => await weaponSync.SyncWeaponPaintToDatabase(playerInfo, weaponDefIndex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -284,8 +257,9 @@ namespace WeaponPaints
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (player != null && Utility.IsPlayerValid(player))
|
|
||||||
MenuManager.OpenChatMenu(player, skinSubMenu);
|
// Open the submenu for skin selection of the chosen weapon
|
||||||
|
ChatMenus.OpenMenu(player, skinSubMenu);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -296,127 +270,24 @@ namespace WeaponPaints
|
|||||||
weaponSelectionMenu.AddMenuOption(weaponName, handleWeaponSelection);
|
weaponSelectionMenu.AddMenuOption(weaponName, handleWeaponSelection);
|
||||||
}
|
}
|
||||||
// Command to open the weapon selection menu for players
|
// Command to open the weapon selection menu for players
|
||||||
AddCommand($"css_{Config.Additional.CommandSkinSelection}", "Skins selection menu", (player, info) =>
|
AddCommand($"css_{Config.AdditionalSetting.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;
|
if (!Utility.IsPlayerValid(player)) return;
|
||||||
|
|
||||||
string selectedPaintName = option.Text;
|
if (player == null || player.UserId == null) return;
|
||||||
|
|
||||||
var selectedGlove = glovesList.FirstOrDefault(g => g.ContainsKey("paint_name") && g["paint_name"]?.ToString() == selectedPaintName);
|
if (!commandsCooldown.TryGetValue((int)player.UserId, out DateTime cooldownEndTime) ||
|
||||||
if (selectedGlove != null)
|
DateTime.UtcNow >= (commandsCooldown.TryGetValue((int)player.UserId, out cooldownEndTime) ? cooldownEndTime : DateTime.UtcNow))
|
||||||
{
|
{
|
||||||
if (
|
commandsCooldown[(int)player.UserId] = DateTime.UtcNow.AddSeconds(Config.CmdRefreshCooldownSeconds);
|
||||||
selectedGlove != null &&
|
ChatMenus.OpenMenu(player, weaponSelectionMenu);
|
||||||
selectedGlove.ContainsKey("weapon_defindex") &&
|
return;
|
||||||
selectedGlove.ContainsKey("paint") &&
|
}
|
||||||
int.TryParse(selectedGlove["weapon_defindex"]?.ToString(), out int weaponDefindex) &&
|
if (!string.IsNullOrEmpty(Localizer["wp_command_cooldown"]))
|
||||||
int.TryParse(selectedGlove["paint"]?.ToString(), out int paint)
|
{
|
||||||
)
|
player!.Print(Localizer["wp_command_cooldown"]);
|
||||||
{
|
}
|
||||||
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, (ushort)weaponDefindex);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
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"]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
38
Config.cs
@@ -3,21 +3,28 @@ using System.Text.Json.Serialization;
|
|||||||
|
|
||||||
namespace WeaponPaints
|
namespace WeaponPaints
|
||||||
{
|
{
|
||||||
public class Additional
|
public class AdditionalSetting
|
||||||
{
|
{
|
||||||
[JsonPropertyName("SkinVisibilityFix")]
|
|
||||||
|
[JsonPropertyName("UseMetamodAlwaysLegacyModel")]
|
||||||
|
public bool UseMetamodAlwaysLegacyModel { get; set; } = false;
|
||||||
|
|
||||||
|
[JsonPropertyName("SkinVisibilityFix")]
|
||||||
public bool SkinVisibilityFix { get; set; } = true;
|
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;
|
||||||
|
|
||||||
[JsonPropertyName("CommandWpEnabled")]
|
[JsonPropertyName("MusicKitEnabled")]
|
||||||
|
public bool MusicKitEnabled { get; set; } = true;
|
||||||
|
|
||||||
|
[JsonPropertyName("NameTagEnabled")]
|
||||||
|
public bool NameTagEnabled { get; set; } = true;
|
||||||
|
|
||||||
|
[JsonPropertyName("CommandWpEnabled")]
|
||||||
public bool CommandWpEnabled { get; set; } = true;
|
public bool CommandWpEnabled { get; set; } = true;
|
||||||
|
|
||||||
[JsonPropertyName("CommandKillEnabled")]
|
[JsonPropertyName("CommandKillEnabled")]
|
||||||
@@ -26,9 +33,6 @@ 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";
|
||||||
|
|
||||||
@@ -46,17 +50,13 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
[JsonPropertyName("GiveRandomSkin")]
|
[JsonPropertyName("GiveRandomSkin")]
|
||||||
public bool GiveRandomSkin { get; set; } = false;
|
public bool GiveRandomSkin { get; set; } = false;
|
||||||
|
|
||||||
[JsonPropertyName("GiveKnifeAfterRemove")]
|
[JsonPropertyName("GiveKnifeAfterRemove")]
|
||||||
public bool GiveKnifeAfterRemove { get; set; } = false;
|
public bool GiveKnifeAfterRemove { get; set; } = false;
|
||||||
|
|
||||||
[JsonPropertyName("ShowSkinImage")]
|
|
||||||
public bool ShowSkinImage { get; set; } = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class WeaponPaintsConfig : BasePluginConfig
|
public class WeaponPaintsConfig : BasePluginConfig
|
||||||
{
|
{
|
||||||
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; } = "";
|
||||||
@@ -73,6 +73,9 @@ 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;
|
||||||
|
|
||||||
@@ -82,7 +85,8 @@ namespace WeaponPaints
|
|||||||
[JsonPropertyName("Website")]
|
[JsonPropertyName("Website")]
|
||||||
public string Website { get; set; } = "example.com/skins";
|
public string Website { get; set; } = "example.com/skins";
|
||||||
|
|
||||||
[JsonPropertyName("Additional")]
|
[JsonPropertyName("AdditionalSetting")]
|
||||||
public Additional Additional { get; set; } = new Additional();
|
public AdditionalSetting AdditionalSetting { get; set; } = new AdditionalSetting();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|||||||
28
Database.cs
@@ -1,28 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
379
Events.cs
@@ -1,102 +1,60 @@
|
|||||||
using CounterStrikeSharp.API;
|
using CounterStrikeSharp.API;
|
||||||
using CounterStrikeSharp.API.Core;
|
using CounterStrikeSharp.API.Core;
|
||||||
using CounterStrikeSharp.API.Core.Attributes.Registration;
|
using CounterStrikeSharp.API.Modules.Entities;
|
||||||
|
using System.Numerics;
|
||||||
|
|
||||||
namespace WeaponPaints
|
namespace WeaponPaints
|
||||||
{
|
{
|
||||||
public partial class WeaponPaints
|
public partial class WeaponPaints
|
||||||
{
|
{
|
||||||
[GameEventHandler]
|
private void OnClientPutInServer(int playerSlot)
|
||||||
public HookResult OnClientFullConnect(EventPlayerConnectFull @event, GameEventInfo info)
|
|
||||||
{
|
{
|
||||||
CCSPlayerController? player = @event.Userid;
|
CCSPlayerController? player = Utilities.GetPlayerFromSlot(playerSlot);
|
||||||
|
|
||||||
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
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
{
|
{
|
||||||
UserId = player.UserId,
|
UserId = player.UserId,
|
||||||
Slot = player.Slot,
|
|
||||||
Index = (int)player.Index,
|
Index = (int)player.Index,
|
||||||
SteamId = player.SteamID.ToString(),
|
SteamId = player.SteamID,
|
||||||
Name = player.PlayerName,
|
Name = player.PlayerName,
|
||||||
IpAddress = player.IpAddress?.Split(":")[0]
|
IpAddress = player.IpAddress?.Split(":")[0]
|
||||||
};
|
};
|
||||||
|
|
||||||
try
|
if (player == null || !player.IsValid || player.IsBot || player.IsHLTV || weaponSync == null) return;
|
||||||
{
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"An error occurred: {ex.Message}");
|
|
||||||
}
|
|
||||||
|
|
||||||
return HookResult.Continue;
|
Task.Run(async () =>
|
||||||
}
|
{
|
||||||
|
await weaponSync.GetPlayerDatabaseIndex(playerInfo);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
[GameEventHandler]
|
private void OnClientDisconnect(int playerSlot)
|
||||||
public HookResult OnPlayerDisconnect(EventPlayerDisconnect @event, GameEventInfo info)
|
|
||||||
{
|
{
|
||||||
CCSPlayerController player = @event.Userid;
|
CCSPlayerController player = Utilities.GetPlayerFromSlot(playerSlot);
|
||||||
|
|
||||||
if (player is null || !player.IsValid || !player.UserId.HasValue || player.IsBot ||
|
if (player == null || !player.IsValid || player.IsBot || player.IsHLTV || player.UserId == null) return;
|
||||||
player.IsHLTV || player.SteamID.ToString().Length != 17) return HookResult.Continue;
|
|
||||||
|
|
||||||
PlayerInfo playerInfo = new PlayerInfo
|
g_playersDatabaseIndex.TryRemove((int)player.Index, out _);
|
||||||
|
if (Config.AdditionalSetting.KnifeEnabled)
|
||||||
|
g_playersKnife.TryRemove((int)player.Index, out _);
|
||||||
|
if (Config.AdditionalSetting.SkinEnabled)
|
||||||
{
|
{
|
||||||
UserId = player.UserId,
|
if (gPlayerWeaponsInfo.TryRemove((int)player.Index, out var innerDictionary))
|
||||||
Slot = player.Slot,
|
|
||||||
Index = (int)player.Index,
|
|
||||||
SteamId = player.SteamID.ToString(),
|
|
||||||
Name = player.PlayerName,
|
|
||||||
IpAddress = player.IpAddress?.Split(":")[0]
|
|
||||||
};
|
|
||||||
|
|
||||||
if (weaponSync != null)
|
|
||||||
{
|
|
||||||
// Run weapon sync tasks asynchronously
|
|
||||||
Task.Run(async () =>
|
|
||||||
{
|
{
|
||||||
await weaponSync.SyncWeaponPaintsToDatabase(playerInfo);
|
innerDictionary.Clear();
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
if (Config.AdditionalSetting.MusicKitEnabled)
|
||||||
// Remove player's command cooldown
|
g_playersMusicKit.TryRemove((int)player.Index, out _);
|
||||||
commandsCooldown.Remove(player.Slot);
|
if (commandsCooldown.ContainsKey((int)player.UserId))
|
||||||
// Remove player data
|
|
||||||
if (Config.Additional.SkinEnabled)
|
|
||||||
{
|
{
|
||||||
gPlayerWeaponsInfo.TryRemove(player.Slot, out _);
|
commandsCooldown.Remove((int)player.UserId);
|
||||||
}
|
}
|
||||||
if (Config.Additional.KnifeEnabled)
|
|
||||||
{
|
|
||||||
g_playersKnife.TryRemove(player.Slot, out _);
|
|
||||||
}
|
|
||||||
if (Config.Additional.GloveEnabled)
|
|
||||||
{
|
|
||||||
g_playersGlove.TryRemove(player.Slot, out _);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return HookResult.Continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnEntityCreated(CEntityInstance entity)
|
private void OnEntityCreated(CEntityInstance entity)
|
||||||
{
|
{
|
||||||
if (!Config.Additional.SkinEnabled) return;
|
if (!Config.AdditionalSetting.SkinEnabled) return;
|
||||||
if (entity == null || !entity.IsValid || string.IsNullOrEmpty(entity.DesignerName)) return;
|
if (entity == null || !entity.IsValid || string.IsNullOrEmpty(entity.DesignerName)) return;
|
||||||
string designerName = entity.DesignerName;
|
string designerName = entity.DesignerName;
|
||||||
if (!weaponList.ContainsKey(designerName)) return;
|
if (!weaponList.ContainsKey(designerName)) return;
|
||||||
@@ -116,7 +74,7 @@ namespace WeaponPaints
|
|||||||
if (weapon.OwnerEntity.Value == null) return;
|
if (weapon.OwnerEntity.Value == null) return;
|
||||||
if (weapon.OwnerEntity.Index <= 0) return;
|
if (weapon.OwnerEntity.Index <= 0) return;
|
||||||
int weaponOwner = (int)weapon.OwnerEntity.Index;
|
int weaponOwner = (int)weapon.OwnerEntity.Index;
|
||||||
CBasePlayerPawn? pawn = Utilities.GetEntityFromIndex<CCSPlayerPawn>(weaponOwner);
|
var pawn = new CBasePlayerPawn(NativeAPI.GetEntityFromIndex(weaponOwner));
|
||||||
if (!pawn.IsValid) return;
|
if (!pawn.IsValid) return;
|
||||||
|
|
||||||
var playerIndex = (int)pawn.Controller.Index;
|
var playerIndex = (int)pawn.Controller.Index;
|
||||||
@@ -129,77 +87,166 @@ namespace WeaponPaints
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public HookResult OnPickup(CEntityIOOutput output, string name, CEntityInstance activator, CEntityInstance caller, CVariant value, float delay)
|
private HookResult OnEventItemPurchasePost(EventItemPurchase @event, GameEventInfo info)
|
||||||
{
|
{
|
||||||
if (!Config.Additional.GiveKnifeAfterRemove)
|
CCSPlayerController? player = @event.Userid;
|
||||||
return HookResult.Continue;
|
|
||||||
|
|
||||||
|
if (player == null || !player.IsValid) return HookResult.Continue;
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (Config.AdditionalSetting.SkinVisibilityFix)
|
||||||
|
AddTimer(0.2f, () => RefreshSkins(player));
|
||||||
|
*/
|
||||||
|
|
||||||
|
return HookResult.Continue;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
private HookResult OnItemPickup(EventItemPickup @event, GameEventInfo info)
|
||||||
|
{
|
||||||
|
if (@event.Defindex == 42 || @event.Defindex == 59)
|
||||||
|
{
|
||||||
|
CCSPlayerController? player = @event.Userid;
|
||||||
|
if (player == null || !player.IsValid || !g_knifePickupCount.ContainsKey((int)player.Index) || player.IsBot || !g_playersKnife.ContainsKey((int)player.Index))
|
||||||
|
return HookResult.Continue;
|
||||||
|
|
||||||
|
|
||||||
|
if (g_knifePickupCount[(int)player.Index] >= 2) return HookResult.Continue;
|
||||||
|
|
||||||
|
if (g_playersKnife.ContainsKey((int)player.Index)
|
||||||
|
&&
|
||||||
|
g_playersKnife[(int)player.Index] != "weapon_knife")
|
||||||
|
{
|
||||||
|
g_knifePickupCount[(int)player.Index]++;
|
||||||
|
|
||||||
|
RemovePlayerKnife(player, true);
|
||||||
|
|
||||||
|
if (!PlayerHasKnife(player) && Config.AdditionalSetting.GiveKnifeAfterRemove)
|
||||||
|
AddTimer(0.3f, () => GiveKnifeToPlayer(player));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return HookResult.Continue;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
public HookResult OnPickup(CEntityIOOutput output, string name, CEntityInstance activator, CEntityInstance caller, CVariant value, float delay)
|
||||||
|
{
|
||||||
CCSPlayerController? player = Utilities.GetEntityFromIndex<CCSPlayerPawn>((int)activator.Index).OriginalController.Value;
|
CCSPlayerController? player = Utilities.GetEntityFromIndex<CCSPlayerPawn>((int)activator.Index).OriginalController.Value;
|
||||||
|
|
||||||
if (player == null || player.IsBot || player.IsHLTV ||
|
if (player == null || player.IsBot || player.IsHLTV)
|
||||||
player.SteamID.ToString().Length != 17 || !g_knifePickupCount.TryGetValue(player.Slot, out var pickupCount) ||
|
return HookResult.Continue;
|
||||||
!g_playersKnife.ContainsKey(player.Slot))
|
|
||||||
{
|
if (player == null || !player.IsValid || player.SteamID.ToString() == "" ||
|
||||||
|
!g_knifePickupCount.ContainsKey((int)player.Index) || !g_playersKnife.ContainsKey((int)player.Index))
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
}
|
|
||||||
|
|
||||||
CBasePlayerWeapon weapon = new(caller.Handle);
|
CBasePlayerWeapon weapon = new(caller.Handle);
|
||||||
|
|
||||||
if (weapon.AttributeManager.Item.ItemDefinitionIndex != 42 && weapon.AttributeManager.Item.ItemDefinitionIndex != 59)
|
if (weapon.AttributeManager.Item.ItemDefinitionIndex != 42 && weapon.AttributeManager.Item.ItemDefinitionIndex != 59)
|
||||||
{
|
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
}
|
|
||||||
|
|
||||||
if (pickupCount >= 2)
|
if (g_knifePickupCount[(int)player.Index] >= 2) return HookResult.Continue;
|
||||||
|
|
||||||
|
if (g_playersKnife[(int)player.Index] != "weapon_knife")
|
||||||
{
|
{
|
||||||
return HookResult.Continue;
|
g_knifePickupCount[(int)player.Index]++;
|
||||||
}
|
player.RemoveItemByDesignerName(weapon.DesignerName);
|
||||||
|
if (Config.AdditionalSetting.GiveKnifeAfterRemove)
|
||||||
if (g_playersKnife[player.Slot] != "weapon_knife")
|
AddTimer(0.2f, () => GiveKnifeToPlayer(player));
|
||||||
{
|
|
||||||
pickupCount++;
|
|
||||||
g_knifePickupCount[player.Slot] = pickupCount;
|
|
||||||
|
|
||||||
RefreshWeapons(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
}
|
}
|
||||||
|
private void OnMapStart(string mapName)
|
||||||
private void OnMapStart(string mapName)
|
|
||||||
{
|
{
|
||||||
if (!Config.Additional.KnifeEnabled && !Config.Additional.SkinEnabled && !Config.Additional.GloveEnabled) return;
|
if (!Config.AdditionalSetting.KnifeEnabled) return;
|
||||||
|
// TODO
|
||||||
if (_database != null)
|
// needed for now
|
||||||
weaponSync = new WeaponSynchronization(_database, Config);
|
AddTimer(2.0f, () =>
|
||||||
|
|
||||||
// TODO
|
|
||||||
// needed for now
|
|
||||||
AddTimer(2.0f, () =>
|
|
||||||
{
|
{
|
||||||
|
|
||||||
NativeAPI.IssueServerCommand("mp_t_default_melee \"\"");
|
NativeAPI.IssueServerCommand("mp_t_default_melee \"\"");
|
||||||
NativeAPI.IssueServerCommand("mp_ct_default_melee \"\"");
|
NativeAPI.IssueServerCommand("mp_ct_default_melee \"\"");
|
||||||
NativeAPI.IssueServerCommand("mp_equipment_reset_rounds 0");
|
NativeAPI.IssueServerCommand("mp_equipment_reset_rounds 0");
|
||||||
|
|
||||||
|
if (Config.GlobalShare)
|
||||||
|
GlobalShareConnect();
|
||||||
|
|
||||||
|
weaponSync = new WeaponSynchronization(DatabaseConnectionString, Config, GlobalShareApi, GlobalShareServerId);
|
||||||
});
|
});
|
||||||
|
/*
|
||||||
|
g_hTimerCheckSkinsData = AddTimer(10.0f, () =>
|
||||||
|
{
|
||||||
|
List<CCSPlayerController> players = Utilities.GetPlayers();
|
||||||
|
HashSet<int> playerIndexes = new HashSet<int>(gPlayerWeaponsInfo.Keys);
|
||||||
|
foreach (CCSPlayerController player in players)
|
||||||
|
{
|
||||||
|
if (player.IsBot || player.IsHLTV || player.SteamID.ToString() == "") continue;
|
||||||
|
//if (gPlayerWeaponsInfo.ContainsKey((int)player.Index)) continue;
|
||||||
|
if (playerIndexes.Contains((int)player.Index)) continue;
|
||||||
|
|
||||||
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
|
{
|
||||||
|
UserId = player.UserId,
|
||||||
|
Index = (int)player.Index,
|
||||||
|
SteamId = player?.SteamID,
|
||||||
|
Name = player?.PlayerName,
|
||||||
|
IpAddress = player?.IpAddress?.Split(":")[0]
|
||||||
|
};
|
||||||
|
if (weaponSync != null)
|
||||||
|
_ = weaponSync.GetKnifeFromDatabase(playerInfo);
|
||||||
|
}
|
||||||
|
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE | CounterStrikeSharp.API.Modules.Timers.TimerFlags.REPEAT);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
private HookResult OnPlayerConnectFull(EventPlayerConnectFull @event, GameEventInfo info)
|
||||||
|
{
|
||||||
|
CCSPlayerController? player = @event.Userid;
|
||||||
|
|
||||||
|
if (player == null || !player.IsValid || player.IsBot || player.IsHLTV || weaponSync == null) return HookResult.Continue;
|
||||||
|
|
||||||
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
|
{
|
||||||
|
UserId = player.UserId,
|
||||||
|
Index = (int)player.Index,
|
||||||
|
SteamId = player?.SteamID,
|
||||||
|
Name = player?.PlayerName,
|
||||||
|
IpAddress = player?.IpAddress?.Split(":")[0]
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!g_playersDatabaseIndex.ContainsKey((int)player!.Index))
|
||||||
|
{
|
||||||
|
Console.WriteLine($"[WeaponPaints] Retrying to retrieve player {player.PlayerName} skins");
|
||||||
|
Task.Run(async () =>
|
||||||
|
{
|
||||||
|
await weaponSync.GetPlayerDatabaseIndex(playerInfo);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return HookResult.Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
private HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
|
private HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
|
||||||
{
|
{
|
||||||
CCSPlayerController? player = @event.Userid;
|
CCSPlayerController? player = @event.Userid;
|
||||||
|
if (player == null || !player.IsValid)
|
||||||
if (player is null || !player.IsValid || player.PlayerPawn == null ||
|
|
||||||
!player.PlayerPawn.IsValid || player.IsHLTV
|
|
||||||
|| !Config.Additional.KnifeEnabled && !Config.Additional.GloveEnabled)
|
|
||||||
return HookResult.Continue;
|
|
||||||
|
|
||||||
g_knifePickupCount[player.Slot] = 0;
|
|
||||||
if (!PlayerHasKnife(player))
|
|
||||||
GiveKnifeToPlayer(player);
|
|
||||||
|
|
||||||
Server.NextFrame(() =>
|
|
||||||
{
|
{
|
||||||
RefreshGloves(player);
|
return HookResult.Continue;
|
||||||
});
|
}
|
||||||
|
|
||||||
|
if (Config.AdditionalSetting.KnifeEnabled && !PlayerHasKnife(player))
|
||||||
|
{
|
||||||
|
g_knifePickupCount[(int)player.Index] = 0;
|
||||||
|
GiveKnifeToPlayer(player);
|
||||||
|
//AddTimer(0.1f, () => GiveKnifeToPlayer(player));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (Config.AdditionalSetting.SkinVisibilityFix)
|
||||||
|
{
|
||||||
|
AddTimer(0.3f, () => RefreshSkins(player));
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
}
|
}
|
||||||
@@ -207,7 +254,6 @@ namespace WeaponPaints
|
|||||||
private HookResult OnRoundEnd(EventRoundEnd @event, GameEventInfo info)
|
private HookResult OnRoundEnd(EventRoundEnd @event, GameEventInfo info)
|
||||||
{
|
{
|
||||||
g_bCommandsAllowed = false;
|
g_bCommandsAllowed = false;
|
||||||
|
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,92 +267,87 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnTick()
|
private void OnTick()
|
||||||
{
|
{
|
||||||
foreach (var player in Utilities.GetPlayers().Where(p =>
|
foreach (var player in Utilities.GetPlayers())
|
||||||
p is not null && p.IsValid &&
|
|
||||||
(LifeState_t)p.LifeState == LifeState_t.LIFE_ALIVE && p.SteamID.ToString().Length == 17
|
|
||||||
&& !p.IsBot && !p.IsHLTV && p.Connected == PlayerConnectedState.PlayerConnected && p.Team != CounterStrikeSharp.API.Modules.Utils.CsTeam.None
|
|
||||||
)
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (Config.Additional.ShowSkinImage && PlayerWeaponImage.ContainsKey(player.Slot) && !string.IsNullOrEmpty(PlayerWeaponImage[player.Slot]))
|
if (player == null || !player.IsValid || !player.PawnIsAlive || player.IsBot || player.IsHLTV || player.Connected == PlayerConnectedState.PlayerDisconnecting) continue;
|
||||||
{
|
|
||||||
player.PrintToCenterHtml("<img src='{PATH}'</img>".Replace("{PATH}", PlayerWeaponImage[player.Slot]));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (player.PlayerPawn?.IsValid != true || player.PlayerPawn?.Value?.IsValid != true)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
var viewModels = GetPlayerViewModels(player);
|
var viewModels = GetPlayerViewModels(player);
|
||||||
if (viewModels == null || viewModels.Length == 0)
|
|
||||||
continue;
|
if (viewModels == null) continue;
|
||||||
|
|
||||||
var viewModel = viewModels[0];
|
var viewModel = viewModels[0];
|
||||||
if (viewModel == null || viewModel.Value == null || viewModel.Value.Weapon == null || viewModel.Value.Weapon.Value == null)
|
if (viewModel == null || viewModel.Value == null || viewModel.Value.Weapon == null || viewModel.Value.Weapon.Value == null) continue;
|
||||||
continue;
|
CBasePlayerWeapon weapon = viewModel.Value.Weapon.Value;
|
||||||
|
|
||||||
var weapon = viewModel.Value.Weapon.Value;
|
if (weapon == null || !weapon.IsValid) continue;
|
||||||
if (weapon == null || !weapon.IsValid || weapon.FallbackPaintKit == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (viewModel.Value.VMName.Contains("knife"))
|
var isKnife = viewModel.Value.VMName.Contains("knife");
|
||||||
continue;
|
|
||||||
|
|
||||||
var sceneNode = viewModel.Value.CBodyComponent?.SceneNode;
|
if (!isKnife)
|
||||||
if (sceneNode == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
var skeleton = GetSkeletonInstance(sceneNode);
|
|
||||||
if (skeleton == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
bool skeletonChange = false;
|
|
||||||
|
|
||||||
int[] newPaints = { 1171, 1170, 1169, 1164, 1162, 1161, 1159, 1175, 1174, 1167, 1165, 1168, 1163, 1160, 1166, 1173 };
|
|
||||||
if (newPaints.Contains(weapon.FallbackPaintKit))
|
|
||||||
{
|
{
|
||||||
if (skeleton.ModelState.MeshGroupMask != 1)
|
if (
|
||||||
|
viewModel.Value.CBodyComponent != null
|
||||||
|
&& viewModel.Value.CBodyComponent.SceneNode != null
|
||||||
|
&& weapon.CBodyComponent!.SceneNode!.GetSkeletonInstance().ModelState.MeshGroupMask != 2
|
||||||
|
)
|
||||||
{
|
{
|
||||||
skeleton.ModelState.MeshGroupMask = 1;
|
weapon.CBodyComponent!.SceneNode!.GetSkeletonInstance().ModelState.MeshGroupMask = 2;
|
||||||
skeletonChange = true;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (skeleton.ModelState.MeshGroupMask != 2)
|
|
||||||
{
|
|
||||||
skeleton.ModelState.MeshGroupMask = 2;
|
|
||||||
skeletonChange = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (skeletonChange)
|
|
||||||
Utilities.SetStateChanged(viewModel.Value, "CBaseEntity", "m_CBodyComponent");
|
Utilities.SetStateChanged(viewModel.Value, "CBaseEntity", "m_CBodyComponent");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{ }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RegisterListeners()
|
private void RegisterListeners()
|
||||||
{
|
{
|
||||||
RegisterListener<Listeners.OnEntitySpawned>(OnEntityCreated);
|
RegisterListener<Listeners.OnEntityCreated>(OnEntityCreated);
|
||||||
//RegisterListener<Listeners.OnClientPutInServer>(OnClientPutInServer);
|
RegisterListener<Listeners.OnClientPutInServer>(OnClientPutInServer);
|
||||||
//RegisterListener<Listeners.OnClientDisconnect>(OnClientDisconnect);
|
RegisterListener<Listeners.OnClientDisconnect>(OnClientDisconnect);
|
||||||
RegisterListener<Listeners.OnMapStart>(OnMapStart);
|
RegisterListener<Listeners.OnMapStart>(OnMapStart);
|
||||||
RegisterListener<Listeners.OnTick>(OnTick);
|
|
||||||
|
|
||||||
|
if (!Config.AdditionalSetting.UseMetamodAlwaysLegacyModel)
|
||||||
|
RegisterListener<Listeners.OnTick>(OnTick);
|
||||||
|
|
||||||
|
RegisterEventHandler<EventPlayerConnectFull>(OnPlayerConnectFull);
|
||||||
RegisterEventHandler<EventPlayerSpawn>(OnPlayerSpawn);
|
RegisterEventHandler<EventPlayerSpawn>(OnPlayerSpawn);
|
||||||
RegisterEventHandler<EventRoundStart>(OnRoundStart, HookMode.Pre);
|
RegisterEventHandler<EventRoundStart>(OnRoundStart, HookMode.Pre);
|
||||||
RegisterEventHandler<EventRoundEnd>(OnRoundEnd);
|
RegisterEventHandler<EventRoundEnd>(OnRoundEnd);
|
||||||
|
RegisterEventHandler<EventItemPurchase>(OnEventItemPurchasePost);
|
||||||
//RegisterEventHandler<EventItemPickup>(OnItemPickup);
|
//RegisterEventHandler<EventItemPickup>(OnItemPickup);
|
||||||
|
HookEntityOutput("weapon_knife", "OnPlayerPickup", OnPickup, HookMode.Pre);
|
||||||
|
}
|
||||||
|
|
||||||
HookEntityOutput("weapon_knife", "OnPlayerPickup", OnPickup);
|
|
||||||
|
/* WORKAROUND FOR CLIENTS WITHOUT STEAMID ON AUTHORIZATION */
|
||||||
|
/*private HookResult OnPlayerConnectFull(EventPlayerConnectFull @event, GameEventInfo info)
|
||||||
|
{
|
||||||
|
CCSPlayerController? player = @event.Userid;
|
||||||
|
|
||||||
|
if (player == null || !player.IsValid || !player.EntityIndex.HasValue || player.IsHLTV) return HookResult.Continue;
|
||||||
|
|
||||||
|
int playerIndex = (int)player.EntityIndex.Value.Value;
|
||||||
|
if (Config.AdditionalSetting.SkinEnabled && weaponSync != null)
|
||||||
|
_ = weaponSync.GetWeaponPaintsFromDatabase(playerIndex);
|
||||||
|
if (Config.AdditionalSetting.KnifeEnabled && weaponSync != null)
|
||||||
|
_ = weaponSync.GetKnifeFromDatabase(playerIndex);
|
||||||
|
|
||||||
|
Task.Run(async () =>
|
||||||
|
{
|
||||||
|
if (Config.AdditionalSetting.SkinEnabled && weaponSync != null)
|
||||||
|
if (Config.AdditionalSetting.KnifeEnabled && weaponSync != null)
|
||||||
|
});
|
||||||
|
|
||||||
|
return HookResult.Continue;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,10 +3,9 @@
|
|||||||
public class PlayerInfo
|
public class PlayerInfo
|
||||||
{
|
{
|
||||||
public int Index { get; set; }
|
public int Index { get; set; }
|
||||||
public int Slot { get; set; }
|
|
||||||
public int? UserId { get; set; }
|
public int? UserId { get; set; }
|
||||||
public string? SteamId { get; set; }
|
public ulong? SteamId { get; set; }
|
||||||
public string? Name { get; set; }
|
public string? Name { get; set; }
|
||||||
public string? IpAddress { get; set; }
|
public string? IpAddress { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
27
README.md
@@ -10,7 +10,7 @@ Unfinished, unoptimized and not fully functional ugly demo weapon paints plugin
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
- Changes only paint, seed and wear on weapons and knives
|
- Changes only paint, seed and wear on weapons and knives
|
||||||
- MySQL based
|
- MySQL(min. ver 5.6.5) based or global website, so you dont need MySQL/Website
|
||||||
- Data syncs on player connect
|
- Data syncs on player connect
|
||||||
- Added command **`!wp`** to refresh skins ***(with cooldown in seconds 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
|
||||||
@@ -18,11 +18,13 @@ Unfinished, unoptimized and not fully functional ugly demo weapon paints plugin
|
|||||||
- Knife change is now limited to have these cvars empty **`mp_t_default_melee ""`** and **`mp_ct_default_melee ""`**
|
- 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
|
- Translations support, submit a PR if you want to share your translation
|
||||||
|
|
||||||
|
**GlobalShare** - global website accessible at [weaponpaints.fun](https://weaponpaints.fun/)
|
||||||
|
|
||||||
## CS2 Server
|
## CS2 Server
|
||||||
- Have working CounterStrikeSharp (**with RUNTIME!**)
|
- Have working CounterStrikeSharp (**with RUNTIME!**)
|
||||||
- Download from Release and copy plugin to plugins
|
- Download from Release and copy plugin to plugins
|
||||||
- Run server with plugin, **it will generate config if installed correctly!**
|
- Run server with plugin, it will generate config if installed correctly
|
||||||
- Edit `addons/counterstrikesharp/configs/`**`plugins/WeaponPaints/WeaponPaints.json`** include database credentials
|
- Edit `addons/counterstrikesharp/configs/`**`plugins/WeaponPaints/WeaponPaints.json`** set **`GlobalShare`** to **`true`** for global, or include database credentials
|
||||||
- In `addons/counterstrikesharp/configs/`**`core.json`** set **FollowCS2ServerGuidelines** to **`false`**
|
- In `addons/counterstrikesharp/configs/`**`core.json`** set **FollowCS2ServerGuidelines** to **`false`**
|
||||||
|
|
||||||
## Plugin Configuration
|
## Plugin Configuration
|
||||||
@@ -30,11 +32,12 @@ Unfinished, unoptimized and not fully functional ugly demo weapon paints plugin
|
|||||||
<summary>Click to expand</summary>
|
<summary>Click to expand</summary>
|
||||||
<code><pre>{
|
<code><pre>{
|
||||||
"Version": 4, // Don't touch
|
"Version": 4, // Don't touch
|
||||||
"DatabaseHost": "", // MySQL host
|
"DatabaseHost": "", // MySQL host (required if GlobalShare = false)
|
||||||
"DatabasePort": 3306, // MySQL port
|
"DatabasePort": 3306, // MySQL port (required if GlobalShare = false)
|
||||||
"DatabaseUser": "", // MySQL username
|
"DatabaseUser": "", // MySQL username (required if GlobalShare = false)
|
||||||
"DatabasePassword": "", // MySQL user password
|
"DatabasePassword": "", // MySQL user password (required if GlobalShare = false)
|
||||||
"DatabaseName": "", // MySQL database name
|
"DatabaseName": "", // MySQL database name (required if GlobalShare = false)
|
||||||
|
"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)
|
||||||
@@ -71,7 +74,9 @@ Unfinished, unoptimized and not fully functional ugly demo weapon paints plugin
|
|||||||
</details>
|
</details>
|
||||||
|
|
||||||
## Web install
|
## Web install
|
||||||
- Requires PHP >= 7.4 ***(Tested on php ver **`8.2.3`** and nginx webserver)***
|
Ignore this section if you have in config **`GlobalShare = true`**
|
||||||
|
- Minimum PHP version 5.5 (needs testing)
|
||||||
|
- Minimum MySQL version 5.6.5
|
||||||
- **Before using website, make sure the plugin is correctly loaded in cs2 server!** Mysql tables are created by plugin not by website.
|
- **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)
|
||||||
@@ -85,7 +90,6 @@ Unfinished, unoptimized and not fully functional ugly demo weapon paints plugin
|
|||||||
|
|
||||||
## 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
|
- Can cause incompatibility with plugins/maps which manipulates weapons and knives
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
@@ -98,9 +102,6 @@ Plugin is not loaded or configured with mysql credentials. Tables are auto-creat
|
|||||||
|
|
||||||
**Knives are disappearing:**
|
**Knives are disappearing:**
|
||||||
Set in config GiveKnifeAfterRemove to true
|
Set in config GiveKnifeAfterRemove to true
|
||||||
|
|
||||||
**Knives are not changing for players:**
|
|
||||||
You can't change knife if you have your own equipped
|
|
||||||
</details>
|
</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/)
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
96
Utility.cs
@@ -1,11 +1,11 @@
|
|||||||
using CounterStrikeSharp.API.Core;
|
using CounterStrikeSharp.API.Core;
|
||||||
using CounterStrikeSharp.API.Modules.Utils;
|
using CounterStrikeSharp.API.Modules.Utils;
|
||||||
using Dapper;
|
using Dapper;
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using MySqlConnector;
|
using MySqlConnector;
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace WeaponPaints
|
namespace WeaponPaints
|
||||||
{
|
{
|
||||||
@@ -23,51 +23,35 @@ namespace WeaponPaints
|
|||||||
Password = Config.DatabasePassword,
|
Password = Config.DatabasePassword,
|
||||||
Database = Config.DatabaseName,
|
Database = Config.DatabaseName,
|
||||||
Port = (uint)Config.DatabasePort,
|
Port = (uint)Config.DatabasePort,
|
||||||
Pooling = true
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return builder.ConnectionString;
|
return builder.ConnectionString;
|
||||||
}
|
}
|
||||||
|
internal static async void CheckDatabaseTables()
|
||||||
internal static async Task CheckDatabaseTables()
|
|
||||||
{
|
{
|
||||||
if (WeaponPaints._database is null) return;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await using var connection = await WeaponPaints._database.GetConnectionAsync();
|
using var connection = new MySqlConnection(BuildDatabaseConnectionString());
|
||||||
|
await connection.OpenAsync();
|
||||||
|
|
||||||
await using var transaction = await connection.BeginTransactionAsync();
|
using var transaction = await connection.BeginTransactionAsync();
|
||||||
|
|
||||||
try
|
// Minimal version for MySQL 5.6.5
|
||||||
|
string[] sqlCommands = new string[]
|
||||||
|
{
|
||||||
|
"CREATE TABLE IF NOT EXISTS `wp_users` (`id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `steamid` BIGINT UNSIGNED NOT NULL, `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `unique_steamid` (`steamid`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;",
|
||||||
|
"CREATE TABLE IF NOT EXISTS `wp_users_items` (`user_id` INT UNSIGNED NOT NULL, `weapon` SMALLINT UNSIGNED NOT NULL, `paint` SMALLINT UNSIGNED NOT NULL, `wear` FLOAT NOT NULL DEFAULT 0.00001, `seed` SMALLINT UNSIGNED NOT NULL DEFAULT 0, `nametag` VARCHAR(20) DEFAULT NULL, `stattrack` INT UNSIGNED NOT NULL DEFAULT 0, `stattrack_enabled` SMALLINT NOT NULL DEFAULT 0, `quality` SMALLINT UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (`user_id`,`weapon`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;",
|
||||||
|
"CREATE TABLE IF NOT EXISTS `wp_users_knife` (`user_id` INT UNSIGNED NOT NULL, `knife` VARCHAR(32) DEFAULT NULL, PRIMARY KEY (`user_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;",
|
||||||
|
"CREATE TABLE IF NOT EXISTS `wp_users_music` (`user_id` INT UNSIGNED NOT NULL, `music` SMALLINT UNSIGNED DEFAULT NULL, PRIMARY KEY (`user_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;"
|
||||||
|
};
|
||||||
|
try
|
||||||
{
|
{
|
||||||
string[] createTableQueries = new[]
|
foreach (string command in sqlCommands)
|
||||||
{
|
{
|
||||||
@"CREATE TABLE IF NOT EXISTS `wp_player_skins` (
|
await connection.ExecuteAsync(command, transaction: transaction);
|
||||||
`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 transaction.CommitAsync();
|
||||||
{
|
|
||||||
await connection.ExecuteAsync(query, transaction: transaction);
|
|
||||||
}
|
|
||||||
|
|
||||||
await transaction.CommitAsync();
|
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
@@ -77,43 +61,25 @@ namespace WeaponPaints
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new Exception("[WeaponPaints] Unknown MySQL exception! " + ex.Message);
|
throw new Exception("[WeaponPaints] Unknown mysql exception! " + ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static bool IsPlayerValid(CCSPlayerController? player)
|
internal static bool IsPlayerValid(CCSPlayerController? player)
|
||||||
{
|
{
|
||||||
if (player is null) return false;
|
return (player != null && player.IsValid && !player.IsBot && !player.IsHLTV && player.AuthorizedSteamID != null);
|
||||||
|
|
||||||
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)
|
internal static void LoadSkinsFromFile(string filePath)
|
||||||
{
|
{
|
||||||
try
|
if (File.Exists(filePath))
|
||||||
{
|
{
|
||||||
string json = File.ReadAllText(filePath);
|
string json = File.ReadAllText(filePath);
|
||||||
var deserializedSkins = JsonConvert.DeserializeObject<List<JObject>>(json);
|
var deserializedSkins = JsonConvert.DeserializeObject<List<JObject>>(json);
|
||||||
WeaponPaints.skinsList = deserializedSkins ?? new List<JObject>();
|
WeaponPaints.skinsList = deserializedSkins ?? new List<JObject>();
|
||||||
}
|
}
|
||||||
catch (FileNotFoundException)
|
else
|
||||||
{
|
{
|
||||||
throw;
|
throw new FileNotFoundException("File not found.", filePath);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,11 +120,11 @@ namespace WeaponPaints
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
HttpResponseMessage response = await client.GetAsync("https://raw.githubusercontent.com/Nereziel/cs2-WeaponPaints/main/VERSION").ConfigureAwait(false);
|
HttpResponseMessage response = await client.GetAsync("https://raw.githubusercontent.com/Nereziel/cs2-WeaponPaints/main/VERSION");
|
||||||
|
|
||||||
if (response.IsSuccessStatusCode)
|
if (response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
string remoteVersion = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
string remoteVersion = await response.Content.ReadAsStringAsync();
|
||||||
remoteVersion = remoteVersion.Trim();
|
remoteVersion = remoteVersion.Trim();
|
||||||
|
|
||||||
int comparisonResult = string.Compare(version, remoteVersion);
|
int comparisonResult = string.Compare(version, remoteVersion);
|
||||||
@@ -181,13 +147,9 @@ namespace WeaponPaints
|
|||||||
logger.LogWarning("Failed to check version");
|
logger.LogWarning("Failed to check version");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (HttpRequestException ex)
|
|
||||||
{
|
|
||||||
logger.LogError(ex, "Failed to connect to the version server.");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
logger.LogError(ex, "An error occurred while checking version.");
|
Console.WriteLine(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -207,7 +169,6 @@ namespace WeaponPaints
|
|||||||
Console.WriteLine(" ");
|
Console.WriteLine(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*(
|
|
||||||
internal static void TestDatabaseConnection()
|
internal static void TestDatabaseConnection()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -226,6 +187,5 @@ namespace WeaponPaints
|
|||||||
}
|
}
|
||||||
CheckDatabaseTables();
|
CheckDatabaseTables();
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
518
WeaponAction.cs
@@ -1,7 +1,6 @@
|
|||||||
using CounterStrikeSharp.API;
|
using CounterStrikeSharp.API;
|
||||||
using CounterStrikeSharp.API.Core;
|
using CounterStrikeSharp.API.Core;
|
||||||
using CounterStrikeSharp.API.Modules.Memory;
|
using CounterStrikeSharp.API.Modules.Memory;
|
||||||
using CounterStrikeSharp.API.Modules.Timers;
|
|
||||||
using CounterStrikeSharp.API.Modules.Utils;
|
using CounterStrikeSharp.API.Modules.Utils;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
@@ -12,23 +11,23 @@ namespace WeaponPaints
|
|||||||
{
|
{
|
||||||
internal static void ChangeWeaponAttributes(CBasePlayerWeapon? weapon, CCSPlayerController? player, bool isKnife = false)
|
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 (player == null || weapon == null || !weapon.IsValid || !Utility.IsPlayerValid(player)) return;
|
||||||
|
|
||||||
if (!gPlayerWeaponsInfo.ContainsKey(player.Slot)) return;
|
int playerIndex = (int)player.Index;
|
||||||
|
|
||||||
if (isKnife && !g_playersKnife.ContainsKey(player.Slot) || isKnife && g_playersKnife[player.Slot] == "weapon_knife") return;
|
if (!gPlayerWeaponsInfo.ContainsKey(playerIndex)) return;
|
||||||
|
|
||||||
int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;
|
if (isKnife && !g_playersKnife.ContainsKey(playerIndex) || isKnife && g_playersKnife[playerIndex] == "weapon_knife") return;
|
||||||
|
|
||||||
|
ushort weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;
|
||||||
|
|
||||||
if (isKnife)
|
if (isKnife)
|
||||||
{
|
{
|
||||||
weapon.AttributeManager.Item.EntityQuality = 3;
|
weapon.AttributeManager.Item.EntityQuality = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fallbackPaintKit = weapon.FallbackPaintKit;
|
if (_config.AdditionalSetting.GiveRandomSkin &&
|
||||||
|
!gPlayerWeaponsInfo[playerIndex].ContainsKey(weaponDefIndex))
|
||||||
if (_config.Additional.GiveRandomSkin &&
|
|
||||||
!gPlayerWeaponsInfo[player.Slot].ContainsKey(weaponDefIndex))
|
|
||||||
{
|
{
|
||||||
// Random skins
|
// Random skins
|
||||||
weapon.AttributeManager.Item.ItemID = 16384;
|
weapon.AttributeManager.Item.ItemID = 16384;
|
||||||
@@ -36,57 +35,19 @@ namespace WeaponPaints
|
|||||||
weapon.AttributeManager.Item.ItemIDHigh = weapon.AttributeManager.Item.ItemIDLow >> 32;
|
weapon.AttributeManager.Item.ItemIDHigh = weapon.AttributeManager.Item.ItemIDLow >> 32;
|
||||||
weapon.FallbackPaintKit = GetRandomPaint(weaponDefIndex);
|
weapon.FallbackPaintKit = GetRandomPaint(weaponDefIndex);
|
||||||
weapon.FallbackSeed = 0;
|
weapon.FallbackSeed = 0;
|
||||||
weapon.FallbackWear = 0.000001f;
|
weapon.FallbackWear = 0.00001f;
|
||||||
|
|
||||||
fallbackPaintKit = weapon.FallbackPaintKit;
|
|
||||||
|
|
||||||
if (fallbackPaintKit == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var foundSkin = skinsList.FirstOrDefault(skin =>
|
|
||||||
((int?)skin?["weapon_defindex"] ?? 0) == weaponDefIndex &&
|
|
||||||
((int?)skin?["paint"] ?? 0) == fallbackPaintKit &&
|
|
||||||
skin?["paint_name"] != null
|
|
||||||
);
|
|
||||||
|
|
||||||
string skinName = foundSkin?["paint_name"]?.ToString() ?? "";
|
|
||||||
if (!string.IsNullOrEmpty(skinName))
|
|
||||||
new SchemaString<CEconItemView>(weapon.AttributeManager.Item, "m_szCustomName").Set(skinName);
|
|
||||||
|
|
||||||
if (!isKnife && weapon.CBodyComponent != null && weapon.CBodyComponent.SceneNode != null)
|
if (!isKnife && weapon.CBodyComponent != null && weapon.CBodyComponent.SceneNode != null)
|
||||||
{
|
{
|
||||||
var skeleton = GetSkeletonInstance(weapon.CBodyComponent.SceneNode);
|
if (weapon.CBodyComponent!.SceneNode!.GetSkeletonInstance().ModelState.MeshGroupMask != 2)
|
||||||
|
|
||||||
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;
|
weapon.CBodyComponent!.SceneNode!.GetSkeletonInstance().ModelState.MeshGroupMask = 2;
|
||||||
}
|
|
||||||
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gPlayerWeaponsInfo[player.Slot].ContainsKey(weaponDefIndex)) return;
|
if (!gPlayerWeaponsInfo[playerIndex].ContainsKey(weaponDefIndex)) return;
|
||||||
WeaponInfo weaponInfo = gPlayerWeaponsInfo[player.Slot][weaponDefIndex];
|
WeaponInfo weaponInfo = gPlayerWeaponsInfo[playerIndex][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]}");
|
//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.ItemID = 16384;
|
||||||
weapon.AttributeManager.Item.ItemIDLow = 16384 & 0xFFFFFFFF;
|
weapon.AttributeManager.Item.ItemIDLow = 16384 & 0xFFFFFFFF;
|
||||||
@@ -95,83 +56,44 @@ namespace WeaponPaints
|
|||||||
weapon.FallbackSeed = weaponInfo.Seed;
|
weapon.FallbackSeed = weaponInfo.Seed;
|
||||||
weapon.FallbackWear = weaponInfo.Wear;
|
weapon.FallbackWear = weaponInfo.Wear;
|
||||||
|
|
||||||
fallbackPaintKit = weapon.FallbackPaintKit;
|
if (!isKnife && weapon.CBodyComponent != null && weapon.CBodyComponent.SceneNode != null)
|
||||||
|
|
||||||
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);
|
if (weapon.CBodyComponent!.SceneNode!.GetSkeletonInstance().ModelState.MeshGroupMask != 2)
|
||||||
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;
|
weapon.CBodyComponent!.SceneNode!.GetSkeletonInstance().ModelState.MeshGroupMask = 2;
|
||||||
}
|
}
|
||||||
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)
|
internal static void GiveKnifeToPlayer(CCSPlayerController? player)
|
||||||
{
|
{
|
||||||
if (!_config.Additional.KnifeEnabled || player == null || !player.IsValid) return;
|
if (!_config.AdditionalSetting.KnifeEnabled || player == null || !player.IsValid) return;
|
||||||
|
|
||||||
string knifeToGive;
|
if (g_playersKnife.TryGetValue((int)player.Index, out var knife))
|
||||||
if (g_playersKnife.TryGetValue(player.Slot, out var knife))
|
|
||||||
{
|
{
|
||||||
knifeToGive = knife;
|
player.GiveNamedItem(knife);
|
||||||
}
|
}
|
||||||
else if (_config.Additional.GiveRandomKnife)
|
else if (_config.AdditionalSetting.GiveRandomKnife)
|
||||||
{
|
{
|
||||||
var knifeTypes = weaponList.Where(pair => pair.Key.StartsWith("weapon_knife") || pair.Key.StartsWith("weapon_bayonet")).ToList();
|
var knifeTypes = weaponList.Where(pair => pair.Key.StartsWith("weapon_knife") || pair.Key.StartsWith("weapon_bayonet")).ToDictionary(pair => pair.Key, pair => pair.Value);
|
||||||
|
|
||||||
if (knifeTypes.Count == 0)
|
|
||||||
{
|
|
||||||
Utility.Log("No valid knife types found.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Random random = new();
|
Random random = new();
|
||||||
int index = random.Next(knifeTypes.Count);
|
int index = random.Next(knifeTypes.Count);
|
||||||
knifeToGive = knifeTypes[index].Key;
|
var randomKnifeClass = knifeTypes.Keys.ElementAt(index);
|
||||||
|
|
||||||
|
player.GiveNamedItem(randomKnifeClass);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
knifeToGive = (CsTeam)player.TeamNum == CsTeam.Terrorist ? "weapon_knife_t" : "weapon_knife";
|
var defaultKnife = (CsTeam)player.TeamNum == CsTeam.Terrorist ? "weapon_knife_t" : "weapon_knife";
|
||||||
|
player.GiveNamedItem(defaultKnife);
|
||||||
}
|
}
|
||||||
|
|
||||||
player.GiveNamedItem(knifeToGive);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static bool PlayerHasKnife(CCSPlayerController? player)
|
internal static bool PlayerHasKnife(CCSPlayerController? player)
|
||||||
{
|
{
|
||||||
if (!_config.Additional.KnifeEnabled) return false;
|
if (!_config.AdditionalSetting.KnifeEnabled) return false;
|
||||||
|
|
||||||
if (player == null || !player.IsValid || player.PlayerPawn == null || !player.PlayerPawn.IsValid || !player.PawnIsAlive)
|
if (player == null || !player.IsValid || player.PlayerPawn == null || !player.PlayerPawn.IsValid || !player.PawnIsAlive)
|
||||||
{
|
{
|
||||||
@@ -196,235 +118,207 @@ namespace WeaponPaints
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void RefreshWeapons(CCSPlayerController? player)
|
internal void RefreshPlayerKnife(CCSPlayerController? player)
|
||||||
{
|
{
|
||||||
if (player == null || !player.IsValid || player.PlayerPawn?.Value == null || (LifeState_t)player.LifeState != LifeState_t.LIFE_ALIVE)
|
if (player == null || !player.IsValid || player.PlayerPawn.Value == null || !player.PawnIsAlive) return;
|
||||||
return;
|
if (player.PlayerPawn.Value.WeaponServices == null || player.PlayerPawn.Value.ItemServices == null) 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;
|
|
||||||
|
|
||||||
//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));
|
|
||||||
}
|
|
||||||
|
|
||||||
//player.RemoveItemByDesignerName(weapon.Value.DesignerName, false);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Logger.LogWarning(ex.Message);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++)
|
|
||||||
{
|
|
||||||
player.ExecuteClientCommand($"slot {i}");
|
|
||||||
player.ExecuteClientCommand($"slot {i}");
|
|
||||||
|
|
||||||
AddTimer(0.1f, () =>
|
|
||||||
{
|
|
||||||
var weapon = player.PlayerPawn.Value.WeaponServices.ActiveWeapon.Value;
|
|
||||||
CCSWeaponBaseGun? gun = weapon?.As<CCSWeaponBaseGun>();
|
|
||||||
player.DropActiveWeapon();
|
|
||||||
|
|
||||||
AddTimer(0.22f, () =>
|
|
||||||
{
|
|
||||||
if (gun != null && gun.IsValid && gun.State == CSWeaponState_t.WEAPON_NOT_CARRIED)
|
|
||||||
{
|
|
||||||
weapon?.Remove();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
AddTimer(1.2f, () =>
|
|
||||||
{
|
|
||||||
GiveKnifeToPlayer(player);
|
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
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;
|
var weapons = player.PlayerPawn.Value.WeaponServices.MyWeapons;
|
||||||
if (weapons != null && weapons.Count > 0)
|
if (weapons != null && weapons.Count > 0)
|
||||||
{
|
{
|
||||||
|
CCSPlayer_ItemServices service = new(player.PlayerPawn.Value.ItemServices.Handle);
|
||||||
|
//var dropWeapon = VirtualFunction.CreateVoid<nint, nint>(service.Handle, GameData.GetOffset("CCSPlayer_ItemServices_DropActivePlayerWeapon"));
|
||||||
|
|
||||||
foreach (var weapon in weapons)
|
foreach (var weapon in weapons)
|
||||||
{
|
{
|
||||||
if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid && weapon.Index > 0)
|
if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid)
|
||||||
{
|
{
|
||||||
|
//if (weapon.Value.AttributeManager.Item.ItemDefinitionIndex == 42 || weapon.Value.AttributeManager.Item.ItemDefinitionIndex == 59)
|
||||||
|
if (weapon.Value.DesignerName.Contains("knife") || weapon.Value.DesignerName.Contains("bayonet"))
|
||||||
|
{
|
||||||
|
if (weapon.Index <= 0) return;
|
||||||
|
int weaponEntityIndex = (int)weapon.Index;
|
||||||
|
NativeAPI.IssueClientCommand((int)player.Index - 1, "slot3");
|
||||||
|
AddTimer(0.22f, () =>
|
||||||
|
{
|
||||||
|
if (player.PlayerPawn.Value.WeaponServices.ActiveWeapon.Value!.DesignerName.Contains("knife")
|
||||||
|
||
|
||||||
|
player.PlayerPawn.Value.WeaponServices.ActiveWeapon.Value!.DesignerName.Contains("bayonet")
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (player.PawnIsAlive)
|
||||||
|
{
|
||||||
|
NativeAPI.IssueClientCommand((int)player.Index - 1, "slot3");
|
||||||
|
service.DropActivePlayerWeapon(weapon.Value);
|
||||||
|
GiveKnifeToPlayer(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Task.Delay(TimeSpan.FromSeconds(3.5)).ContinueWith(_ =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
CEntityInstance? knife = Utilities.GetEntityFromIndex<CEntityInstance>(weaponEntityIndex);
|
||||||
|
|
||||||
|
if (knife != null && knife.IsValid && knife.Handle != -1 && knife.Index > 0)
|
||||||
|
{
|
||||||
|
knife.Remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception) { }
|
||||||
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
internal void RefreshSkins(CCSPlayerController? player)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
if (!Utility.IsPlayerValid(player) || !player!.PawnIsAlive) return;
|
||||||
|
|
||||||
|
AddTimer(0.18f, () => NativeAPI.IssueClientCommand((int)player.Index - 1, "slot3"));
|
||||||
|
AddTimer(0.25f, () => NativeAPI.IssueClientCommand((int)player.Index - 1, "slot2"));
|
||||||
|
AddTimer(0.38f, () => NativeAPI.IssueClientCommand((int)player.Index - 1, "slot1"));
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
internal void RefreshWeapons(CCSPlayerController? player)
|
||||||
|
{
|
||||||
|
if (player == null || !player.IsValid || player.PlayerPawn.Value == null || !player.PawnIsAlive) return;
|
||||||
|
if (player.PlayerPawn.Value.WeaponServices == null || player.PlayerPawn.Value.ItemServices == null) return;
|
||||||
|
|
||||||
|
var weapons = player.PlayerPawn.Value.WeaponServices.MyWeapons;
|
||||||
|
if (weapons != null && weapons.Count > 0)
|
||||||
|
{
|
||||||
|
CCSPlayer_ItemServices service = new(player.PlayerPawn.Value.ItemServices.Handle);
|
||||||
|
|
||||||
|
foreach (var weapon in weapons)
|
||||||
|
{
|
||||||
|
if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid)
|
||||||
|
{
|
||||||
|
if (weapon.Index <= 0 || !weapon.Value.DesignerName.Contains("weapon_")) continue;
|
||||||
|
//if (weapon.Value.AttributeManager.Item.ItemDefinitionIndex == 42 || weapon.Value.AttributeManager.Item.ItemDefinitionIndex == 59)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CCSWeaponBaseVData? weaponData = weapon.Value.As<CCSWeaponBase>().VData;
|
if (weapon.Value.DesignerName.Contains("knife") || weapon.Value.DesignerName.Contains("bayonet"))
|
||||||
|
|
||||||
if (weapon.Value.DesignerName.Contains("knife") || weaponData?.GearSlot == gear_slot_t.GEAR_SLOT_KNIFE)
|
|
||||||
{
|
{
|
||||||
RefreshWeapons(player);
|
player.RemoveItemByDesignerName(weapon.Value.DesignerName, true);
|
||||||
break;
|
GiveKnifeToPlayer(player);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!WeaponDefindex.ContainsKey(weapon.Value.AttributeManager.Item.ItemDefinitionIndex)) continue;
|
||||||
|
int clip1, reservedAmmo;
|
||||||
|
|
||||||
|
clip1 = weapon.Value.Clip1;
|
||||||
|
reservedAmmo = weapon.Value.ReserveAmmo[0];
|
||||||
|
|
||||||
|
string weaponByDefindex = WeaponDefindex[weapon.Value.AttributeManager.Item.ItemDefinitionIndex];
|
||||||
|
player.RemoveItemByDesignerName(weapon.Value.DesignerName, true);
|
||||||
|
CBasePlayerWeapon newWeapon = new(player.GiveNamedItem(weaponByDefindex));
|
||||||
|
|
||||||
|
Server.NextFrame(() =>
|
||||||
|
{
|
||||||
|
if (newWeapon == null) return;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newWeapon.Clip1 = clip1;
|
||||||
|
newWeapon.ReserveAmmo[0] = reservedAmmo;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{ }
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.LogWarning($"Cannot remove knife: {ex.Message}");
|
Logger.LogWarning("Refreshing weapons exception");
|
||||||
|
Console.WriteLine("[WeaponPaints] Refreshing weapons exception");
|
||||||
|
Console.WriteLine(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (Config.AdditionalSetting.SkinVisibilityFix)
|
||||||
|
RefreshSkins(player);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void RemovePlayerKnife(CCSPlayerController? player, bool force = false)
|
||||||
|
{
|
||||||
|
if (player == null || !player.IsValid || player.PlayerPawn.Value == null || !player.PawnIsAlive) return;
|
||||||
|
if (player.PlayerPawn.Value.WeaponServices == null || player.PlayerPawn.Value.ItemServices == null) return;
|
||||||
|
|
||||||
|
var weapons = player.PlayerPawn.Value.WeaponServices.MyWeapons;
|
||||||
|
if (weapons != null && weapons.Count > 0)
|
||||||
|
{
|
||||||
|
CCSPlayer_ItemServices service = new CCSPlayer_ItemServices(player.PlayerPawn.Value.ItemServices.Handle);
|
||||||
|
//var dropWeapon = VirtualFunction.CreateVoid<nint, nint>(service.Handle, GameData.GetOffset("CCSPlayer_ItemServices_DropActivePlayerWeapon"));
|
||||||
|
|
||||||
|
foreach (var weapon in weapons)
|
||||||
|
{
|
||||||
|
if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid)
|
||||||
|
{
|
||||||
|
//if (weapon.Value.AttributeManager.Item.ItemDefinitionIndex == 42 || weapon.Value.AttributeManager.Item.ItemDefinitionIndex == 59)
|
||||||
|
if (weapon.Value.DesignerName.Contains("knife") || weapon.Value.DesignerName.Contains("bayonet"))
|
||||||
|
{
|
||||||
|
if (!force)
|
||||||
|
{
|
||||||
|
if ((int)weapon.Index <= 0) return;
|
||||||
|
int weaponEntityIndex = (int)weapon.Index;
|
||||||
|
NativeAPI.IssueClientCommand((int)player.Index - 1, "slot3");
|
||||||
|
AddTimer(0.35f, () => service.DropActivePlayerWeapon(weapon.Value));
|
||||||
|
|
||||||
|
AddTimer(1.0f, () =>
|
||||||
|
{
|
||||||
|
CEntityInstance? knife = Utilities.GetEntityFromIndex<CEntityInstance>(weaponEntityIndex);
|
||||||
|
if (knife != null && knife.IsValid)
|
||||||
|
{
|
||||||
|
knife.Remove();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
weapon.Value.Remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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.2f, () =>
|
|
||||||
{
|
|
||||||
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)
|
private static int GetRandomPaint(int defindex)
|
||||||
{
|
{
|
||||||
if (skinsList == null || skinsList.Count == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
Random rnd = new Random();
|
if (skinsList != null)
|
||||||
|
{
|
||||||
// Filter weapons by the provided defindex
|
Random rnd = new Random();
|
||||||
var filteredWeapons = skinsList.Where(w => w["weapon_defindex"]?.ToString() == defindex.ToString()).ToList();
|
// Filter weapons by the provided defindex
|
||||||
|
var filteredWeapons = skinsList.FindAll(w => w["weapon_defindex"]?.ToString() == defindex.ToString());
|
||||||
if (filteredWeapons.Count == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
var randomWeapon = filteredWeapons[rnd.Next(filteredWeapons.Count)];
|
|
||||||
|
|
||||||
if (int.TryParse(randomWeapon["paint"]?.ToString(), out int paintValue))
|
|
||||||
return paintValue;
|
|
||||||
|
|
||||||
|
if (filteredWeapons.Count > 0)
|
||||||
|
{
|
||||||
|
var randomWeapon = filteredWeapons[rnd.Next(filteredWeapons.Count)];
|
||||||
|
if (int.TryParse(randomWeapon["paint"]?.ToString(), out int paintValue))
|
||||||
|
{
|
||||||
|
return paintValue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
private static unsafe CHandle<CBaseViewModel>[]? GetPlayerViewModels(CCSPlayerController player)
|
||||||
{
|
{
|
||||||
if (player.PlayerPawn.Value == null || player.PlayerPawn.Value.ViewModelServices == null) return null;
|
if (player.PlayerPawn.Value == null || player.PlayerPawn.Value.ViewModelServices == null) return null;
|
||||||
|
|||||||
@@ -2,8 +2,12 @@
|
|||||||
{
|
{
|
||||||
public class WeaponInfo
|
public class WeaponInfo
|
||||||
{
|
{
|
||||||
public int Paint { get; set; }
|
public ushort Paint { get; set; }
|
||||||
public int Seed { get; set; } = 0;
|
public ushort Seed { get; set; }
|
||||||
public float Wear { get; set; } = 0f;
|
public float Wear { get; set; }
|
||||||
}
|
public string? NameTag { get; set; }
|
||||||
|
public ushort Quality { get; set; }
|
||||||
|
public uint StatTrack { get; set; }
|
||||||
|
public bool StatTrackEnabled { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
291
WeaponPaints.cs
@@ -1,19 +1,17 @@
|
|||||||
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.Memory.DynamicFunctions;
|
using CounterStrikeSharp.API.Modules.Cvars;
|
||||||
using Microsoft.Extensions.Localization;
|
using Microsoft.Extensions.Localization;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using MySqlConnector;
|
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
|
|
||||||
namespace WeaponPaints;
|
namespace WeaponPaints;
|
||||||
|
|
||||||
[MinimumApiVersion(168)]
|
[MinimumApiVersion(155)]
|
||||||
public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
||||||
{
|
{
|
||||||
internal static WeaponPaints Instance { get; private set; } = new();
|
|
||||||
internal static readonly Dictionary<string, string> weaponList = new()
|
internal static readonly Dictionary<string, string> weaponList = new()
|
||||||
{
|
{
|
||||||
{"weapon_deagle", "Desert Eagle"},
|
{"weapon_deagle", "Desert Eagle"},
|
||||||
@@ -38,7 +36,6 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
|||||||
{"weapon_negev", "Negev"},
|
{"weapon_negev", "Negev"},
|
||||||
{"weapon_sawedoff", "Sawed-Off"},
|
{"weapon_sawedoff", "Sawed-Off"},
|
||||||
{"weapon_tec9", "Tec-9"},
|
{"weapon_tec9", "Tec-9"},
|
||||||
{"weapon_taser", "Zeus x27"},
|
|
||||||
{"weapon_hkp2000", "P2000"},
|
{"weapon_hkp2000", "P2000"},
|
||||||
{"weapon_mp7", "MP7"},
|
{"weapon_mp7", "MP7"},
|
||||||
{"weapon_mp9", "MP9"},
|
{"weapon_mp9", "MP9"},
|
||||||
@@ -70,92 +67,86 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
|||||||
{ "weapon_knife_cord", "Paracord Knife" },
|
{ "weapon_knife_cord", "Paracord Knife" },
|
||||||
{ "weapon_knife_canis", "Survival Knife" },
|
{ "weapon_knife_canis", "Survival Knife" },
|
||||||
{ "weapon_knife_outdoor", "Nomad Knife" },
|
{ "weapon_knife_outdoor", "Nomad Knife" },
|
||||||
{ "weapon_knife_skeleton", "Skeleton Knife" },
|
{ "weapon_knife_skeleton", "Skeleton Knife" }
|
||||||
{ "weapon_knife_kukri", "Kukri Knife" }
|
|
||||||
};
|
};
|
||||||
|
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" },
|
||||||
|
{ 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" }
|
||||||
|
};
|
||||||
|
|
||||||
internal static WeaponPaintsConfig _config = new WeaponPaintsConfig();
|
internal static WeaponPaintsConfig _config = new WeaponPaintsConfig();
|
||||||
internal static IStringLocalizer? _localizer;
|
internal static IStringLocalizer? _localizer;
|
||||||
internal static Dictionary<int, int> g_knifePickupCount = new Dictionary<int, int>();
|
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, int> g_playersDatabaseIndex = new ConcurrentDictionary<int, int>();
|
||||||
internal static ConcurrentDictionary<int, ushort> g_playersGlove = new ConcurrentDictionary<int, ushort>();
|
internal static ConcurrentDictionary<int, string> g_playersKnife = new ConcurrentDictionary<int, string>();
|
||||||
internal static ConcurrentDictionary<int, ConcurrentDictionary<int, WeaponInfo>> gPlayerWeaponsInfo = new ConcurrentDictionary<int, ConcurrentDictionary<int, WeaponInfo>>();
|
internal static ConcurrentDictionary<int, int?> g_playersMusicKit = new ConcurrentDictionary<int, int?>();
|
||||||
|
internal static ConcurrentDictionary<int, ConcurrentDictionary<ushort, WeaponInfo>> gPlayerWeaponsInfo = new ConcurrentDictionary<int, ConcurrentDictionary<ushort, WeaponInfo>>();
|
||||||
internal static List<JObject> skinsList = new List<JObject>();
|
internal static List<JObject> skinsList = new List<JObject>();
|
||||||
internal static List<JObject> glovesList = new List<JObject>();
|
|
||||||
internal static WeaponSynchronization? weaponSync;
|
internal static WeaponSynchronization? weaponSync;
|
||||||
public static bool g_bCommandsAllowed = true;
|
internal bool g_bCommandsAllowed = true;
|
||||||
internal Dictionary<int, string> PlayerWeaponImage = new();
|
|
||||||
|
|
||||||
|
internal Uri GlobalShareApi = new("https://weaponpaints.fun/api.php");
|
||||||
|
internal int GlobalShareServerId = 0;
|
||||||
internal static Dictionary<int, DateTime> commandsCooldown = new Dictionary<int, DateTime>();
|
internal static Dictionary<int, DateTime> commandsCooldown = new Dictionary<int, DateTime>();
|
||||||
internal static Database? _database;
|
private string DatabaseConnectionString = string.Empty;
|
||||||
|
//private CounterStrikeSharp.API.Modules.Timers.Timer? g_hTimerCheckSkinsData = null;
|
||||||
internal static MemoryFunctionVoid<nint, string, float> CAttributeList_SetOrAddAttributeValueByName = new(GameData.GetSignature("CAttributeList_SetOrAddAttributeValueByName"));
|
public WeaponPaintsConfig Config { get; set; } = new();
|
||||||
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 override string ModuleAuthor => "Nereziel & daffyy";
|
public override string ModuleAuthor => "Nereziel & daffyy";
|
||||||
public override string ModuleDescription => "Skin, gloves and knife selector, standalone and web-based";
|
public override string ModuleDescription => "Skin and knife selector, standalone and web-based";
|
||||||
public override string ModuleName => "WeaponPaints";
|
public override string ModuleName => "WeaponPaints";
|
||||||
public override string ModuleVersion => "1.9a";
|
public override string ModuleVersion => "1.5.0";
|
||||||
|
|
||||||
public static WeaponPaintsConfig GetWeaponPaintsConfig()
|
public static WeaponPaintsConfig GetWeaponPaintsConfig()
|
||||||
{
|
{
|
||||||
@@ -164,88 +155,91 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
|||||||
|
|
||||||
public override void Load(bool hotReload)
|
public override void Load(bool hotReload)
|
||||||
{
|
{
|
||||||
Instance = this;
|
if (!Config.GlobalShare)
|
||||||
|
{
|
||||||
|
DatabaseConnectionString = Utility.BuildDatabaseConnectionString();
|
||||||
|
Utility.TestDatabaseConnection();
|
||||||
|
}
|
||||||
|
|
||||||
if (hotReload)
|
if (hotReload)
|
||||||
{
|
{
|
||||||
OnMapStart(string.Empty);
|
OnMapStart(string.Empty);
|
||||||
|
|
||||||
foreach (var player in Utilities.GetPlayers())
|
List<CCSPlayerController> players = Utilities.GetPlayers();
|
||||||
|
|
||||||
|
foreach (CCSPlayerController player in players)
|
||||||
{
|
{
|
||||||
if (weaponSync == null || player is null || !player.IsValid || player.SteamID.ToString().Length != 17 || !player.PawnIsAlive || player.IsBot ||
|
if (player == null || !player.IsValid || player.IsBot || player.IsHLTV || player.SteamID.ToString() == "") continue;
|
||||||
player.IsHLTV || player.Connected != PlayerConnectedState.PlayerConnected)
|
if (g_playersDatabaseIndex.ContainsKey((int)player.Index)) continue;
|
||||||
continue;
|
|
||||||
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
g_knifePickupCount[(int)player.Slot] = 0;
|
|
||||||
gPlayerWeaponsInfo.TryRemove((int)player.Slot, out _);
|
|
||||||
g_playersKnife.TryRemove((int)player.Slot, out _);
|
|
||||||
|
|
||||||
PlayerInfo playerInfo = new PlayerInfo
|
|
||||||
{
|
{
|
||||||
UserId = player.UserId,
|
UserId = player.UserId,
|
||||||
Slot = player.Slot,
|
Index = (int)player.Index,
|
||||||
Index = (int)player.Slot,
|
SteamId = player?.SteamID,
|
||||||
SteamId = player?.SteamID.ToString(),
|
|
||||||
Name = player?.PlayerName,
|
Name = player?.PlayerName,
|
||||||
IpAddress = player?.IpAddress?.Split(":")[0]
|
IpAddress = player?.IpAddress?.Split(":")[0]
|
||||||
};
|
};
|
||||||
|
if (weaponSync != null)
|
||||||
if (Config.Additional.SkinEnabled)
|
|
||||||
{
|
{
|
||||||
Task.Run(() => weaponSync.GetWeaponPaintsFromDatabase(playerInfo));
|
_ = weaponSync!.GetPlayerDatabaseIndex(playerInfo);
|
||||||
}
|
|
||||||
if (Config.Additional.KnifeEnabled)
|
|
||||||
{
|
|
||||||
Task.Run(() => weaponSync.GetKnifeFromDatabase(playerInfo));
|
|
||||||
}
|
|
||||||
if (Config.Additional.GloveEnabled)
|
|
||||||
{
|
|
||||||
Task.Run(() => weaponSync.GetGloveFromDatabase(playerInfo));
|
|
||||||
}
|
}
|
||||||
|
g_knifePickupCount[(int)player!.Index] = 0;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
RegisterListeners();
|
||||||
|
RegisterCommands();
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
Utility.LoadSkinsFromFile(ModuleDirectory + "/skins.json");
|
if (Config.AdditionalSetting.KnifeEnabled)
|
||||||
Utility.LoadGlovesFromFile(ModuleDirectory + "/gloves.json");
|
|
||||||
|
|
||||||
if (Config.Additional.KnifeEnabled)
|
|
||||||
SetupKnifeMenu();
|
SetupKnifeMenu();
|
||||||
if (Config.Additional.SkinEnabled)
|
if (Config.AdditionalSetting.SkinEnabled)
|
||||||
SetupSkinsMenu();
|
SetupSkinsMenu();
|
||||||
if (Config.Additional.GloveEnabled)
|
|
||||||
SetupGlovesMenu();
|
|
||||||
|
|
||||||
RegisterListeners();
|
RegisterListeners();
|
||||||
RegisterCommands();
|
RegisterCommands();
|
||||||
|
|
||||||
|
Utility.LoadSkinsFromFile(ModuleDirectory + "/skins.json");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnConfigParsed(WeaponPaintsConfig config)
|
public void OnConfigParsed(WeaponPaintsConfig config)
|
||||||
{
|
{
|
||||||
if (config.DatabaseHost.Length < 1 || config.DatabaseName.Length < 1 || config.DatabaseUser.Length < 1)
|
if (!config.GlobalShare)
|
||||||
{
|
{
|
||||||
Logger.LogError("You need to setup Database credentials in config!");
|
if (config.DatabaseHost.Length < 1 || config.DatabaseName.Length < 1 || config.DatabaseUser.Length < 1)
|
||||||
throw new Exception("[WeaponPaints] You need to setup Database credentials in config!");
|
{
|
||||||
|
// maybe more spam to get attention?
|
||||||
|
for (int i = 1; i <= 30; i++)
|
||||||
|
{
|
||||||
|
Console.WriteLine("[WeaponPaints] You need to setup Database credentials in config!");
|
||||||
|
}
|
||||||
|
Logger.LogError("You need to setup Database credentials in config!");
|
||||||
|
throw new Exception("[WeaponPaints] You need to setup Database credentials in config!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
var builder = new MySqlConnectionStringBuilder
|
|
||||||
{
|
{
|
||||||
Server = config.DatabaseHost,
|
// maybe more spam to get attention?
|
||||||
UserID = config.DatabaseUser,
|
for (int i = 1; i <= 30; i++)
|
||||||
Password = config.DatabasePassword,
|
{
|
||||||
Database = config.DatabaseName,
|
Console.WriteLine("[WeaponPaints] GLOBAL SHARE IS NOT SUPPORTED NOW !!");
|
||||||
Port = (uint)config.DatabasePort,
|
}
|
||||||
Pooling = true
|
Logger.LogError("GLOBAL SHARE IS NOT SUPPORTED NOW !!");
|
||||||
};
|
throw new Exception("[WeaponPaints] GLOBAL SHARE IS NOT SUPPORTED NOW !!");
|
||||||
|
}
|
||||||
_database = new(builder.ConnectionString);
|
|
||||||
|
|
||||||
_ = Utility.CheckDatabaseTables();
|
|
||||||
|
|
||||||
Config = config;
|
Config = config;
|
||||||
_config = config;
|
_config = config;
|
||||||
_localizer = Localizer;
|
_localizer = Localizer;
|
||||||
|
|
||||||
Utility.Config = config;
|
/*
|
||||||
|
* GLOBAL SHARE IS NOT SUPPORTED NOW!
|
||||||
|
*/
|
||||||
|
if (Config.GlobalShare)
|
||||||
|
Config.GlobalShare = false;
|
||||||
|
|
||||||
|
Utility.Config = config;
|
||||||
Utility.ShowAd(ModuleVersion);
|
Utility.ShowAd(ModuleVersion);
|
||||||
Task.Run(async () => await Utility.CheckVersion(ModuleVersion, Logger));
|
Task.Run(async () => await Utility.CheckVersion(ModuleVersion, Logger));
|
||||||
}
|
}
|
||||||
@@ -254,4 +248,41 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
|||||||
{
|
{
|
||||||
base.Unload(hotReload);
|
base.Unload(hotReload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 = int.Parse(responseBody);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger.LogError("Unable to retrieve serverid from GlobalShare!");
|
||||||
|
throw new Exception("[WeaponPaints] Unable to retrieve serverid from GlobalShare!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger.LogInformation("GlobalShare ONLINE!");
|
||||||
|
Console.WriteLine("[WeaponPaints] GlobalShare ONLINE");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -9,9 +9,9 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.168" />
|
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.148" />
|
||||||
<PackageReference Include="Dapper" Version="2.1.28" />
|
<PackageReference Include="Dapper" Version="2.1.28" />
|
||||||
<PackageReference Include="MySqlConnector" Version="2.3.5" />
|
<PackageReference Include="MySqlConnector" Version="2.3.4" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
using Dapper;
|
using CounterStrikeSharp.API.Core;
|
||||||
|
using CounterStrikeSharp.API.Modules.Entities;
|
||||||
|
using Dapper;
|
||||||
|
using MySqlConnector;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
|
|
||||||
namespace WeaponPaints
|
namespace WeaponPaints
|
||||||
@@ -6,27 +10,287 @@ namespace WeaponPaints
|
|||||||
internal class WeaponSynchronization
|
internal class WeaponSynchronization
|
||||||
{
|
{
|
||||||
private readonly WeaponPaintsConfig _config;
|
private readonly WeaponPaintsConfig _config;
|
||||||
private readonly Database _database;
|
private readonly string _databaseConnectionString;
|
||||||
|
private readonly Uri _globalShareApi;
|
||||||
|
private readonly int _globalShareServerId;
|
||||||
|
|
||||||
internal WeaponSynchronization(Database database, WeaponPaintsConfig config)
|
internal WeaponSynchronization(string databaseConnectionString, WeaponPaintsConfig config, Uri globalShareApi, int globalShareServerId)
|
||||||
{
|
{
|
||||||
_database = database;
|
_databaseConnectionString = databaseConnectionString;
|
||||||
_config = config;
|
_config = config;
|
||||||
|
_globalShareApi = globalShareApi;
|
||||||
|
_globalShareServerId = globalShareServerId;
|
||||||
}
|
}
|
||||||
|
internal async Task GetPlayerDatabaseIndex(PlayerInfo player)
|
||||||
internal async Task GetKnifeFromDatabase(PlayerInfo player)
|
|
||||||
{
|
{
|
||||||
if (!_config.Additional.KnifeEnabled) return;
|
if (player.SteamId == null || player.Index == 0) return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var connection = new MySqlConnection(_databaseConnectionString))
|
||||||
|
{
|
||||||
|
await connection.OpenAsync();
|
||||||
|
|
||||||
|
string query = "SELECT `id` FROM `wp_users` WHERE `steamid` = @steamid";
|
||||||
|
int? databaseIndex = await connection.QueryFirstOrDefaultAsync<int?>(query, new { steamid = player.SteamId });
|
||||||
|
if (databaseIndex != null)
|
||||||
|
{
|
||||||
|
WeaponPaints.g_playersDatabaseIndex[player.Index] = (int)databaseIndex;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string insertQuery = "INSERT INTO `wp_users` (`steamid`) VALUES (@steamid)";
|
||||||
|
await connection.ExecuteAsync(insertQuery, new { steamid = player.SteamId });
|
||||||
|
Console.WriteLine("SQL Insert Query: " + insertQuery);
|
||||||
|
databaseIndex = await connection.QueryFirstOrDefaultAsync<int?>(query, new { steamid = player.SteamId });
|
||||||
|
WeaponPaints.g_playersDatabaseIndex[(int)player.Index] = (int)databaseIndex;
|
||||||
|
}
|
||||||
|
await connection.CloseAsync();
|
||||||
|
|
||||||
|
if (databaseIndex != null)
|
||||||
|
{
|
||||||
|
if (_config.AdditionalSetting.SkinEnabled)
|
||||||
|
await GetWeaponPaintsFromDatabase(player);
|
||||||
|
if (_config.AdditionalSetting.KnifeEnabled)
|
||||||
|
await GetKnifeFromDatabase(player);
|
||||||
|
if (_config.AdditionalSetting.MusicKitEnabled)
|
||||||
|
await GetMusicKitFromDatabase(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Utility.Log("GetPlayerDatabaseIndex: " + e.Message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
internal async Task GetKnifeFromDatabase(PlayerInfo player)
|
||||||
|
{
|
||||||
|
if (!_config.AdditionalSetting.KnifeEnabled) return;
|
||||||
|
if (player.SteamId == null || player.Index == 0) return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await using var connection = await _database.GetConnectionAsync();
|
if (_config.GlobalShare)
|
||||||
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;
|
var values = new Dictionary<string, string>
|
||||||
|
{
|
||||||
|
{ "server_id", _globalShareServerId.ToString() },
|
||||||
|
{ "steamid", player.SteamId.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))
|
||||||
|
{
|
||||||
|
WeaponPaints.g_playersKnife[player.Index] = result;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!WeaponPaints.g_playersDatabaseIndex.TryGetValue(player.Index, out _))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
using (var connection = new MySqlConnection(_databaseConnectionString))
|
||||||
|
{
|
||||||
|
await connection.OpenAsync();
|
||||||
|
string query = "SELECT `knife` FROM `wp_users_knife` WHERE `user_id` = @userId";
|
||||||
|
string? PlayerKnife = await connection.QueryFirstOrDefaultAsync<string>(query, new { userId = WeaponPaints.g_playersDatabaseIndex[player.Index] });
|
||||||
|
if (PlayerKnife != null)
|
||||||
|
{
|
||||||
|
WeaponPaints.g_playersKnife[player.Index] = PlayerKnife;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await connection.CloseAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Utility.Log("GetKnifeFromDatabase: " + e.Message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
internal async Task GetMusicKitFromDatabase(PlayerInfo player)
|
||||||
|
{
|
||||||
|
if (!_config.AdditionalSetting.MusicKitEnabled) return;
|
||||||
|
if (player.SteamId == null || player.Index == 0) return;
|
||||||
|
if (!WeaponPaints.g_playersDatabaseIndex.TryGetValue(player.Index, out _))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var connection = new MySqlConnection(_databaseConnectionString))
|
||||||
|
{
|
||||||
|
await connection.OpenAsync();
|
||||||
|
string query = "SELECT `music` FROM `wp_users_music` WHERE `user_id` = @userId";
|
||||||
|
int? PlayerMusitKit = await connection.QueryFirstOrDefaultAsync<int?>(query, new { userId = WeaponPaints.g_playersDatabaseIndex[player.Index] });
|
||||||
|
if (PlayerMusitKit != null)
|
||||||
|
{
|
||||||
|
WeaponPaints.g_playersMusicKit[player.Index] = PlayerMusitKit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await connection.CloseAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Utility.Log("GetMusicKitFromDatabase: " + e.Message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal async Task GetWeaponPaintsFromDatabase(PlayerInfo player)
|
||||||
|
{
|
||||||
|
if (!_config.AdditionalSetting.SkinEnabled) return;
|
||||||
|
if (player.SteamId == null || player.Index == 0) return;
|
||||||
|
|
||||||
|
if (!WeaponPaints.gPlayerWeaponsInfo.TryGetValue(player.Index, out _))
|
||||||
|
{
|
||||||
|
WeaponPaints.gPlayerWeaponsInfo[player.Index] = new ConcurrentDictionary<ushort, WeaponInfo>();
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (_config.GlobalShare)
|
||||||
|
{
|
||||||
|
var values = new Dictionary<string, string>
|
||||||
|
{
|
||||||
|
{ "server_id", _globalShareServerId.ToString() },
|
||||||
|
{ "steamid", player.SteamId.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 != null && jsonArray.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var weapon in jsonArray)
|
||||||
|
{
|
||||||
|
ushort? weaponDefIndex = weapon["weapon_defindex"]?.Value<ushort>();
|
||||||
|
ushort? weaponPaintId = weapon["weapon_paint_id"]?.Value<ushort>();
|
||||||
|
float? weaponWear = weapon["weapon_wear"]?.Value<float>();
|
||||||
|
ushort? weaponSeed = weapon["weapon_seed"]?.Value<ushort>();
|
||||||
|
|
||||||
|
if (weaponDefIndex != null && weaponPaintId != null && weaponWear != null && weaponSeed != null)
|
||||||
|
{
|
||||||
|
WeaponInfo weaponInfo = new WeaponInfo
|
||||||
|
{
|
||||||
|
Paint = weaponPaintId.Value,
|
||||||
|
Seed = weaponSeed.Value,
|
||||||
|
Wear = weaponWear.Value,
|
||||||
|
NameTag = null
|
||||||
|
};
|
||||||
|
WeaponPaints.gPlayerWeaponsInfo[player.Index][weaponDefIndex.Value] = weaponInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!WeaponPaints.g_playersDatabaseIndex.TryGetValue(player.Index, out _))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
using (var connection = new MySqlConnection(_databaseConnectionString))
|
||||||
|
{
|
||||||
|
await connection.OpenAsync();
|
||||||
|
string query = "SELECT `weapon`, `paint`, `wear`, `seed`, `nametag` FROM `wp_users_items` WHERE `user_id` = @userId";
|
||||||
|
IEnumerable<dynamic> PlayerSkins = await connection.QueryAsync<dynamic>(query, new { userId = WeaponPaints.g_playersDatabaseIndex[player.Index] });
|
||||||
|
if (PlayerSkins != null && PlayerSkins.Any())
|
||||||
|
{
|
||||||
|
PlayerSkins.ToList().ForEach(row =>
|
||||||
|
{
|
||||||
|
ushort weaponDefIndex = row.weapon ?? default(ushort);
|
||||||
|
ushort weaponPaintId = row.paint ?? default(ushort);
|
||||||
|
float weaponWear = row.wear ?? default(float);
|
||||||
|
ushort weaponSeed = row.seed ?? default(ushort);
|
||||||
|
string weaponNameTag = row.nametag;
|
||||||
|
|
||||||
|
WeaponInfo weaponInfo = new WeaponInfo
|
||||||
|
{
|
||||||
|
Paint = weaponPaintId,
|
||||||
|
Seed = weaponSeed,
|
||||||
|
Wear = weaponWear,
|
||||||
|
NameTag = weaponNameTag
|
||||||
|
};
|
||||||
|
WeaponPaints.gPlayerWeaponsInfo[player.Index][weaponDefIndex] = weaponInfo;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await connection.CloseAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Utility.Log("GetWeaponPaintsFromDatabase: " + e.Message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal async Task SyncKnifeToDatabase(PlayerInfo player, string knife)
|
||||||
|
{
|
||||||
|
if (!_config.AdditionalSetting.KnifeEnabled) return;
|
||||||
|
if(player == null || player.Index <= 0) return;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!WeaponPaints.g_playersDatabaseIndex.TryGetValue(player.Index, out _))
|
||||||
|
return;
|
||||||
|
|
||||||
|
using var connection = new MySqlConnection(_databaseConnectionString);
|
||||||
|
await connection.OpenAsync();
|
||||||
|
string query = "INSERT INTO `wp_users_knife` (`user_id`, `knife`) VALUES(@userId, @newKnife) ON DUPLICATE KEY UPDATE `knife` = @newKnife";
|
||||||
|
await connection.ExecuteAsync(query, new { userId = WeaponPaints.g_playersDatabaseIndex[player.Index], newKnife = knife });
|
||||||
|
await connection.CloseAsync();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -34,139 +298,34 @@ namespace WeaponPaints
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
internal async Task SyncWeaponPaintToDatabase(PlayerInfo player, ushort weaponDefIndex)
|
||||||
internal async Task GetGloveFromDatabase(PlayerInfo player)
|
|
||||||
{
|
{
|
||||||
if (!_config.Additional.GloveEnabled) return;
|
if (!_config.AdditionalSetting.SkinEnabled) return;
|
||||||
|
if (player == null || player.Index <= 0) return;
|
||||||
|
|
||||||
try
|
if (!WeaponPaints.g_playersDatabaseIndex.TryGetValue(player.Index, out var playerDatabaseIndex))
|
||||||
{
|
return;
|
||||||
// Ensure proper disposal of resources using "using" statement
|
|
||||||
await using var connection = await _database.GetConnectionAsync();
|
if (!WeaponPaints.gPlayerWeaponsInfo.TryGetValue(player.Index, out var playerSavedWeapons))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!playerSavedWeapons.TryGetValue(weaponDefIndex, out var weaponInfo))
|
||||||
|
return;
|
||||||
|
|
||||||
// Construct the SQL query with specific columns for better performance
|
using var connection = new MySqlConnection(_databaseConnectionString);
|
||||||
string query = "SELECT `weapon_defindex` FROM `wp_player_gloves` WHERE `steamid` = @steamid";
|
string querySql = @"
|
||||||
|
INSERT INTO `wp_users_items`
|
||||||
// Execute the query and retrieve glove data
|
(`user_id`, `weapon`, `paint`, `wear`, `seed`)
|
||||||
ushort? gloveData = await connection.QueryFirstOrDefaultAsync<ushort?>(query, new { steamid = player.SteamId });
|
VALUES
|
||||||
|
(@userId, @weaponDefIndex, @paintId, @wear, @seed)
|
||||||
// Check if glove data is retrieved successfully
|
ON DUPLICATE KEY UPDATE
|
||||||
if (gloveData != null)
|
paint = @paintId,
|
||||||
{
|
wear = @wear,
|
||||||
// Update g_playersGlove dictionary with glove data
|
seed = @seed";
|
||||||
WeaponPaints.g_playersGlove[player.Slot] = gloveData.Value;
|
var queryParams = new { weaponDefIndex, userId = playerDatabaseIndex, paintId = weaponInfo.Paint, wear = weaponInfo.Wear, seed = weaponInfo.Seed };
|
||||||
}
|
await connection.ExecuteAsync(querySql, queryParams);
|
||||||
}
|
await connection.CloseAsync();
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
// Log any exceptions occurred during database operation
|
|
||||||
Utility.Log("An error occurred while fetching glove data: " + e.Message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task GetWeaponPaintsFromDatabase(PlayerInfo player)
|
|
||||||
{
|
|
||||||
if (!_config.Additional.SkinEnabled || player == null || player.SteamId == null) return;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
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 e)
|
|
||||||
{
|
|
||||||
Utility.Log($"Database error occurred: {e.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, ushort 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 query = "INSERT INTO `wp_player_skins` (`steamid`, `weapon_defindex`, `weapon_paint_id`, `weapon_wear`, `weapon_seed`) " +
|
|
||||||
"VALUES (@steamid, @weaponDefIndex, @paintId, @wear, @seed) " +
|
|
||||||
"ON DUPLICATE KEY UPDATE `weapon_paint_id` = @paintId, `weapon_wear` = @wear, `weapon_seed` = @seed";
|
|
||||||
|
|
||||||
var 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}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
{
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,14 +3,11 @@
|
|||||||
"wp_info_website": "Visit {lime}{0}{default} where you can change skins",
|
"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_refresh": "Type {lime}!wp{default} to synchronize chosen skins",
|
||||||
"wp_info_knife": "Type {lime}!knife{default} to open knife menu",
|
"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_cooldown": "{lightred}You can't refresh weapon paints right now",
|
||||||
"wp_command_refresh_done": "{lime}Refreshing weapon paints",
|
"wp_command_refresh_done": "{lime}Refreshing weapon paints",
|
||||||
"wp_knife_menu_select": "You have chosen {lime}{0}{default} as your knife",
|
"wp_knife_menu_select": "You have chosen {lime}{0}{default} as your knife",
|
||||||
"wp_knife_menu_kill": "",
|
"wp_knife_menu_kill": "To correctly apply skin for knife, you need to type {lime}!kill{default}",
|
||||||
"wp_knife_menu_title": "Knife Menu",
|
"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_weapon_title": "Weapon Menu",
|
||||||
"wp_skin_menu_skin_title": "Select skin for {lime}{0}{default}",
|
"wp_skin_menu_skin_title": "Select skin for {lime}{0}{default}",
|
||||||
"wp_skin_menu_select": "You have chosen {lime}{0}{default} as your skin"
|
"wp_skin_menu_select": "You have chosen {lime}{0}{default} as your skin"
|
||||||
|
|||||||
25
lang/lv.json
@@ -1,17 +1,14 @@
|
|||||||
{
|
{
|
||||||
"wp_prefix": "{lightblue}[WeaponPaints] {default}",
|
"wp_prefix": "{lightblue}[Ieroču Ādiņas] {default}",
|
||||||
"wp_info_website": "Apmeklējiet {lime}{0}{default}, kur varat mainīt ādas",
|
"wp_info_website": "Apmeklē {lime}{0}{default} kur tu vari nomainīt skinus",
|
||||||
"wp_info_refresh": "Ievadiet {lime}!wp{default}, lai sinhronizētu izvēlētās ādas",
|
"wp_info_refresh": "Raksti {lime}!wp{default} lai sinhronizētu izvēlētos skinus",
|
||||||
"wp_info_knife": "Ievadiet {lime}!knife{default}, lai atvērtu nazis izvēlni",
|
"wp_info_knife": "Raksti {lime}!knife{default} lai atvērtu nažu izvēlni",
|
||||||
"wp_info_glove": "Ievadiet {lime}!gloves{default}, lai atvērtu cimdi izvēlni",
|
"wp_command_cooldown": "{lightred} Tu šobrīd nevari atjaunot ieroču skinus...",
|
||||||
"wp_command_cooldown": "{lightred}Šobrīd jūs nevarat atjaunot ieroču ādas",
|
"wp_command_refresh_done": "{lime}Izvēlētie skini tiek atjaunoti",
|
||||||
"wp_command_refresh_done": "{lime}Atjauno ieroču ādas",
|
"wp_knife_menu_select": "Tu esi izvēlējies {lime}{0}{default} nazi",
|
||||||
"wp_knife_menu_select": "Jūs esat izvēlējies {lime}{0}{default} kā savu nazi",
|
"wp_knife_menu_kill": "Lai pareizi atjaunotu naža skinu, ieraksti čatā {lime}!kill{default}",
|
||||||
"wp_knife_menu_kill": "",
|
"wp_knife_menu_title": "Nažu Izvēlne",
|
||||||
"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_weapon_title": "Ieroču Izvēlne",
|
||||||
"wp_skin_menu_skin_title": "Izvēlieties ādu {lime}{0}{default}",
|
"wp_skin_menu_skin_title": "Izvēlies skinu ierocim: {lime}{0}{default}",
|
||||||
"wp_skin_menu_select": "Jūs esat izvēlējies {lime}{0}{default} kā savu ādu"
|
"wp_skin_menu_select": "Tu esi izvēlējies {lime}{0}{default} kā savu skinu"
|
||||||
}
|
}
|
||||||
|
|||||||
25
lang/pl.json
@@ -1,17 +1,14 @@
|
|||||||
{
|
{
|
||||||
"wp_prefix": "{lightblue}[WeaponPaints] {default}",
|
"wp_prefix": "{lightblue}[WeaponPaints] {default}",
|
||||||
"wp_info_website": "Odwiedź {lime}{0}{default}, gdzie możesz zmieniać skórki",
|
"wp_info_website": "Odwiedź {lime}{0}{default} gdzie będziesz mógł ustawić skiny",
|
||||||
"wp_info_refresh": "Wpisz {lime}!wp{default}, aby zsynchronizować wybrane skórki",
|
"wp_info_refresh": "Wpisz {lime}!wp{default} aby zsynchronizować swoje skiny",
|
||||||
"wp_info_knife": "Wpisz {lime}!knife{default}, aby otworzyć menu noży",
|
"wp_info_knife": "Wpisz {lime}!knife{default} aby wy<EFBFBD>wietlić menu no<EFBFBD>y",
|
||||||
"wp_info_glove": "Wpisz {lime}!gloves{default}, aby otworzyć menu rękawiczek",
|
"wp_command_cooldown": "{lightred}Odczekaj chwilę przed wykonaniem tej komendy...",
|
||||||
"wp_command_cooldown": "{lightred}Nie możesz teraz odświeżyć skórek broni",
|
"wp_command_refresh_done": "{lime}Pomyslnie zsynchronizowano twoje skiny",
|
||||||
"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_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_kill": "Do prawidłowego zastosowania noża użyj {lime}!kill{default}",
|
||||||
"wp_knife_menu_title": "Menu Noży",
|
"wp_knife_menu_title": "Menu noży",
|
||||||
"wp_glove_menu_select": "Wybrałeś {lime}{0}{default} jako swoje rękawiczki",
|
"wp_skin_menu_weapon_title": "Menu broni",
|
||||||
"wp_glove_menu_title": "Menu Rękawiczek",
|
"wp_skin_menu_skin_title": "Wybierz skin dla {lime}{0}{default}",
|
||||||
"wp_skin_menu_weapon_title": "Menu Broni",
|
"wp_skin_menu_select": "Wybrałeś {lime}{0}{default} jako swój skin"
|
||||||
"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ę"
|
|
||||||
}
|
|
||||||
@@ -1,17 +1,14 @@
|
|||||||
{
|
{
|
||||||
"wp_prefix": "{lightblue}[WeaponPaints] {default}",
|
"wp_prefix": "{lightblue}[WeaponPaints] {default}",
|
||||||
"wp_info_website": "Visite {lime}{0}{default}, onde você pode alterar skins",
|
"wp_info_website": "Visite {lime}{0}{default} para mudar suas skins e faca",
|
||||||
"wp_info_refresh": "Digite {lime}!wp{default} para sincronizar as skins selecionadas",
|
"wp_info_refresh": "Digite {lime}!wp{default} para sincronizar as suas skins",
|
||||||
"wp_info_knife": "Digite {lime}!knife{default} para abrir o menu de facas",
|
"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 das armas agora",
|
||||||
"wp_command_cooldown": "{lightred}Você não pode atualizar as skins de arma agora",
|
"wp_command_refresh_done": "{lime}Sincronizando as suas skins",
|
||||||
"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_select": "Você escolheu {lime}{0}{default} como sua faca",
|
||||||
"wp_knife_menu_kill": "",
|
"wp_knife_menu_kill": "Para aplicar corretamente a skin da faca, você precisa digitar {lime}!kill{default}",
|
||||||
"wp_knife_menu_title": "Menu de Facas",
|
"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_weapon_title": "Menu de Armas",
|
||||||
"wp_skin_menu_skin_title": "Selecione uma skin para {lime}{0}{default}",
|
"wp_skin_menu_skin_title": "Selecionou a skin para {lime}{0}{default}",
|
||||||
"wp_skin_menu_select": "Você escolheu {lime}{0}{default} como sua skin"
|
"wp_skin_menu_select": "Você escolheu {lime}{0}{default} como sua skin"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,14 @@
|
|||||||
{
|
{
|
||||||
"wp_prefix": "{lightblue}[WeaponPaints] {default}",
|
"wp_prefix": "{lightblue}[WeaponPaints] {default}",
|
||||||
"wp_info_website": "Visite {lime}{0}{default}, onde pode alterar skins",
|
"wp_info_website": "Visita {lime}{0}{default} onde podes mudar as tuas skins",
|
||||||
"wp_info_refresh": "Digite {lime}!wp{default} para sincronizar as skins selecionadas",
|
"wp_info_refresh": "Digita {lime}!wp{default} para sincronizar as tuas skins",
|
||||||
"wp_info_knife": "Digite {lime}!knife{default} para abrir o menu de facas",
|
"wp_info_knife": "Digita {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}Tu não podes sincronizar agora as tuas skins",
|
||||||
"wp_command_cooldown": "{lightred}Você não pode atualizar as skins de arma agora",
|
"wp_command_refresh_done": "{lime}Sincronizando as tuas skins",
|
||||||
"wp_command_refresh_done": "{lime}Atualizando as skins de arma",
|
"wp_knife_menu_select": "Tu escolheste {lime}{0}{default} como a tua faca",
|
||||||
"wp_knife_menu_select": "Você escolheu {lime}{0}{default} como sua faca",
|
"wp_knife_menu_kill": "Para aplicar corretamente a skins para a tua faca, digita {lime}!kill{default}",
|
||||||
"wp_knife_menu_kill": "",
|
"wp_knife_menu_title": "Menu Facas",
|
||||||
"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_weapon_title": "Menu de Armas",
|
||||||
"wp_skin_menu_skin_title": "Selecione uma skin para {lime}{0}{default}",
|
"wp_skin_menu_skin_title": "Escolhe a skin para {lime}{0}{default}",
|
||||||
"wp_skin_menu_select": "Você escolheu {lime}{0}{default} como sua skin"
|
"wp_skin_menu_select": "Tu escolheste {lime}{0}{default} como a tua skin"
|
||||||
}
|
}
|
||||||
|
|||||||
23
lang/ru.json
@@ -1,17 +1,14 @@
|
|||||||
{
|
{
|
||||||
"wp_prefix": "{lightblue}[WeaponPaints] {default}",
|
"wp_prefix": "{lightblue}[WeaponPaints] {default}",
|
||||||
"wp_info_website": "Посетите {lime}{0}{default}, где вы можете изменить скины",
|
"wp_info_website": "Посетите сайт {lime}{0},{default} чтобы выбрать скин",
|
||||||
"wp_info_refresh": "Введите {lime}!wp{default}, чтобы синхронизировать выбранные скины",
|
"wp_info_refresh": "Наберите в чат {lime}!wp{default} для синхронизации выбранных скинов",
|
||||||
"wp_info_knife": "Введите {lime}!knife{default}, чтобы открыть меню ножей",
|
"wp_info_knife": "Наберите в чат {lime}!knife,{default} чтобы выбрать нож",
|
||||||
"wp_info_glove": "Введите {lime}!gloves{default}, чтобы открыть меню перчаток",
|
"wp_command_cooldown": "{lightred}Вы не можете выбрать оружие прямо сейчас",
|
||||||
"wp_command_cooldown": "{lightred}Вы не можете обновить скины оружия сейчас",
|
"wp_command_refresh_done": "{lime}Обновление скинов для оружия",
|
||||||
"wp_command_refresh_done": "{lime}Обновление скинов оружия",
|
"wp_knife_menu_select": "Вы выбрали {lime}{0}{default} скин для ножа",
|
||||||
"wp_knife_menu_select": "Вы выбрали {lime}{0}{default} в качестве вашего ножа",
|
"wp_knife_menu_kill": "Чтобы правильно применить скин для ножа, набери в чат {lime}!kill{default}",
|
||||||
"wp_knife_menu_kill": "",
|
"wp_knife_menu_title": "Меню ножей",
|
||||||
"wp_knife_menu_title": "Меню Ножей",
|
"wp_skin_menu_weapon_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_skin_title": "Выберите скин для {lime}{0}{default}",
|
||||||
"wp_skin_menu_select": "Вы выбрали {lime}{0}{default} в качестве вашего скина"
|
"wp_skin_menu_select": "Вы выбрали {lime}{0}{default} скина для оружия"
|
||||||
}
|
}
|
||||||
19
lang/tr.json
@@ -1,17 +1,14 @@
|
|||||||
{
|
{
|
||||||
"wp_prefix": "{lightblue}[WeaponPaints] {default}",
|
"wp_prefix": "{lightblue}[WeaponPaints] {default}",
|
||||||
"wp_info_website": "Ziyaret edin {lime}{0}{default}, burada skinleri değiştirebilirsiniz",
|
"wp_info_website": "Görünümleri değiştirebileceğiniz {lime}{0}{default} adresini ziyaret edin",
|
||||||
"wp_info_refresh": "Senkronize edilen skinleri görmek için {lime}!wp{default} yazın",
|
"wp_info_refresh": "Seçilen kaplamyı senkronize etmek 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_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 kaplamasını yenileyemezsiniz",
|
||||||
"wp_command_cooldown": "{lightred}Şu anda silah skinlerini yenileyemezsiniz",
|
"wp_command_refresh_done": "{lime}Silah kaplaması yenileniyor",
|
||||||
"wp_command_refresh_done": "{lime}Silah skinleri yenileniyor",
|
"wp_knife_menu_select": "Bıçağınız olarak {lime}{0}{default} seçtiniz",
|
||||||
"wp_knife_menu_select": "{lime}{0}{default} olarak bıçağınızı seçtiniz",
|
"wp_knife_menu_kill": "Bıçak için doğru şekilde kaplama uygulamak için {lime}!kill{default} yazmanız gerekir",
|
||||||
"wp_knife_menu_kill": "",
|
|
||||||
"wp_knife_menu_title": "Bıçak Menüsü",
|
"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_weapon_title": "Silah Menüsü",
|
||||||
"wp_skin_menu_skin_title": "{lime}{0}{default} için bir skin seçin",
|
"wp_skin_menu_skin_title": "Select skin for {lime}{0}{default}",
|
||||||
"wp_skin_menu_select": "{lime}{0}{default} olarak bir skin seçtiniz"
|
"wp_skin_menu_select": "Teniniz olarak {lime}{0}{default} seçtiniz"
|
||||||
}
|
}
|
||||||
|
|||||||
25
lang/ua.json
@@ -1,17 +1,14 @@
|
|||||||
{
|
{
|
||||||
"wp_prefix": "{lightblue}[WeaponPaints] {default}",
|
"wp_prefix": "{lightblue}[WeaponPaints] {default}",
|
||||||
"wp_info_website": "Відвідайте {lime}{0}{default}, де ви можете змінити шкури",
|
"wp_info_website": "Відвідайте веб-сайт {lime}{0},{default} щоб вибрати скин",
|
||||||
"wp_info_refresh": "Введіть {lime}!wp{default}, щоб синхронізувати обрані шкури",
|
"wp_info_refresh": "Напишіть у чат {lime}!wp{default} для синхронізації вибраних скинів",
|
||||||
"wp_info_knife": "Введіть {lime}!knife{default}, щоб відкрити меню ножів",
|
"wp_info_knife": "Напишіть у чат {lime}!knife,{default} щоб вибрати ніж",
|
||||||
"wp_info_glove": "Введіть {lime}!gloves{default}, щоб відкрити меню рукавичок",
|
"wp_command_cooldown": "{lightred}Ви не можете вибрати зброю зараз",
|
||||||
"wp_command_cooldown": "{lightred}Наразі ви не можете оновлювати шкіри зброї",
|
"wp_command_refresh_done": "{lime}Оновлення скинів для зброї",
|
||||||
"wp_command_refresh_done": "{lime}Оновлення шкірок зброї",
|
"wp_knife_menu_select": "Ви вибрали скин {lime}{0}{default} для ножа",
|
||||||
"wp_knife_menu_select": "Ви вибрали {lime}{0}{default} як ваш ніж",
|
"wp_knife_menu_kill": "Щоб правильно застосувати скин для ножа, напишіть у чат {lime}!kill{default}",
|
||||||
"wp_knife_menu_kill": "",
|
"wp_knife_menu_title": "Меню ножів",
|
||||||
"wp_knife_menu_title": "Меню Ножів",
|
"wp_skin_menu_weapon_title": "Меню зброї",
|
||||||
"wp_glove_menu_select": "Ви вибрали {lime}{0}{default} як ваші рукавички",
|
"wp_skin_menu_skin_title": "Виберіть скин для {lime}{0}{default}",
|
||||||
"wp_glove_menu_title": "Меню Рукавичок",
|
"wp_skin_menu_select": "Ви вибрали скин {lime}{0}{default} для зброї"
|
||||||
"wp_skin_menu_weapon_title": "Меню Зброї",
|
|
||||||
"wp_skin_menu_skin_title": "Виберіть шкіру для {lime}{0}{default}",
|
|
||||||
"wp_skin_menu_select": "Ви вибрали {lime}{0}{default} як вашу шкіру"
|
|
||||||
}
|
}
|
||||||
@@ -1,17 +1,14 @@
|
|||||||
{
|
{
|
||||||
"wp_prefix": "{lightblue}[WeaponPaints] {default}",
|
"wp_prefix": "{lightblue}[武器皮肤] {default}",
|
||||||
"wp_info_website": "访问 {lime}{0}{default},您可以更改皮肤",
|
"wp_info_website": "在线访问 {lime}{0}{default} 更改你的武器皮肤",
|
||||||
"wp_info_refresh": "输入 {lime}!wp{default} 同步已选择的皮肤",
|
"wp_info_refresh": "输入 {lime}!wp{default} 进行在线皮肤同步",
|
||||||
"wp_info_knife": "输入 {lime}!knife{default} 打开刀具菜单",
|
"wp_info_knife": "输入 {lime}!knife{default} 打开刀菜单",
|
||||||
"wp_info_glove": "输入 {lime}!gloves{default} 打开手套菜单",
|
"wp_command_cooldown": "{lightred}皮肤同步刷新冷却中",
|
||||||
"wp_command_cooldown": "{lightred}您现在无法刷新武器皮肤",
|
"wp_command_refresh_done": "{lime}刷新武器皮肤中",
|
||||||
"wp_command_refresh_done": "{lime}刷新武器皮肤",
|
"wp_knife_menu_select": "你选择了 {lime}{0}{default} 作为你的刀",
|
||||||
"wp_knife_menu_select": "您已选择 {lime}{0}{default} 作为您的刀具",
|
"wp_knife_menu_kill": "如需完全应用皮肤到刀上, 你需要输入 {lime}!kill{default} 自杀来进行刷新",
|
||||||
"wp_knife_menu_kill": "",
|
"wp_knife_menu_title": "刀菜单",
|
||||||
"wp_knife_menu_title": "刀具菜单",
|
|
||||||
"wp_glove_menu_select": "您已选择 {lime}{0}{default} 作为您的手套",
|
|
||||||
"wp_glove_menu_title": "手套菜单",
|
|
||||||
"wp_skin_menu_weapon_title": "武器菜单",
|
"wp_skin_menu_weapon_title": "武器菜单",
|
||||||
"wp_skin_menu_skin_title": "为 {lime}{0}{default} 选择皮肤",
|
"wp_skin_menu_skin_title": "选择 {lime}{0}{default} 的皮肤",
|
||||||
"wp_skin_menu_select": "您已选择 {lime}{0}{default} 作为您的皮肤"
|
"wp_skin_menu_select": "你选择了 {lime}{0}{default} 作为你的皮肤"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +1,66 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* Class DataBase
|
||||||
|
*
|
||||||
|
* This class handles database operations using PDO.
|
||||||
|
*/
|
||||||
class DataBase {
|
class DataBase {
|
||||||
|
/**
|
||||||
|
* @var PDO The PDO instance for database connection.
|
||||||
|
*/
|
||||||
private $PDO;
|
private $PDO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor method to initialize the database connection.
|
||||||
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
try {
|
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"));
|
// Establish a connection to the database using PDO
|
||||||
|
$this->PDO = new PDO(
|
||||||
|
"mysql:host=".DB_HOST.";port=".DB_PORT.";dbname=".DB_NAME,
|
||||||
|
DB_USER,
|
||||||
|
DB_PASS
|
||||||
|
);
|
||||||
|
// Set the connection to use utf8 encoding
|
||||||
|
$this->PDO->exec("SET NAMES utf8");
|
||||||
}
|
}
|
||||||
catch(PDOException $ex)
|
catch(PDOException $ex) {
|
||||||
{
|
// Display error message if connection fails
|
||||||
echo "<div style='display: flex; flex-direction: column;align-items: center;justify-content: center;text-align: center;'><h2>Problem with database!</h2>";
|
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>");
|
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 = []) {
|
|
||||||
|
/**
|
||||||
|
* Perform a SELECT query on the database.
|
||||||
|
*
|
||||||
|
* @param string $query The SQL query to execute.
|
||||||
|
* @param array $bindings An associative array of parameters and their values.
|
||||||
|
* @return array|false Returns an array of rows as associative arrays or false if no results are found.
|
||||||
|
*/
|
||||||
|
public function select($query, $bindings = array()) {
|
||||||
|
// Prepare and execute the SQL query
|
||||||
$STH = $this->PDO->prepare($query);
|
$STH = $this->PDO->prepare($query);
|
||||||
$STH->execute($bindings);
|
$STH->execute($bindings);
|
||||||
|
|
||||||
|
// Fetch the results as associative arrays
|
||||||
$result = $STH->fetchAll(PDO::FETCH_ASSOC);
|
$result = $STH->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$result ??= false;
|
if ($result === false) {
|
||||||
return $result;
|
$result = array(); // Set $result to an empty array if no results found
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function query($query, $bindings = []){
|
/**
|
||||||
|
* Perform a non-query SQL statement on the database.
|
||||||
|
*
|
||||||
|
* @param string $query The SQL query to execute.
|
||||||
|
* @param array $bindings An associative array of parameters and their values.
|
||||||
|
* @return bool Returns true on success or false on failure.
|
||||||
|
*/
|
||||||
|
public function query($query, $bindings = array()) {
|
||||||
|
// Prepare and execute the SQL query
|
||||||
$STH = $this->PDO->prepare($query);
|
$STH = $this->PDO->prepare($query);
|
||||||
return $STH->execute($bindings);
|
return $STH->execute($bindings);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
71
website/class/header.php
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
// Set security headers to enhance security
|
||||||
|
header("X-Frame-Options: SAMEORIGIN");
|
||||||
|
header("X-XSS-Protection: 1; mode=block");
|
||||||
|
header("X-Content-Type-Options: nosniff");
|
||||||
|
header("Referrer-Policy: no-referrer-when-downgrade");
|
||||||
|
header("Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net https://code.jquery.com; style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net; img-src 'self' data: https://cdn.jsdelivr.net https://steamcommunity-a.akamaihd.net https://raw.githubusercontent.com;");
|
||||||
|
|
||||||
|
|
||||||
|
// Include necessary classes and files
|
||||||
|
require 'class/config.php';
|
||||||
|
require 'class/database.php';
|
||||||
|
require 'steamauth/steamauth.php';
|
||||||
|
require 'class/utils.php';
|
||||||
|
|
||||||
|
// Create a database instance
|
||||||
|
$db = new DataBase();
|
||||||
|
|
||||||
|
// Check if the user is logged in
|
||||||
|
if (isset($_SESSION['steamid'])) {
|
||||||
|
// Insert or update user's Steam ID in the database
|
||||||
|
$steamid = $_SESSION['steamid'];
|
||||||
|
$db->query("INSERT INTO `wp_users` (`steamid`) VALUES ('{$steamid}') ON DUPLICATE KEY UPDATE `updated_at` = CURRENT_TIMESTAMP");
|
||||||
|
|
||||||
|
// Get user's database index
|
||||||
|
$userInfoQuery = $db->select("SELECT `id` FROM `wp_users` WHERE `steamid` = :steamid", ["steamid" => $steamid]);
|
||||||
|
$_SESSION['userDbIndex'] = $userDbIndex = (int)$userInfoQuery[0]['id'];
|
||||||
|
|
||||||
|
// Get weapons and skins information
|
||||||
|
$weapons = UtilsClass::getWeaponsFromArray();
|
||||||
|
$skins = UtilsClass::skinsFromJson();
|
||||||
|
|
||||||
|
// Retrieve user's selected skins and knife
|
||||||
|
$querySelected = $db->select("SELECT `weapon`, `paint`, `wear`, `seed`, `nametag` FROM `wp_users_items` WHERE `user_id` = :user_id", ["user_id" => $userDbIndex]);
|
||||||
|
$selectedSkins = UtilsClass::getSelectedSkins($querySelected);
|
||||||
|
$selectedKnifeResult = $db->select("SELECT `knife` FROM `wp_users_knife` WHERE `user_id` = :user_id", ["user_id" => $userDbIndex]);
|
||||||
|
|
||||||
|
// Determine user's selected knife or set default knife
|
||||||
|
if (!empty($selectedKnifeResult)) {
|
||||||
|
$selectedKnife = $selectedKnifeResult[0]['knife'];
|
||||||
|
} else {
|
||||||
|
$selectedKnife = "weapon_knife";
|
||||||
|
}
|
||||||
|
$knifes = UtilsClass::getKnifeTypes();
|
||||||
|
|
||||||
|
// Handle form submission
|
||||||
|
if (isset($_POST['forma'])) {
|
||||||
|
$ex = explode("-", $_POST['forma']);
|
||||||
|
|
||||||
|
// Handle knife selection
|
||||||
|
if ($ex[0] == "knife") {
|
||||||
|
$db->query("INSERT INTO `wp_users_knife` (`user_id`, `knife`) VALUES(:user_id, :knife) ON DUPLICATE KEY UPDATE `knife` = :knife", ["user_id" => $userDbIndex, "knife" => $knifes[$ex[1]]['weapon_name']]);
|
||||||
|
} else {
|
||||||
|
// Handle skin selection
|
||||||
|
if (array_key_exists($ex[1], $skins[$ex[0]]) && isset($_POST['wear']) && $_POST['wear'] >= 0.00 && $_POST['wear'] <= 1.00 && isset($_POST['seed'])) {
|
||||||
|
$wear = floatval($_POST['wear']); // wear
|
||||||
|
$seed = intval($_POST['seed']); // seed
|
||||||
|
|
||||||
|
// Check if the skin is already selected and update or insert accordingly
|
||||||
|
if (array_key_exists($ex[0], $selectedSkins)) {
|
||||||
|
$db->query("UPDATE wp_users_items SET paint = :weapon_paint_id, wear = :weapon_wear, seed = :weapon_seed WHERE user_id = :user_id AND weapon = :weapon_defindex", ["user_id" => $userDbIndex, "weapon_defindex" => $ex[0], "weapon_paint_id" => $ex[1], "weapon_wear" => $wear, "weapon_seed" => $seed]);
|
||||||
|
} else {
|
||||||
|
$db->query("INSERT INTO wp_users_items (`user_id`, `weapon`, `paint`, `wear`, `seed`) VALUES (:user_id, :weapon_defindex, :weapon_paint_id, :weapon_wear, :weapon_seed)", ["user_id" => $userDbIndex, "weapon_defindex" => $ex[0], "weapon_paint_id" => $ex[1], "weapon_wear" => $wear, "weapon_seed" => $seed]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Redirect to the same page after form submission
|
||||||
|
header("Location: {$_SERVER['PHP_SELF']}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
@@ -1,99 +1,112 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* Class UtilsClass
|
||||||
|
*
|
||||||
|
* Provides utility methods for handling skin and weapon data.
|
||||||
|
*/
|
||||||
class UtilsClass
|
class UtilsClass
|
||||||
{
|
{
|
||||||
public static function skinsFromJson(): array
|
/**
|
||||||
|
* Retrieve skins data from the JSON file.
|
||||||
|
*
|
||||||
|
* @return array An associative array containing skin data.
|
||||||
|
*/
|
||||||
|
public static function skinsFromJson()
|
||||||
{
|
{
|
||||||
$skins = [];
|
$skins = array();
|
||||||
$json = json_decode(file_get_contents(__DIR__ . "/../data/skins.json"), true);
|
$jsonFilePath = __DIR__ . "/../data/skins.json";
|
||||||
|
|
||||||
foreach ($json as $skin) {
|
if (file_exists($jsonFilePath) && is_readable($jsonFilePath)) {
|
||||||
$skins[(int) $skin['weapon_defindex']][(int) $skin['paint']] = [
|
$json = json_decode(file_get_contents($jsonFilePath), true);
|
||||||
'weapon_name' => $skin['weapon_name'],
|
|
||||||
'paint_name' => $skin['paint_name'],
|
foreach ($json as $skin) {
|
||||||
'image_url' => $skin['image'],
|
$skins[(int) $skin['weapon_defindex']][(int) $skin['paint']] = array(
|
||||||
];
|
'weapon_name' => $skin['weapon_name'],
|
||||||
|
'paint_name' => $skin['paint_name'],
|
||||||
|
'image_url' => $skin['image'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Handle file not found or unreadable error
|
||||||
|
// You can throw an exception or log an error message
|
||||||
}
|
}
|
||||||
|
|
||||||
return $skins;
|
return $skins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve weapons data from the skin data array.
|
||||||
|
*
|
||||||
|
* @return array An associative array containing weapon data.
|
||||||
|
*/
|
||||||
public static function getWeaponsFromArray()
|
public static function getWeaponsFromArray()
|
||||||
{
|
{
|
||||||
$weapons = [];
|
$weapons = array();
|
||||||
$temp = self::skinsFromJson();
|
$skinsData = self::skinsFromJson();
|
||||||
|
|
||||||
foreach ($temp as $key => $value) {
|
foreach ($skinsData as $key => $value) {
|
||||||
if (key_exists($key, $weapons))
|
$weapons[$key] = array(
|
||||||
continue;
|
|
||||||
|
|
||||||
$weapons[$key] = [
|
|
||||||
'weapon_name' => $value[0]['weapon_name'],
|
'weapon_name' => $value[0]['weapon_name'],
|
||||||
'paint_name' => $value[0]['paint_name'],
|
'paint_name' => $value[0]['paint_name'],
|
||||||
'image_url' => $value[0]['image_url'],
|
'image_url' => $value[0]['image_url'],
|
||||||
];
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $weapons;
|
return $weapons;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve knife types from the weapon data array.
|
||||||
|
*
|
||||||
|
* @return array An associative array containing knife types data.
|
||||||
|
*/
|
||||||
public static function getKnifeTypes()
|
public static function getKnifeTypes()
|
||||||
{
|
{
|
||||||
$knifes = [];
|
$knifes = array();
|
||||||
$temp = self::getWeaponsFromArray();
|
$weaponsData = self::getWeaponsFromArray();
|
||||||
|
|
||||||
foreach ($temp as $key => $weapon) {
|
$allowedKnifeKeys = array(
|
||||||
if (
|
500, 503, 505, 506, 507, 508, 509, 512, 514, 515,
|
||||||
!in_array($key, [
|
516, 517, 518, 519, 520, 521, 522, 523, 525
|
||||||
500,
|
);
|
||||||
503,
|
|
||||||
505,
|
|
||||||
506,
|
|
||||||
507,
|
|
||||||
508,
|
|
||||||
509,
|
|
||||||
512,
|
|
||||||
514,
|
|
||||||
515,
|
|
||||||
516,
|
|
||||||
517,
|
|
||||||
518,
|
|
||||||
519,
|
|
||||||
520,
|
|
||||||
521,
|
|
||||||
522,
|
|
||||||
523,
|
|
||||||
525,
|
|
||||||
526
|
|
||||||
])
|
|
||||||
)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
$knifes[$key] = [
|
foreach ($weaponsData as $key => $weapon) {
|
||||||
'weapon_name' => $weapon['weapon_name'],
|
if (in_array($key, $allowedKnifeKeys)) {
|
||||||
'paint_name' => rtrim(explode("|", $weapon['paint_name'])[0]),
|
$knifes[$key] = array(
|
||||||
'image_url' => $weapon['image_url'],
|
'weapon_name' => $weapon['weapon_name'],
|
||||||
];
|
'paint_name' => rtrim(explode("|", $weapon['paint_name'])[0]),
|
||||||
$knifes[0] = [
|
'image_url' => $weapon['image_url'],
|
||||||
'weapon_name' => "weapon_knife",
|
);
|
||||||
'paint_name' => "Default knife",
|
}
|
||||||
'image_url' => "https://raw.githubusercontent.com/Nereziel/cs2-WeaponPaints/main/website/img/skins/weapon_knife.png",
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add default knife
|
||||||
|
$knifes[0] = array(
|
||||||
|
'weapon_name' => "weapon_knife",
|
||||||
|
'paint_name' => "Default knife",
|
||||||
|
'image_url' => "https://raw.githubusercontent.com/Nereziel/cs2-WeaponPaints/main/website/img/skins/weapon_knife.png",
|
||||||
|
);
|
||||||
|
|
||||||
ksort($knifes);
|
ksort($knifes);
|
||||||
return $knifes;
|
return $knifes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getSelectedSkins(array $temp)
|
/**
|
||||||
|
* Retrieve selected skins data from the database result.
|
||||||
|
*
|
||||||
|
* @param array $temp An array containing the selected skins data.
|
||||||
|
* @return array An associative array containing selected skins data.
|
||||||
|
*/
|
||||||
|
public static function getSelectedSkins($temp)
|
||||||
{
|
{
|
||||||
$selected = [];
|
$selected = array();
|
||||||
|
|
||||||
foreach ($temp as $weapon) {
|
foreach ($temp as $weapon) {
|
||||||
$selected[$weapon['weapon_defindex']] = [
|
$selected[$weapon['weapon']] = array(
|
||||||
'weapon_paint_id' => $weapon['weapon_paint_id'],
|
'weapon_paint_id' => $weapon['paint'],
|
||||||
'weapon_seed' => $weapon['weapon_seed'],
|
'weapon_seed' => $weapon['seed'],
|
||||||
'weapon_wear' => $weapon['weapon_wear'],
|
'weapon_wear' => $weapon['wear'],
|
||||||
];
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $selected;
|
return $selected;
|
||||||
|
|||||||
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" => 11,
|
"weapon_g3sg1" => 10,
|
||||||
"weapon_galilar" => 13,
|
"weapon_galilar" => 13,
|
||||||
"weapon_m249" => 14,
|
"weapon_m249" => 14,
|
||||||
"weapon_m4a1" => 16,
|
"weapon_m4a1" => 16,
|
||||||
@@ -53,14 +53,7 @@ $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)
|
||||||
{
|
{
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 169 KiB |
|
Before Width: | Height: | Size: 171 KiB |
|
Before Width: | Height: | Size: 162 KiB |
|
Before Width: | Height: | Size: 163 KiB |
|
Before Width: | Height: | Size: 168 KiB |
|
Before Width: | Height: | Size: 175 KiB |
|
Before Width: | Height: | Size: 182 KiB |
|
Before Width: | Height: | Size: 166 KiB |
|
Before Width: | Height: | Size: 171 KiB |
|
Before Width: | Height: | Size: 179 KiB |
|
Before Width: | Height: | Size: 179 KiB |
|
Before Width: | Height: | Size: 169 KiB |
|
Before Width: | Height: | Size: 232 KiB |
|
Before Width: | Height: | Size: 237 KiB |
|
Before Width: | Height: | Size: 241 KiB |
|
Before Width: | Height: | Size: 239 KiB |
|
Before Width: | Height: | Size: 242 KiB |
|
Before Width: | Height: | Size: 232 KiB |
|
Before Width: | Height: | Size: 238 KiB |
|
Before Width: | Height: | Size: 238 KiB |
|
Before Width: | Height: | Size: 239 KiB |
|
Before Width: | Height: | Size: 235 KiB |
|
Before Width: | Height: | Size: 240 KiB |
|
Before Width: | Height: | Size: 231 KiB |
|
Before Width: | Height: | Size: 215 KiB |
|
Before Width: | Height: | Size: 217 KiB |
|
Before Width: | Height: | Size: 215 KiB |
|
Before Width: | Height: | Size: 232 KiB |
|
Before Width: | Height: | Size: 244 KiB |
|
Before Width: | Height: | Size: 218 KiB |
|
Before Width: | Height: | Size: 228 KiB |
|
Before Width: | Height: | Size: 218 KiB |
|
Before Width: | Height: | Size: 224 KiB |
|
Before Width: | Height: | Size: 235 KiB |
|
Before Width: | Height: | Size: 227 KiB |
|
Before Width: | Height: | Size: 216 KiB |
|
Before Width: | Height: | Size: 246 KiB |
|
Before Width: | Height: | Size: 244 KiB |
|
Before Width: | Height: | Size: 253 KiB |
|
Before Width: | Height: | Size: 260 KiB |
|
Before Width: | Height: | Size: 246 KiB |
|
Before Width: | Height: | Size: 246 KiB |
|
Before Width: | Height: | Size: 245 KiB |
|
Before Width: | Height: | Size: 256 KiB |
|
Before Width: | Height: | Size: 252 KiB |
|
Before Width: | Height: | Size: 257 KiB |
|
Before Width: | Height: | Size: 259 KiB |
|
Before Width: | Height: | Size: 253 KiB |
|
Before Width: | Height: | Size: 256 KiB |
|
Before Width: | Height: | Size: 249 KiB |
|
Before Width: | Height: | Size: 248 KiB |
|
Before Width: | Height: | Size: 239 KiB |
|
Before Width: | Height: | Size: 257 KiB |
|
Before Width: | Height: | Size: 249 KiB |
|
Before Width: | Height: | Size: 269 KiB |
|
Before Width: | Height: | Size: 258 KiB |
|
Before Width: | Height: | Size: 251 KiB |
|
Before Width: | Height: | Size: 236 KiB |
|
Before Width: | Height: | Size: 234 KiB |
|
Before Width: | Height: | Size: 199 KiB |
|
Before Width: | Height: | Size: 176 KiB |
|
Before Width: | Height: | Size: 187 KiB |
|
Before Width: | Height: | Size: 200 KiB |
|
Before Width: | Height: | Size: 184 KiB |
|
Before Width: | Height: | Size: 201 KiB |
|
Before Width: | Height: | Size: 196 KiB |
|
Before Width: | Height: | Size: 198 KiB |
|
Before Width: | Height: | Size: 197 KiB |