Compare commits
73 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c5f9cc6429 | ||
|
|
4087d3d016 | ||
|
|
e7919bb468 | ||
|
|
33bd83d0a1 | ||
|
|
73d989c0ce | ||
|
|
f1cecfc73e | ||
|
|
aae6f7e260 | ||
|
|
171d520cc0 | ||
|
|
deac9bab97 | ||
|
|
8a76530302 | ||
|
|
d1cbecaecb | ||
|
|
ebc932e47c | ||
|
|
e258ed8c92 | ||
|
|
e44af369bb | ||
|
|
47055ad6f7 | ||
|
|
d9166253b3 | ||
|
|
4e90506645 | ||
|
|
bd93936fab | ||
|
|
63403dfc8e | ||
|
|
b24a2bd04e | ||
|
|
dbc652a68c | ||
|
|
a59ce8f1a5 | ||
|
|
baaa47d837 | ||
|
|
7dcfea3e17 | ||
|
|
4eab8f0a87 | ||
|
|
236c79c4b9 | ||
|
|
83084452df | ||
|
|
43e7a3183e | ||
|
|
60c592aa54 | ||
|
|
2568f263d9 | ||
|
|
14e285d44f | ||
|
|
97b8840ac4 | ||
|
|
f820c7d251 | ||
|
|
6e5d595c0f | ||
|
|
71d57eb3ad | ||
|
|
620b067991 | ||
|
|
89c425c170 | ||
|
|
c744f2898b | ||
|
|
d04bc0879a | ||
|
|
4417b093dd | ||
|
|
3f8533ab94 | ||
|
|
55905ccc33 | ||
|
|
24fcfa0222 | ||
|
|
cd059c6bfb | ||
|
|
e338bebaec | ||
|
|
efd7f5dbef | ||
|
|
6bd002cdec | ||
|
|
3a1adf8d4a | ||
|
|
7c3fa6469b | ||
|
|
52962518fe | ||
|
|
7e12b89a9e | ||
|
|
ae56b18a3c | ||
|
|
c907911cd1 | ||
|
|
1aa486cd7d | ||
|
|
5e62c7c597 | ||
|
|
819ac6233c | ||
|
|
ed24eb0dfc | ||
|
|
1a9f7ad108 | ||
|
|
6cd1bb3bf5 | ||
|
|
4f94b831c2 | ||
|
|
969d40b970 | ||
|
|
7f41607d54 | ||
|
|
928c1e1466 | ||
|
|
78649f5dcf | ||
|
|
4e72f10326 | ||
|
|
3ddbf7e11e | ||
|
|
ee770fd8c2 | ||
|
|
72c5df53b5 | ||
|
|
d0ed0f4c0b | ||
|
|
a8cf33d404 | ||
|
|
1c026c018e | ||
|
|
4a410fd0d8 | ||
|
|
bb08e88371 |
2
.gitignore
vendored
@@ -1,4 +1,4 @@
|
|||||||
|
|
||||||
.vs/
|
.vs/
|
||||||
bin/
|
bin/
|
||||||
obj/
|
obj/
|
||||||
|
website/getskins.php
|
||||||
|
|||||||
162
Commands.cs
@@ -10,40 +10,49 @@ namespace WeaponPaints
|
|||||||
{
|
{
|
||||||
if (!Config.Additional.CommandWpEnabled || !Config.Additional.SkinEnabled || !g_bCommandsAllowed) return;
|
if (!Config.Additional.CommandWpEnabled || !Config.Additional.SkinEnabled || !g_bCommandsAllowed) return;
|
||||||
if (!Utility.IsPlayerValid(player)) return;
|
if (!Utility.IsPlayerValid(player)) return;
|
||||||
if (player == null || player.Index <= 0) return;
|
|
||||||
|
if (player == null || !player.IsValid || player.UserId == null || player.IsBot) return;
|
||||||
|
|
||||||
int playerIndex = (int)player!.Index;
|
int playerIndex = (int)player!.Index;
|
||||||
|
|
||||||
PlayerInfo playerInfo = new PlayerInfo
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
{
|
{
|
||||||
UserId = player.UserId,
|
UserId = player.UserId,
|
||||||
Index = (int)player.Index,
|
Index = (int)player.Index,
|
||||||
SteamId = player?.AuthorizedSteamID?.SteamId64.ToString(),
|
SteamId = player?.SteamID.ToString(),
|
||||||
Name = player?.PlayerName,
|
Name = player?.PlayerName,
|
||||||
IpAddress = player?.IpAddress?.Split(":")[0]
|
IpAddress = player?.IpAddress?.Split(":")[0]
|
||||||
};
|
};
|
||||||
|
|
||||||
if (playerIndex != 0 && DateTime.UtcNow >= commandCooldown[playerIndex].AddSeconds(Config.CmdRefreshCooldownSeconds))
|
if (player == null || !player.IsValid || player.UserId == null || player.IsBot) return;
|
||||||
{
|
|
||||||
commandCooldown[playerIndex] = DateTime.UtcNow;
|
|
||||||
if (weaponSync != null)
|
|
||||||
Task.Run(async () => await weaponSync.GetWeaponPaintsFromDatabase(playerInfo));
|
|
||||||
if (Config.Additional.KnifeEnabled)
|
|
||||||
{
|
|
||||||
if (weaponSync != null)
|
|
||||||
Task.Run(async () => await weaponSync.GetKnifeFromDatabase(playerInfo));
|
|
||||||
|
|
||||||
RefreshWeapons(player);
|
try
|
||||||
}
|
|
||||||
if (!string.IsNullOrEmpty(Localizer["wp_command_refresh_done"]))
|
|
||||||
{
|
|
||||||
player!.Print(Localizer["wp_command_refresh_done"]);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!string.IsNullOrEmpty(Localizer["wp_command_cooldown"]))
|
|
||||||
{
|
{
|
||||||
player!.Print(Localizer["wp_command_cooldown"]);
|
if (!commandsCooldown.TryGetValue((int)player.UserId, out DateTime cooldownEndTime) ||
|
||||||
|
DateTime.UtcNow >= (commandsCooldown.TryGetValue((int)player.UserId, out cooldownEndTime) ? cooldownEndTime : DateTime.UtcNow))
|
||||||
|
{
|
||||||
|
commandsCooldown[(int)player.UserId] = DateTime.UtcNow.AddSeconds(Config.CmdRefreshCooldownSeconds);
|
||||||
|
if (weaponSync != null)
|
||||||
|
Task.Run(async () => await weaponSync.GetWeaponPaintsFromDatabase(playerInfo));
|
||||||
|
if (Config.Additional.KnifeEnabled)
|
||||||
|
{
|
||||||
|
if (weaponSync != null)
|
||||||
|
Task.Run(async () => await weaponSync.GetKnifeFromDatabase(playerInfo));
|
||||||
|
|
||||||
|
RefreshWeapons(player);
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(Localizer["wp_command_refresh_done"]))
|
||||||
|
{
|
||||||
|
player!.Print(Localizer["wp_command_refresh_done"]);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(Localizer["wp_command_cooldown"]))
|
||||||
|
{
|
||||||
|
player!.Print(Localizer["wp_command_cooldown"]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnCommandWS(CCSPlayerController? player, CommandInfo command)
|
private void OnCommandWS(CCSPlayerController? player, CommandInfo command)
|
||||||
@@ -98,44 +107,40 @@ namespace WeaponPaints
|
|||||||
.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) =>
|
giveItemMenu.PostSelectAction = PostSelectAction.Close;
|
||||||
|
var handleGive = (CCSPlayerController player, ChatMenuOption option) =>
|
||||||
{
|
{
|
||||||
if (Utility.IsPlayerValid(player))
|
if (!Utility.IsPlayerValid(player)) return;
|
||||||
|
|
||||||
|
var knifeName = option.Text;
|
||||||
|
var knifeKey = knivesOnly.FirstOrDefault(x => x.Value == knifeName).Key;
|
||||||
|
if (!string.IsNullOrEmpty(knifeKey))
|
||||||
{
|
{
|
||||||
if (player == null) return;
|
if (!string.IsNullOrEmpty(Localizer["wp_knife_menu_select"]))
|
||||||
var knifeName = option.Text;
|
|
||||||
var knifeKey = knivesOnly.FirstOrDefault(x => x.Value == knifeName).Key;
|
|
||||||
if (!string.IsNullOrEmpty(knifeKey))
|
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(Localizer["wp_knife_menu_select"]))
|
player!.Print(Localizer["wp_knife_menu_select", knifeName]);
|
||||||
{
|
|
||||||
player!.Print(Localizer["wp_knife_menu_select", knifeName]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(Localizer["wp_knife_menu_kill"]) && Config.Additional.CommandKillEnabled)
|
|
||||||
{
|
|
||||||
player!.Print(Localizer["wp_knife_menu_kill"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayerInfo playerInfo = new PlayerInfo
|
|
||||||
{
|
|
||||||
UserId = player.UserId,
|
|
||||||
Index = (int)player.Index,
|
|
||||||
SteamId = player?.AuthorizedSteamID?.SteamId64.ToString(),
|
|
||||||
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,
|
||||||
|
Index = (int)player.Index,
|
||||||
|
SteamId = player.SteamID.ToString(),
|
||||||
|
Name = player.PlayerName,
|
||||||
|
IpAddress = player.IpAddress?.Split(":")[0]
|
||||||
|
};
|
||||||
|
|
||||||
|
g_playersKnife[(int)player!.Index] = knifeKey;
|
||||||
|
|
||||||
|
if (g_bCommandsAllowed && (LifeState_t)player.LifeState == LifeState_t.LIFE_ALIVE)
|
||||||
|
RefreshKnife(player);
|
||||||
|
|
||||||
|
_ = weaponSync?.SyncKnifeToDatabase(playerInfo, knifeKey) ?? Task.CompletedTask;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
foreach (var knifePair in knivesOnly)
|
foreach (var knifePair in knivesOnly)
|
||||||
@@ -145,12 +150,14 @@ namespace WeaponPaints
|
|||||||
AddCommand($"css_{Config.Additional.CommandKnife}", "Knife Menu", (player, info) =>
|
AddCommand($"css_{Config.Additional.CommandKnife}", "Knife Menu", (player, info) =>
|
||||||
{
|
{
|
||||||
if (!Utility.IsPlayerValid(player) || !g_bCommandsAllowed) return;
|
if (!Utility.IsPlayerValid(player) || !g_bCommandsAllowed) return;
|
||||||
int playerIndex = (int)player!.Index;
|
|
||||||
|
|
||||||
if (commandCooldown != null && DateTime.UtcNow >= commandCooldown[playerIndex].AddSeconds(Config.CmdRefreshCooldownSeconds))
|
if (player == null || player.UserId == null) return;
|
||||||
|
|
||||||
|
if (!commandsCooldown.TryGetValue((int)player.UserId, out DateTime cooldownEndTime) ||
|
||||||
|
DateTime.UtcNow >= (commandsCooldown.TryGetValue((int)player.UserId, out cooldownEndTime) ? cooldownEndTime : DateTime.UtcNow))
|
||||||
{
|
{
|
||||||
commandCooldown[playerIndex] = DateTime.UtcNow;
|
commandsCooldown[(int)player.UserId] = DateTime.UtcNow.AddSeconds(Config.CmdRefreshCooldownSeconds);
|
||||||
ChatMenus.OpenMenu(player, giveItemMenu);
|
MenuManager.OpenChatMenu(player, giveItemMenu);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrEmpty(Localizer["wp_command_cooldown"]))
|
if (!string.IsNullOrEmpty(Localizer["wp_command_cooldown"]))
|
||||||
@@ -182,17 +189,16 @@ 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 (p == null || !p.IsValid || p.Index <= 0) return;
|
if (!Utility.IsPlayerValid(p)) return;
|
||||||
|
|
||||||
playerIndex = (int)p.Index;
|
playerIndex = (int)p.Index;
|
||||||
|
|
||||||
if (p.AuthorizedSteamID == null) return;
|
string steamId = p.SteamID.ToString();
|
||||||
|
|
||||||
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))
|
||||||
@@ -210,7 +216,7 @@ namespace WeaponPaints
|
|||||||
int.TryParse(weaponDefIndexObj.ToString(), out var weaponDefIndex) &&
|
int.TryParse(weaponDefIndexObj.ToString(), out var weaponDefIndex) &&
|
||||||
int.TryParse(selectedPaintID, out var paintID))
|
int.TryParse(selectedPaintID, out var paintID))
|
||||||
{
|
{
|
||||||
p!.Print(Localizer["f", selectedSkin]);
|
p!.Print(Localizer["wp_skin_menu_select", selectedSkin]);
|
||||||
|
|
||||||
if (!gPlayerWeaponsInfo[playerIndex].ContainsKey(weaponDefIndex))
|
if (!gPlayerWeaponsInfo[playerIndex].ContainsKey(weaponDefIndex))
|
||||||
{
|
{
|
||||||
@@ -223,13 +229,16 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
PlayerInfo playerInfo = new PlayerInfo
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
{
|
{
|
||||||
UserId = player.UserId,
|
UserId = p.UserId,
|
||||||
Index = (int)player.Index,
|
Index = (int)p.Index,
|
||||||
SteamId = player?.AuthorizedSteamID?.SteamId64.ToString(),
|
SteamId = p.SteamID.ToString(),
|
||||||
Name = player?.PlayerName,
|
Name = p.PlayerName,
|
||||||
IpAddress = player?.IpAddress?.Split(":")[0]
|
IpAddress = p.IpAddress?.Split(":")[0]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (g_bCommandsAllowed && (LifeState_t)p.LifeState == LifeState_t.LIFE_ALIVE)
|
||||||
|
RefreshWeapons(p);
|
||||||
|
|
||||||
if (!Config.GlobalShare)
|
if (!Config.GlobalShare)
|
||||||
{
|
{
|
||||||
if (weaponSync != null)
|
if (weaponSync != null)
|
||||||
@@ -257,7 +266,7 @@ namespace WeaponPaints
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Open the submenu for skin selection of the chosen weapon
|
// Open the submenu for skin selection of the chosen weapon
|
||||||
ChatMenus.OpenMenu(player, skinSubMenu);
|
MenuManager.OpenChatMenu(player, skinSubMenu);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -271,12 +280,15 @@ namespace WeaponPaints
|
|||||||
AddCommand($"css_{Config.Additional.CommandSkinSelection}", "Skins selection menu", (player, info) =>
|
AddCommand($"css_{Config.Additional.CommandSkinSelection}", "Skins selection menu", (player, info) =>
|
||||||
{
|
{
|
||||||
if (!Utility.IsPlayerValid(player)) return;
|
if (!Utility.IsPlayerValid(player)) return;
|
||||||
int playerIndex = (int)player!.Index;
|
|
||||||
|
|
||||||
if (commandCooldown != null && DateTime.UtcNow >= commandCooldown[playerIndex].AddSeconds(Config.CmdRefreshCooldownSeconds) && playerIndex > 0 && playerIndex < commandCooldown.Length)
|
if (player == null || player.UserId == null) return;
|
||||||
|
|
||||||
|
if (!commandsCooldown.TryGetValue((int)player.UserId, out DateTime cooldownEndTime) ||
|
||||||
|
DateTime.UtcNow >= (commandsCooldown.TryGetValue((int)player.UserId, out cooldownEndTime) ? cooldownEndTime : DateTime.UtcNow))
|
||||||
{
|
{
|
||||||
commandCooldown[playerIndex] = DateTime.UtcNow;
|
commandsCooldown[(int)player.UserId] = DateTime.UtcNow.AddSeconds(Config.CmdRefreshCooldownSeconds);
|
||||||
ChatMenus.OpenMenu(player, weaponSelectionMenu);
|
MenuManager.OpenChatMenu(player, weaponSelectionMenu);
|
||||||
|
weaponSelectionMenu.PostSelectAction = PostSelectAction.Close;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrEmpty(Localizer["wp_command_cooldown"]))
|
if (!string.IsNullOrEmpty(Localizer["wp_command_cooldown"]))
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ 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;
|
||||||
}
|
}
|
||||||
@@ -78,5 +79,4 @@ namespace WeaponPaints
|
|||||||
[JsonPropertyName("Additional")]
|
[JsonPropertyName("Additional")]
|
||||||
public Additional Additional { get; set; } = new Additional();
|
public Additional Additional { get; set; } = new Additional();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
28
Database.cs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
using MySqlConnector;
|
||||||
|
|
||||||
|
namespace WeaponPaints
|
||||||
|
{
|
||||||
|
public class Database
|
||||||
|
{
|
||||||
|
private readonly string _dbConnectionString;
|
||||||
|
|
||||||
|
public Database(string dbConnectionString)
|
||||||
|
{
|
||||||
|
_dbConnectionString = dbConnectionString;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<MySqlConnection> GetConnectionAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var connection = new MySqlConnection(_dbConnectionString);
|
||||||
|
await connection.OpenAsync();
|
||||||
|
return connection;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
182
Events.cs
@@ -1,54 +1,62 @@
|
|||||||
using CounterStrikeSharp.API;
|
using CounterStrikeSharp.API;
|
||||||
using CounterStrikeSharp.API.Core;
|
using CounterStrikeSharp.API.Core;
|
||||||
using CounterStrikeSharp.API.Modules.Entities;
|
|
||||||
|
|
||||||
namespace WeaponPaints
|
namespace WeaponPaints
|
||||||
{
|
{
|
||||||
public partial class WeaponPaints
|
public partial class WeaponPaints
|
||||||
{
|
{
|
||||||
private void OnClientAuthorized(int playerSlot, SteamID steamID)
|
private void OnClientPutInServer(int playerSlot)
|
||||||
{
|
{
|
||||||
int playerIndex = playerSlot + 1;
|
CCSPlayerController? player = Utilities.GetPlayerFromSlot(playerSlot);
|
||||||
|
|
||||||
CCSPlayerController? player = Utilities.GetPlayerFromIndex(playerIndex);
|
if (player == null || !player.IsValid || player.IsBot || player.IsHLTV || weaponSync == null || player.Connected == PlayerConnectedState.PlayerDisconnecting) return;
|
||||||
|
|
||||||
PlayerInfo playerInfo = new PlayerInfo
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
{
|
{
|
||||||
UserId = player.UserId,
|
UserId = player.UserId,
|
||||||
Index = (int)player.Index,
|
Index = (int)player.Index,
|
||||||
SteamId = player?.AuthorizedSteamID?.SteamId64.ToString(),
|
SteamId = player.SteamID.ToString(),
|
||||||
Name = player?.PlayerName,
|
Name = player.PlayerName,
|
||||||
IpAddress = player?.IpAddress?.Split(":")[0]
|
IpAddress = player.IpAddress?.Split(":")[0]
|
||||||
};
|
};
|
||||||
|
|
||||||
if (player == null || !player.IsValid || player.IsBot || player.IsHLTV || weaponSync == null) return;
|
if (!gPlayerWeaponsInfo.ContainsKey((int)player.Index))
|
||||||
|
|
||||||
Task.Run(async () =>
|
|
||||||
{
|
{
|
||||||
if (Config.Additional.SkinEnabled)
|
_ = Task.Run(async () =>
|
||||||
await weaponSync.GetKnifeFromDatabase(playerInfo);
|
{
|
||||||
});
|
if (Config.Additional.SkinEnabled)
|
||||||
|
await weaponSync.GetWeaponPaintsFromDatabase(playerInfo);
|
||||||
|
|
||||||
//if (Config.Additional.KnifeEnabled && weaponSync != null)
|
if (Config.Additional.KnifeEnabled)
|
||||||
//_ = weaponSync.GetKnifeFromDatabase(playerIndex);
|
await weaponSync.GetKnifeFromDatabase(playerInfo);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnClientDisconnect(int playerSlot)
|
private void OnClientDisconnect(int playerSlot)
|
||||||
{
|
{
|
||||||
CCSPlayerController player = Utilities.GetPlayerFromSlot(playerSlot);
|
CCSPlayerController player = Utilities.GetPlayerFromSlot(playerSlot);
|
||||||
|
|
||||||
if (player == null || !player.IsValid || player.IsBot || player.IsHLTV) return;
|
if (player == null || !player.IsValid || player.IsBot || player.IsHLTV || player.UserId == null)
|
||||||
|
return;
|
||||||
|
|
||||||
if (Config.Additional.KnifeEnabled)
|
if (Config.Additional.KnifeEnabled)
|
||||||
g_playersKnife.Remove((int)player.Index);
|
g_playersKnife.TryRemove((int)player.Index, out _);
|
||||||
if (Config.Additional.SkinEnabled)
|
|
||||||
gPlayerWeaponsInfo.Remove((int)player.Index);
|
if (Config.Additional.SkinEnabled && gPlayerWeaponsInfo.TryGetValue((int)player.Index, out var innerDictionary))
|
||||||
|
{
|
||||||
|
innerDictionary.Clear();
|
||||||
|
gPlayerWeaponsInfo.TryRemove((int)player.Index, out _);
|
||||||
|
}
|
||||||
|
|
||||||
|
commandsCooldown.Remove((int)player.UserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnEntityCreated(CEntityInstance entity)
|
private void OnEntityCreated(CEntityInstance entity)
|
||||||
{
|
{
|
||||||
if (!Config.Additional.SkinEnabled) return;
|
if (!Config.Additional.SkinEnabled) return;
|
||||||
var designerName = entity.DesignerName;
|
if (entity == null || !entity.IsValid || string.IsNullOrEmpty(entity.DesignerName)) return;
|
||||||
|
string designerName = entity.DesignerName;
|
||||||
if (!weaponList.ContainsKey(designerName)) return;
|
if (!weaponList.ContainsKey(designerName)) return;
|
||||||
bool isKnife = false;
|
bool isKnife = false;
|
||||||
var weapon = new CBasePlayerWeapon(entity.Handle);
|
var weapon = new CBasePlayerWeapon(entity.Handle);
|
||||||
@@ -66,7 +74,8 @@ 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;
|
||||||
var pawn = new CBasePlayerPawn(NativeAPI.GetEntityFromIndex(weaponOwner));
|
CBasePlayerPawn? pawn = Utilities.GetEntityFromIndex<CCSPlayerPawn>((int)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;
|
||||||
@@ -85,34 +94,29 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
if (player == null || !player.IsValid) return HookResult.Continue;
|
if (player == null || !player.IsValid) return HookResult.Continue;
|
||||||
|
|
||||||
|
/*
|
||||||
if (Config.Additional.SkinVisibilityFix)
|
if (Config.Additional.SkinVisibilityFix)
|
||||||
AddTimer(0.2f, () => RefreshSkins(player));
|
AddTimer(0.2f, () => RefreshSkins(player));
|
||||||
|
*/
|
||||||
|
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
private HookResult OnItemPickup(EventItemPickup @event, GameEventInfo info)
|
private HookResult OnItemPickup(EventItemPickup @event, GameEventInfo info)
|
||||||
{
|
{
|
||||||
if (@event.Defindex == 42 || @event.Defindex == 59)
|
if (@event.Defindex == 42 || @event.Defindex == 59)
|
||||||
{
|
{
|
||||||
Server.PrintToChatAll("test1");
|
|
||||||
|
|
||||||
CCSPlayerController? player = @event.Userid;
|
CCSPlayerController? player = @event.Userid;
|
||||||
if (player == null || !player.IsValid || !g_knifePickupCount.ContainsKey((int)player.Index) || player.IsBot || !g_playersKnife.ContainsKey((int)player.Index))
|
if (player == null || !player.IsValid || !g_knifePickupCount.ContainsKey((int)player.Index) || player.IsBot || !g_playersKnife.ContainsKey((int)player.Index))
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
|
|
||||||
Server.PrintToChatAll("test2");
|
|
||||||
|
|
||||||
|
|
||||||
if (g_knifePickupCount[(int)player.Index] >= 2) return HookResult.Continue;
|
if (g_knifePickupCount[(int)player.Index] >= 2) return HookResult.Continue;
|
||||||
Server.PrintToChatAll("test3");
|
|
||||||
|
|
||||||
|
|
||||||
if (g_playersKnife.ContainsKey((int)player.Index)
|
if (g_playersKnife.ContainsKey((int)player.Index)
|
||||||
&&
|
&&
|
||||||
g_playersKnife[(int)player.Index] != "weapon_knife")
|
g_playersKnife[(int)player.Index] != "weapon_knife")
|
||||||
{
|
{
|
||||||
Server.PrintToChatAll("usuwam noz");
|
|
||||||
g_knifePickupCount[(int)player.Index]++;
|
g_knifePickupCount[(int)player.Index]++;
|
||||||
|
|
||||||
RemovePlayerKnife(player, true);
|
RemovePlayerKnife(player, true);
|
||||||
@@ -123,69 +127,79 @@ namespace WeaponPaints
|
|||||||
}
|
}
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
public HookResult OnPickup(CEntityIOOutput output, string name, CEntityInstance activator, CEntityInstance caller, CVariant value, float delay)
|
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 ||
|
||||||
return HookResult.Continue;
|
player.SteamID.ToString() == "" || !g_knifePickupCount.TryGetValue((int)player.Index, out var pickupCount) ||
|
||||||
|
!g_playersKnife.ContainsKey((int)player.Index))
|
||||||
if (player == null || !player.IsValid || player.AuthorizedSteamID == null ||
|
{
|
||||||
!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 (g_knifePickupCount[(int)player.Index] >= 2) return HookResult.Continue;
|
if (pickupCount >= 2)
|
||||||
|
{
|
||||||
|
return HookResult.Continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (g_playersKnife[(int)player.Index] != "weapon_knife")
|
if (g_playersKnife[(int)player.Index] != "weapon_knife")
|
||||||
{
|
{
|
||||||
g_knifePickupCount[(int)player.Index]++;
|
pickupCount++;
|
||||||
weapon.Remove();
|
g_knifePickupCount[(int)player.Index] = pickupCount;
|
||||||
if (!PlayerHasKnife(player) && Config.Additional.GiveKnifeAfterRemove)
|
player.RemoveItemByDesignerName(weapon.DesignerName);
|
||||||
|
if (Config.Additional.GiveKnifeAfterRemove)
|
||||||
|
{
|
||||||
AddTimer(0.2f, () => GiveKnifeToPlayer(player));
|
AddTimer(0.2f, () => GiveKnifeToPlayer(player));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void OnMapStart(string mapName)
|
private void OnMapStart(string mapName)
|
||||||
{
|
{
|
||||||
if (!Config.Additional.KnifeEnabled) return;
|
if (!Config.Additional.KnifeEnabled && !Config.Additional.SkinEnabled) return;
|
||||||
|
|
||||||
|
if (_database != null)
|
||||||
|
weaponSync = new WeaponSynchronization(_database, Config, GlobalShareApi, GlobalShareServerId);
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
// needed for now
|
// needed for now
|
||||||
AddTimer(2.0f, () =>
|
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)
|
if (Config.GlobalShare)
|
||||||
GlobalShareConnect();
|
GlobalShareConnect();
|
||||||
|
|
||||||
weaponSync = new WeaponSynchronization(DatabaseConnectionString, Config, GlobalShareApi, GlobalShareServerId);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
g_hTimerCheckSkinsData = AddTimer(10.0f, () =>
|
g_hTimerCheckSkinsData = AddTimer(10.0f, () =>
|
||||||
{
|
{
|
||||||
List<CCSPlayerController> players = Utilities.GetPlayers();
|
List<CCSPlayerController> players = Utilities.GetPlayers();
|
||||||
|
|
||||||
foreach (CCSPlayerController player in players)
|
foreach (CCSPlayerController player in players)
|
||||||
{
|
{
|
||||||
if (player.IsBot || player.IsHLTV || player.AuthorizedSteamID == null) continue;
|
if (player.IsBot || player.IsHLTV || player.SteamID.ToString() == "") continue;
|
||||||
if (gPlayerWeaponsInfo.ContainsKey((int)player.Index)) continue;
|
if (gPlayerWeaponsInfo.ContainsKey((int)player.Index)) continue;
|
||||||
|
|
||||||
PlayerInfo playerInfo = new PlayerInfo
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
{
|
{
|
||||||
UserId = player.UserId,
|
UserId = player.UserId,
|
||||||
Index = (int)player.Index,
|
Index = (int)player.Index,
|
||||||
SteamId = player?.AuthorizedSteamID?.SteamId64.ToString(),
|
SteamId = player?.SteamID.ToString(),
|
||||||
Name = player?.PlayerName,
|
Name = player?.PlayerName,
|
||||||
IpAddress = player?.IpAddress?.Split(":")[0]
|
IpAddress = player?.IpAddress?.Split(":")[0]
|
||||||
};
|
};
|
||||||
@@ -196,6 +210,7 @@ namespace WeaponPaints
|
|||||||
_ = weaponSync.GetKnifeFromDatabase(playerInfo);
|
_ = weaponSync.GetKnifeFromDatabase(playerInfo);
|
||||||
}
|
}
|
||||||
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE | CounterStrikeSharp.API.Modules.Timers.TimerFlags.REPEAT);
|
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE | CounterStrikeSharp.API.Modules.Timers.TimerFlags.REPEAT);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private HookResult OnPlayerConnectFull(EventPlayerConnectFull @event, GameEventInfo info)
|
private HookResult OnPlayerConnectFull(EventPlayerConnectFull @event, GameEventInfo info)
|
||||||
@@ -208,7 +223,7 @@ namespace WeaponPaints
|
|||||||
{
|
{
|
||||||
UserId = player.UserId,
|
UserId = player.UserId,
|
||||||
Index = (int)player.Index,
|
Index = (int)player.Index,
|
||||||
SteamId = player?.AuthorizedSteamID?.SteamId64.ToString(),
|
SteamId = player?.SteamID.ToString(),
|
||||||
Name = player?.PlayerName,
|
Name = player?.PlayerName,
|
||||||
IpAddress = player?.IpAddress?.Split(":")[0]
|
IpAddress = player?.IpAddress?.Split(":")[0]
|
||||||
};
|
};
|
||||||
@@ -231,21 +246,13 @@ namespace WeaponPaints
|
|||||||
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 || player.IsBot)
|
if (player == null || !player.IsValid || !Config.Additional.KnifeEnabled || PlayerHasKnife(player))
|
||||||
{
|
{
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.Additional.KnifeEnabled)
|
g_knifePickupCount[(int)player.Index] = 0;
|
||||||
{
|
GiveKnifeToPlayer(player);
|
||||||
g_knifePickupCount[(int)player.Index] = 0;
|
|
||||||
AddTimer(0.1f, () => GiveKnifeToPlayer(player));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.Additional.SkinVisibilityFix)
|
|
||||||
{
|
|
||||||
AddTimer(0.3f, () => RefreshSkins(player));
|
|
||||||
}
|
|
||||||
|
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
}
|
}
|
||||||
@@ -267,18 +274,73 @@ namespace WeaponPaints
|
|||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnTick()
|
||||||
|
{
|
||||||
|
foreach (var player in Utilities.GetPlayers())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (player is null || !player.IsValid || !player.PawnIsAlive || player.IsBot || player.IsHLTV || player.Connected != PlayerConnectedState.PlayerConnected)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var viewModels = GetPlayerViewModels(player);
|
||||||
|
if (viewModels == null || viewModels.Length == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var viewModel = viewModels[0];
|
||||||
|
if (viewModel == null || viewModel.Value == null || viewModel.Value.Weapon == null || viewModel.Value.Weapon.Value == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var weapon = viewModel.Value.Weapon.Value;
|
||||||
|
if (weapon == null || !weapon.IsValid)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (viewModel.Value.VMName.Contains("knife"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var sceneNode = viewModel.Value.CBodyComponent?.SceneNode;
|
||||||
|
if (sceneNode == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var skeleton = GetSkeletonInstance(sceneNode);
|
||||||
|
if (skeleton == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
int[] knifePaintKits = { 1171, 1170, 1169, 1164, 1162, 1161, 1159, 1175, 1174, 1167, 1165, 1168, 1163, 1160, 1166, 1173 };
|
||||||
|
if (knifePaintKits.Contains(weapon.FallbackPaintKit))
|
||||||
|
{
|
||||||
|
skeleton.ModelState.MeshGroupMask = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (skeleton.ModelState.MeshGroupMask != 2)
|
||||||
|
{
|
||||||
|
skeleton.ModelState.MeshGroupMask = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Utilities.SetStateChanged(viewModel.Value, "CBaseEntity", "m_CBodyComponent");
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
// Handle exceptions silently
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void RegisterListeners()
|
private void RegisterListeners()
|
||||||
{
|
{
|
||||||
RegisterListener<Listeners.OnEntityCreated>(OnEntityCreated);
|
RegisterListener<Listeners.OnEntityCreated>(OnEntityCreated);
|
||||||
RegisterListener<Listeners.OnClientAuthorized>(OnClientAuthorized);
|
RegisterListener<Listeners.OnClientPutInServer>(OnClientPutInServer);
|
||||||
RegisterListener<Listeners.OnClientDisconnect>(OnClientDisconnect);
|
RegisterListener<Listeners.OnClientDisconnect>(OnClientDisconnect);
|
||||||
RegisterListener<Listeners.OnMapStart>(OnMapStart);
|
RegisterListener<Listeners.OnMapStart>(OnMapStart);
|
||||||
|
RegisterListener<Listeners.OnTick>(OnTick);
|
||||||
|
|
||||||
RegisterEventHandler<EventPlayerConnectFull>(OnPlayerConnectFull);
|
//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<EventItemPurchase>(OnEventItemPurchasePost);
|
||||||
//RegisterEventHandler<EventItemPickup>(OnItemPickup);
|
//RegisterEventHandler<EventItemPickup>(OnItemPickup);
|
||||||
HookEntityOutput("weapon_knife", "OnPlayerPickup", OnPickup, HookMode.Pre);
|
HookEntityOutput("weapon_knife", "OnPlayerPickup", OnPickup, HookMode.Pre);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ public static class PlayerExtensions
|
|||||||
{
|
{
|
||||||
public static void Print(this CCSPlayerController controller, string message)
|
public static void Print(this CCSPlayerController controller, string message)
|
||||||
{
|
{
|
||||||
|
if (WeaponPaints._localizer == null) return;
|
||||||
StringBuilder _message = new(WeaponPaints._localizer["wp_prefix"]);
|
StringBuilder _message = new(WeaponPaints._localizer["wp_prefix"]);
|
||||||
_message.Append(message);
|
_message.Append(message);
|
||||||
controller.PrintToChat(_message.ToString());
|
controller.PrintToChat(_message.ToString());
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
|
|
||||||
64
README.md
@@ -1,26 +1,31 @@
|
|||||||
# CS2 Weapon Paints
|
# CS2 Weapon Paints
|
||||||
|
|
||||||
## Description
|
## Description
|
||||||
Unfinished, unoptimized and not fully functional ugly demo weapon paints plugin for **[CSSharp](https://docs.cssharp.dev/)**.
|
Unfinished, unoptimized and not fully functional ugly demo weapon paints plugin for **[CSSharp](https://docs.cssharp.dev/docs/guides/getting-started.html)**.
|
||||||
|
|
||||||
## Created [Discord server](https://discord.gg/d9CvaYPSFe) where you can discus about plugin.
|
## Created [Discord server](https://discord.gg/d9CvaYPSFe) where you can discuss about plugin.
|
||||||
|
|
||||||
### Consider to donate instead of buying from unknown sources.
|
### Consider to donate instead of buying from unknown sources.
|
||||||
[](https://ko-fi.com/E1E2G0P2O) or [](https://steamcommunity.com/tradeoffer/new/?partner=41515647&token=gW2W-nXE)
|
[](https://ko-fi.com/E1E2G0P2O) or [](https://steamcommunity.com/tradeoffer/new/?partner=41515647&token=gW2W-nXE)
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
- Changes only paint, seed and wear on weapons and knives;
|
- Changes only paint, seed and wear on weapons and knives
|
||||||
- MySQL based or global website at [weaponpaints.fun](https://weaponpaints.fun/), so you dont need MySQL/Website;
|
- MySQL based or global website, so you dont need MySQL/Website
|
||||||
- Data sync on player connect;
|
- Data syncs on player connect
|
||||||
- Added command **`!wp`** to refresh skins; ***(with cooldown in second can be configured)***
|
- Added command **`!wp`** to refresh skins ***(with cooldown in seconds can be configured)***
|
||||||
- Added command **`!ws`** to show website;
|
- Added command **`!ws`** to show website
|
||||||
- Added command **`!knife`** to show menu with knives;
|
- Added command **`!knife`** to show menu with knives
|
||||||
- Knife change is now limited to have these cvars empty **`mp_t_default_melee ""`** and **`mp_ct_default_melee ""`**;
|
- 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
|
||||||
|
|
||||||
|
**GlobalShare** - global website accessible at [weaponpaints.fun](https://weaponpaints.fun/)
|
||||||
|
|
||||||
## CS2 Server
|
## CS2 Server
|
||||||
- Compile and copy plugin to plugins, [more info here](https://docs.cssharp.dev/guides/hello-world-plugin/);
|
- Have working CounterStrikeSharp (**with RUNTIME!**)
|
||||||
- Setup **`addons/counterstrikesharp/configs/plugins/WeaponPaints/WeaponPaints.json`** set **`GlobalShare`** to **`true`** for global, or include database credentials;
|
- Download from Release and copy plugin to plugins
|
||||||
- in **`addons/counterstrikesharp/configs/core.json`** set **FollowCS2ServerGuidelines** to **`false`**;
|
- Run server with plugin, **it will generate config if installed correctly!**
|
||||||
|
- Edit `addons/counterstrikesharp/configs/`**`plugins/WeaponPaints/WeaponPaints.json`** set **`GlobalShare`** to **`true`** for global, or include database credentials
|
||||||
|
- In `addons/counterstrikesharp/configs/`**`core.json`** set **FollowCS2ServerGuidelines** to **`false`**
|
||||||
|
|
||||||
## Plugin Configuration
|
## Plugin Configuration
|
||||||
<details>
|
<details>
|
||||||
@@ -69,15 +74,38 @@ Unfinished, unoptimized and not fully functional ugly demo weapon paints plugin
|
|||||||
</details>
|
</details>
|
||||||
|
|
||||||
## Web install
|
## Web install
|
||||||
Disregard if the config is **`GlobalShare = true`**;
|
Disregard if the config is **`GlobalShare = true`**
|
||||||
- Requires PHP >= 7.4; ***(Tested on php ver **`8.2.3`** and nginx webserver)***
|
- Requires PHP >= 7.4 ***(Tested on php ver **`8.2.3`** and nginx webserver)***
|
||||||
- Copy website to web server; ***(Folder `img` not needed)***
|
- **Before using website, make sure the plugin is correctly loaded in cs2 server!** Mysql tables are created by plugin not by website.
|
||||||
- Get [Steam API Key](https://steamcommunity.com/dev/apikey);
|
- Copy website to web server ***(Folder `img` not needed)***
|
||||||
- Fill in database credentials and api key in `class/config.php`;
|
- Get [Steam API Key](https://steamcommunity.com/dev/apikey)
|
||||||
- Visit website and login via steam;
|
- Fill in database credentials and api key in `class/config.php`
|
||||||
|
- Visit website and login via steam
|
||||||
|
|
||||||
|
## Web Features
|
||||||
|
- Basic website
|
||||||
|
- Steam login/logout
|
||||||
|
- Change knife, paint, seed and wear
|
||||||
|
|
||||||
## Known issues
|
## Known issues
|
||||||
- Issue on Windows servers, no knives are given.
|
- Issue on Windows servers, no knives are given.
|
||||||
|
- You can't change knife if it's equpied in cs2 inventory
|
||||||
|
- Can cause incompatibility with plugins/maps which manipulates weapons and knives
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
<details>
|
||||||
|
**Skins are not changing:**
|
||||||
|
Set FollowCSGOGuidelines to false in cssharp’s core.jcon config
|
||||||
|
|
||||||
|
**Database error table does not exists:**
|
||||||
|
Plugin is not loaded or configured with mysql credentials. Tables are auto-created by plugin.
|
||||||
|
|
||||||
|
**Knives are disappearing:**
|
||||||
|
Set in config GiveKnifeAfterRemove to true
|
||||||
|
|
||||||
|
**Knives are not changing for players:**
|
||||||
|
You can't change knife if you have your own equipped
|
||||||
|
</details>
|
||||||
|
|
||||||
### Use this plugin at your own risk! Using this may lead to GSLT ban or something else Valve come with. [Valve Server guidelines](https://blog.counter-strike.net/index.php/server_guidelines/)
|
### Use this plugin at your own risk! Using this may lead to GSLT ban or something else Valve come with. [Valve Server guidelines](https://blog.counter-strike.net/index.php/server_guidelines/)
|
||||||
|
|
||||||
|
|||||||
67
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 MySqlConnector;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using System.Reflection;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using MySqlConnector;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace WeaponPaints
|
namespace WeaponPaints
|
||||||
{
|
{
|
||||||
@@ -23,27 +23,44 @@ 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
|
||||||
{
|
{
|
||||||
using var connection = new MySqlConnection(BuildDatabaseConnectionString());
|
await using var connection = await WeaponPaints._database.GetConnectionAsync();
|
||||||
await connection.OpenAsync();
|
|
||||||
|
|
||||||
using var transaction = await connection.BeginTransactionAsync();
|
await using var transaction = await connection.BeginTransactionAsync();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string createTable1 = "CREATE TABLE IF NOT EXISTS `wp_player_skins` (`steamid` varchar(64) NOT NULL, `weapon_defindex` int(6) NOT NULL, `weapon_paint_id` int(6) NOT NULL, `weapon_wear` float NOT NULL DEFAULT 0.000001, `weapon_seed` int(16) NOT NULL DEFAULT 0) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci";
|
string[] createTableQueries = new[]
|
||||||
string createTable2 = "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_skins` (
|
||||||
|
`steamid` varchar(64) NOT NULL,
|
||||||
|
`weapon_defindex` int(6) NOT NULL,
|
||||||
|
`weapon_paint_id` int(6) NOT NULL,
|
||||||
|
`weapon_wear` float NOT NULL DEFAULT 0.000001,
|
||||||
|
`weapon_seed` int(16) NOT NULL DEFAULT 0
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci",
|
||||||
|
@"CREATE TABLE IF NOT EXISTS `wp_player_knife` (
|
||||||
|
`steamid` varchar(64) NOT NULL,
|
||||||
|
`knife` varchar(64) NOT NULL,
|
||||||
|
UNIQUE (`steamid`)
|
||||||
|
) ENGINE = InnoDB"
|
||||||
|
};
|
||||||
|
|
||||||
await connection.ExecuteAsync(createTable1, transaction: transaction);
|
foreach (var query in createTableQueries)
|
||||||
await connection.ExecuteAsync(createTable2, transaction: transaction);
|
{
|
||||||
|
await connection.ExecuteAsync(query, transaction: transaction);
|
||||||
|
}
|
||||||
|
|
||||||
await transaction.CommitAsync();
|
await transaction.CommitAsync();
|
||||||
}
|
}
|
||||||
@@ -55,25 +72,29 @@ 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)
|
||||||
{
|
{
|
||||||
return (player != null && player.IsValid && !player.IsBot && !player.IsHLTV && player.AuthorizedSteamID != null);
|
if (player is null) return false;
|
||||||
|
|
||||||
|
return (player is not null && player.IsValid && !player.IsBot && !player.IsHLTV
|
||||||
|
&& WeaponPaints.weaponSync != null && player.Connected == PlayerConnectedState.PlayerConnected);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void LoadSkinsFromFile(string filePath)
|
internal static void LoadSkinsFromFile(string filePath)
|
||||||
{
|
{
|
||||||
if (File.Exists(filePath))
|
try
|
||||||
{
|
{
|
||||||
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>();
|
||||||
}
|
}
|
||||||
else
|
catch (FileNotFoundException)
|
||||||
{
|
{
|
||||||
throw new FileNotFoundException("File not found.", filePath);
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,11 +135,11 @@ namespace WeaponPaints
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
HttpResponseMessage response = await client.GetAsync("https://raw.githubusercontent.com/Nereziel/cs2-WeaponPaints/main/VERSION");
|
HttpResponseMessage response = await client.GetAsync("https://raw.githubusercontent.com/Nereziel/cs2-WeaponPaints/main/VERSION").ConfigureAwait(false);
|
||||||
|
|
||||||
if (response.IsSuccessStatusCode)
|
if (response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
string remoteVersion = await response.Content.ReadAsStringAsync();
|
string remoteVersion = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||||
remoteVersion = remoteVersion.Trim();
|
remoteVersion = remoteVersion.Trim();
|
||||||
|
|
||||||
int comparisonResult = string.Compare(version, remoteVersion);
|
int comparisonResult = string.Compare(version, remoteVersion);
|
||||||
@@ -141,9 +162,13 @@ 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)
|
||||||
{
|
{
|
||||||
Console.WriteLine(ex);
|
logger.LogError(ex, "An error occurred while checking version.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -163,6 +188,7 @@ namespace WeaponPaints
|
|||||||
Console.WriteLine(" ");
|
Console.WriteLine(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*(
|
||||||
internal static void TestDatabaseConnection()
|
internal static void TestDatabaseConnection()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -181,5 +207,6 @@ namespace WeaponPaints
|
|||||||
}
|
}
|
||||||
CheckDatabaseTables();
|
CheckDatabaseTables();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
333
WeaponAction.cs
@@ -3,6 +3,7 @@ using CounterStrikeSharp.API.Core;
|
|||||||
using CounterStrikeSharp.API.Modules.Memory;
|
using CounterStrikeSharp.API.Modules.Memory;
|
||||||
using CounterStrikeSharp.API.Modules.Utils;
|
using CounterStrikeSharp.API.Modules.Utils;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace WeaponPaints
|
namespace WeaponPaints
|
||||||
{
|
{
|
||||||
@@ -10,7 +11,7 @@ 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 == null || weapon == null || !weapon.IsValid || !Utility.IsPlayerValid(player)) return;
|
if (player is null || weapon is null || !weapon.IsValid || !Utility.IsPlayerValid(player)) return;
|
||||||
|
|
||||||
int playerIndex = (int)player.Index;
|
int playerIndex = (int)player.Index;
|
||||||
|
|
||||||
@@ -38,7 +39,20 @@ namespace WeaponPaints
|
|||||||
if (!isKnife && weapon.CBodyComponent != null && weapon.CBodyComponent.SceneNode != null)
|
if (!isKnife && weapon.CBodyComponent != null && weapon.CBodyComponent.SceneNode != null)
|
||||||
{
|
{
|
||||||
var skeleton = GetSkeletonInstance(weapon.CBodyComponent.SceneNode);
|
var skeleton = GetSkeletonInstance(weapon.CBodyComponent.SceneNode);
|
||||||
skeleton.ModelState.MeshGroupMask = 2;
|
|
||||||
|
int[] array = { 1171, 1170, 1169, 1164, 1162, 1161, 1159, 1175, 1174, 1167, 1165, 1168, 1163, 1160, 1166, 1173 };
|
||||||
|
int fallbackPaintKit = weapon.FallbackPaintKit;
|
||||||
|
if (array.Contains(fallbackPaintKit))
|
||||||
|
{
|
||||||
|
skeleton.ModelState.MeshGroupMask = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (skeleton.ModelState.MeshGroupMask != 2)
|
||||||
|
{
|
||||||
|
skeleton.ModelState.MeshGroupMask = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -52,35 +66,55 @@ namespace WeaponPaints
|
|||||||
weapon.FallbackPaintKit = weaponInfo.Paint;
|
weapon.FallbackPaintKit = weaponInfo.Paint;
|
||||||
weapon.FallbackSeed = weaponInfo.Seed;
|
weapon.FallbackSeed = weaponInfo.Seed;
|
||||||
weapon.FallbackWear = weaponInfo.Wear;
|
weapon.FallbackWear = weaponInfo.Wear;
|
||||||
|
|
||||||
if (!isKnife && weapon.CBodyComponent != null && weapon.CBodyComponent.SceneNode != null)
|
if (!isKnife && weapon.CBodyComponent != null && weapon.CBodyComponent.SceneNode != null)
|
||||||
{
|
{
|
||||||
var skeleton = GetSkeletonInstance(weapon.CBodyComponent.SceneNode);
|
var skeleton = GetSkeletonInstance(weapon.CBodyComponent.SceneNode);
|
||||||
skeleton.ModelState.MeshGroupMask = 2;
|
int[] array = { 1171, 1170, 1169, 1164, 1162, 1161, 1159, 1175, 1174, 1167, 1165, 1168, 1163, 1160, 1166, 1173 };
|
||||||
|
int fallbackPaintKit = weapon.FallbackPaintKit;
|
||||||
|
if (array.Contains(fallbackPaintKit))
|
||||||
|
{
|
||||||
|
skeleton.ModelState.MeshGroupMask = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (skeleton.ModelState.MeshGroupMask != 2)
|
||||||
|
{
|
||||||
|
skeleton.ModelState.MeshGroupMask = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void GiveKnifeToPlayer(CCSPlayerController? player)
|
internal static void GiveKnifeToPlayer(CCSPlayerController? player)
|
||||||
{
|
{
|
||||||
if (!_config.Additional.KnifeEnabled || player == null || !player.IsValid) return;
|
if (!_config.Additional.KnifeEnabled || player == null || !player.IsValid) return;
|
||||||
|
|
||||||
|
string knifeToGive;
|
||||||
if (g_playersKnife.TryGetValue((int)player.Index, out var knife))
|
if (g_playersKnife.TryGetValue((int)player.Index, out var knife))
|
||||||
{
|
{
|
||||||
player.GiveNamedItem(knife);
|
knifeToGive = knife;
|
||||||
}
|
}
|
||||||
else if (_config.Additional.GiveRandomKnife)
|
else if (_config.Additional.GiveRandomKnife)
|
||||||
{
|
{
|
||||||
var knifeTypes = weaponList.Where(pair => pair.Key.StartsWith("weapon_knife") || pair.Key.StartsWith("weapon_bayonet")).ToDictionary(pair => pair.Key, pair => pair.Value);
|
var knifeTypes = weaponList.Where(pair => pair.Key.StartsWith("weapon_knife") || pair.Key.StartsWith("weapon_bayonet")).ToList();
|
||||||
|
|
||||||
|
if (knifeTypes.Count == 0)
|
||||||
|
{
|
||||||
|
Utility.Log("No valid knife types found.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Random random = new();
|
Random random = new();
|
||||||
int index = random.Next(knifeTypes.Count);
|
int index = random.Next(knifeTypes.Count);
|
||||||
var randomKnifeClass = knifeTypes.Keys.ElementAt(index);
|
knifeToGive = knifeTypes[index].Key;
|
||||||
|
|
||||||
player.GiveNamedItem(randomKnifeClass);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var defaultKnife = (CsTeam)player.TeamNum == CsTeam.Terrorist ? "weapon_knife_t" : "weapon_knife";
|
knifeToGive = (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)
|
||||||
@@ -110,8 +144,10 @@ namespace WeaponPaints
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
internal void RefreshPlayerKnife(CCSPlayerController? player)
|
internal void RefreshPlayerKnife(CCSPlayerController? player)
|
||||||
{
|
{
|
||||||
|
return;
|
||||||
if (player == null || !player.IsValid || player.PlayerPawn.Value == null || !player.PawnIsAlive) return;
|
if (player == null || !player.IsValid || player.PlayerPawn.Value == null || !player.PawnIsAlive) 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;
|
||||||
|
|
||||||
@@ -167,144 +203,193 @@ namespace WeaponPaints
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
internal void RefreshSkins(CCSPlayerController? player)
|
internal void RefreshSkins(CCSPlayerController? player)
|
||||||
{
|
{
|
||||||
|
return;
|
||||||
if (!Utility.IsPlayerValid(player) || !player!.PawnIsAlive) return;
|
if (!Utility.IsPlayerValid(player) || !player!.PawnIsAlive) return;
|
||||||
|
|
||||||
AddTimer(0.18f, () => NativeAPI.IssueClientCommand((int)player.Index - 1, "slot3"));
|
AddTimer(0.18f, () => NativeAPI.IssueClientCommand((int)player.Index - 1, "slot3"));
|
||||||
AddTimer(0.25f, () => NativeAPI.IssueClientCommand((int)player.Index - 1, "slot2"));
|
AddTimer(0.25f, () => NativeAPI.IssueClientCommand((int)player.Index - 1, "slot2"));
|
||||||
AddTimer(0.38f, () => NativeAPI.IssueClientCommand((int)player.Index - 1, "slot1"));
|
AddTimer(0.38f, () => NativeAPI.IssueClientCommand((int)player.Index - 1, "slot1"));
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
internal void RefreshWeapons(CCSPlayerController? player)
|
internal void RefreshWeapons(CCSPlayerController? player)
|
||||||
{
|
{
|
||||||
if (player == null || !player.IsValid || player.PlayerPawn.Value == null || !player.PawnIsAlive) return;
|
if (player == null || !player.IsValid || player.PlayerPawn?.Value == null || (LifeState_t)player.LifeState != LifeState_t.LIFE_ALIVE)
|
||||||
if (player.PlayerPawn.Value.WeaponServices == null || player.PlayerPawn.Value.ItemServices == null) return;
|
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;
|
||||||
|
|
||||||
|
// Dictionary to store weapons and their ammo
|
||||||
|
|
||||||
|
|
||||||
|
if (weapons != null && weapons.Count > 0)
|
||||||
|
{
|
||||||
|
//Dictionary<string, (int, int)> weaponsWithAmmo = new Dictionary<string, (int, int)>();
|
||||||
|
Dictionary<string, List<(int, int)>> weaponsWithAmmo = new Dictionary<string, List<(int, int)>>();
|
||||||
|
bool bomb = false;
|
||||||
|
bool defuser = player.PawnHasDefuser;
|
||||||
|
bool healthshot = false;
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string? weaponByDefindex = null;
|
||||||
|
|
||||||
|
CCSWeaponBaseVData? weaponData = weapon.Value.As<CCSWeaponBase>().VData;
|
||||||
|
|
||||||
|
if (weaponData != null)
|
||||||
|
{
|
||||||
|
if (weaponData.GearSlot == gear_slot_t.GEAR_SLOT_C4)
|
||||||
|
bomb = true;
|
||||||
|
|
||||||
|
if (weaponData.Name.Equals("weapon_healtshot"))
|
||||||
|
healthshot = true;
|
||||||
|
|
||||||
|
if (weaponData.GearSlot == gear_slot_t.GEAR_SLOT_GRENADES || weaponData.GearSlot == gear_slot_t.GEAR_SLOT_UTILITY || weaponData.GearSlot == gear_slot_t.GEAR_SLOT_BOOSTS)
|
||||||
|
{
|
||||||
|
int clip1 = weapon.Value.Clip1;
|
||||||
|
int reservedAmmo = weapon.Value.ReserveAmmo[0];
|
||||||
|
|
||||||
|
weaponsWithAmmo.Add(weapon.Value.DesignerName, new List<(int, int)>() { (clip1, reservedAmmo) });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!weapon.Value.DesignerName.Contains("knife") && weaponDefindex.TryGetValue(weapon.Value.AttributeManager.Item.ItemDefinitionIndex, out weaponByDefindex) && weaponByDefindex != null)
|
||||||
|
{
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.LogWarning(ex.Message);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
player.RemoveWeapons();
|
||||||
|
AddTimer(0.2f, () =>
|
||||||
|
{
|
||||||
|
if (bomb)
|
||||||
|
player.GiveNamedItem("weapon_c4");
|
||||||
|
|
||||||
|
if (defuser)
|
||||||
|
{
|
||||||
|
var itemServ = player.PlayerPawn?.Value?.ItemServices;
|
||||||
|
if (itemServ != null)
|
||||||
|
{
|
||||||
|
var items = new CCSPlayer_ItemServices(itemServ.Handle);
|
||||||
|
items.HasDefuser = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (healthshot)
|
||||||
|
player.GiveNamedItem("weapon_healtshot");
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void RefreshKnife(CCSPlayerController? player, bool force = false)
|
||||||
|
{
|
||||||
|
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);
|
|
||||||
|
|
||||||
foreach (var weapon in weapons)
|
foreach (var weapon in weapons)
|
||||||
{
|
{
|
||||||
if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid)
|
if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid && weapon.Index > 0)
|
||||||
{
|
{
|
||||||
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
|
||||||
{
|
{
|
||||||
if (weapon.Value.DesignerName.Contains("knife") || weapon.Value.DesignerName.Contains("bayonet"))
|
CCSWeaponBaseVData? weaponData = weapon.Value.As<CCSWeaponBase>().VData;
|
||||||
|
|
||||||
|
if (weapon.Value.DesignerName.Contains("knife") || weaponData?.GearSlot == gear_slot_t.GEAR_SLOT_KNIFE)
|
||||||
{
|
{
|
||||||
weapon.Value.Remove();
|
player.RemoveItemByDesignerName(weapon.Value.DesignerName, weapon.Value.Entity?.EntityInstance.IsValid ?? false);
|
||||||
GiveKnifeToPlayer(player);
|
AddTimer(0.2f, () => GiveKnifeToPlayer(player));
|
||||||
}
|
break;
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!weaponDefindex.ContainsKey(weapon.Value.AttributeManager.Item.ItemDefinitionIndex)) continue;
|
|
||||||
int clip1, reservedAmmo;
|
|
||||||
|
|
||||||
clip1 = weapon.Value.Clip1;
|
|
||||||
reservedAmmo = weapon.Value.ReserveAmmo[0];
|
|
||||||
|
|
||||||
weapon.Value.Remove();
|
|
||||||
string weaponByDefindex = weaponDefindex[weapon.Value.AttributeManager.Item.ItemDefinitionIndex];
|
|
||||||
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("Refreshing weapons exception");
|
Logger.LogWarning($"Cannot remove knife: {ex.Message}");
|
||||||
Console.WriteLine("[WeaponPaints] Refreshing weapons exception");
|
|
||||||
Console.WriteLine(ex.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (Config.Additional.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 int GetRandomPaint(int defindex)
|
private static int GetRandomPaint(int defindex)
|
||||||
{
|
{
|
||||||
|
if (skinsList == null || skinsList.Count == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (skinsList != null)
|
Random rnd = new Random();
|
||||||
{
|
|
||||||
Random rnd = new Random();
|
// Filter weapons by the provided defindex
|
||||||
// Filter weapons by the provided defindex
|
var filteredWeapons = skinsList.Where(w => w["weapon_defindex"]?.ToString() == defindex.ToString()).ToList();
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,5 +398,27 @@ namespace WeaponPaints
|
|||||||
Func<nint, nint> GetSkeletonInstance = VirtualFunction.Create<nint, nint>(node.Handle, 8);
|
Func<nint, nint> GetSkeletonInstance = VirtualFunction.Create<nint, nint>(node.Handle, 8);
|
||||||
return new CSkeletonInstance(GetSkeletonInstance(node.Handle));
|
return new CSkeletonInstance(GetSkeletonInstance(node.Handle));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static unsafe CHandle<CBaseViewModel>[]? GetPlayerViewModels(CCSPlayerController player)
|
||||||
|
{
|
||||||
|
if (player.PlayerPawn.Value == null || player.PlayerPawn.Value.ViewModelServices == null) return null;
|
||||||
|
CCSPlayer_ViewModelServices viewModelServices = new CCSPlayer_ViewModelServices(player.PlayerPawn.Value.ViewModelServices!.Handle);
|
||||||
|
return GetFixedArray<CHandle<CBaseViewModel>>(viewModelServices.Handle, "CCSPlayer_ViewModelServices", "m_hViewModel", 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static unsafe T[] GetFixedArray<T>(nint pointer, string @class, string member, int length) where T : CHandle<CBaseViewModel>
|
||||||
|
{
|
||||||
|
nint ptr = pointer + Schema.GetSchemaOffset(@class, member);
|
||||||
|
Span<nint> references = MemoryMarshal.CreateSpan<nint>(ref ptr, length);
|
||||||
|
T[] values = new T[length];
|
||||||
|
|
||||||
|
for (int i = 0; i < length; i++)
|
||||||
|
{
|
||||||
|
values[i] = (T)Activator.CreateInstance(typeof(T), references[i])!;
|
||||||
|
}
|
||||||
|
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,13 +2,15 @@ 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.Cvars;
|
using CounterStrikeSharp.API.Modules.Cvars;
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Microsoft.Extensions.Localization;
|
using Microsoft.Extensions.Localization;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using MySqlConnector;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
|
||||||
namespace WeaponPaints;
|
namespace WeaponPaints;
|
||||||
|
|
||||||
[MinimumApiVersion(121)]
|
[MinimumApiVersion(163)]
|
||||||
public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
||||||
{
|
{
|
||||||
internal static readonly Dictionary<string, string> weaponList = new()
|
internal static readonly Dictionary<string, string> weaponList = new()
|
||||||
@@ -35,6 +37,7 @@ 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"},
|
||||||
@@ -66,24 +69,25 @@ 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" }
|
||||||
};
|
};
|
||||||
|
|
||||||
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 Dictionary<int, string> g_playersKnife = new();
|
internal static ConcurrentDictionary<int, string> g_playersKnife = new ConcurrentDictionary<int, string>();
|
||||||
internal static Dictionary<int, Dictionary<int, WeaponInfo>> gPlayerWeaponsInfo = new Dictionary<int, Dictionary<int, WeaponInfo>>();
|
internal static ConcurrentDictionary<int, ConcurrentDictionary<int, WeaponInfo>> gPlayerWeaponsInfo = new ConcurrentDictionary<int, ConcurrentDictionary<int, WeaponInfo>>();
|
||||||
internal static List<JObject> skinsList = new List<JObject>();
|
internal static List<JObject> skinsList = new List<JObject>();
|
||||||
internal static WeaponSynchronization? weaponSync;
|
internal static WeaponSynchronization? weaponSync;
|
||||||
//internal static List<int> g_changedKnife = new();
|
|
||||||
internal bool g_bCommandsAllowed = true;
|
internal bool g_bCommandsAllowed = true;
|
||||||
|
|
||||||
internal Uri GlobalShareApi = new("https://weaponpaints.fun/api.php");
|
internal Uri GlobalShareApi = new("https://weaponpaints.fun/api.php");
|
||||||
internal int GlobalShareServerId = 0;
|
internal int GlobalShareServerId = 0;
|
||||||
private DateTime[] commandCooldown = new DateTime[Server.MaxPlayers];
|
internal static Dictionary<int, DateTime> commandsCooldown = new Dictionary<int, DateTime>();
|
||||||
private string DatabaseConnectionString = string.Empty;
|
internal static Database? _database;
|
||||||
private CounterStrikeSharp.API.Modules.Timers.Timer? g_hTimerCheckSkinsData = null;
|
|
||||||
|
//private CounterStrikeSharp.API.Modules.Timers.Timer? g_hTimerCheckSkinsData = null;
|
||||||
public static Dictionary<int, string> weaponDefindex { get; } = new Dictionary<int, string>
|
public static Dictionary<int, string> weaponDefindex { get; } = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
{ 1, "weapon_deagle" },
|
{ 1, "weapon_deagle" },
|
||||||
@@ -108,6 +112,7 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
|||||||
{ 28, "weapon_negev" },
|
{ 28, "weapon_negev" },
|
||||||
{ 29, "weapon_sawedoff" },
|
{ 29, "weapon_sawedoff" },
|
||||||
{ 30, "weapon_tec9" },
|
{ 30, "weapon_tec9" },
|
||||||
|
{ 31, "weapon_taser" },
|
||||||
{ 32, "weapon_hkp2000" },
|
{ 32, "weapon_hkp2000" },
|
||||||
{ 33, "weapon_mp7" },
|
{ 33, "weapon_mp7" },
|
||||||
{ 34, "weapon_mp9" },
|
{ 34, "weapon_mp9" },
|
||||||
@@ -138,14 +143,15 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
|||||||
{ 521, "weapon_knife_outdoor" },
|
{ 521, "weapon_knife_outdoor" },
|
||||||
{ 522, "weapon_knife_stiletto" },
|
{ 522, "weapon_knife_stiletto" },
|
||||||
{ 523, "weapon_knife_widowmaker" },
|
{ 523, "weapon_knife_widowmaker" },
|
||||||
{ 525, "weapon_knife_skeleton" }
|
{ 525, "weapon_knife_skeleton" },
|
||||||
|
{ 526, "weapon_knife_kukri" }
|
||||||
};
|
};
|
||||||
|
|
||||||
public WeaponPaintsConfig Config { get; set; } = new();
|
public WeaponPaintsConfig Config { get; set; } = new();
|
||||||
public override string ModuleAuthor => "Nereziel & daffyy";
|
public override string ModuleAuthor => "Nereziel & daffyy";
|
||||||
public override string ModuleDescription => "Skin 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.3g";
|
public override string ModuleVersion => "1.6b";
|
||||||
|
|
||||||
public static WeaponPaintsConfig GetWeaponPaintsConfig()
|
public static WeaponPaintsConfig GetWeaponPaintsConfig()
|
||||||
{
|
{
|
||||||
@@ -154,45 +160,34 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
|||||||
|
|
||||||
public override void Load(bool hotReload)
|
public override void Load(bool hotReload)
|
||||||
{
|
{
|
||||||
if (!Config.GlobalShare)
|
if (hotReload && weaponSync != null)
|
||||||
{
|
|
||||||
DatabaseConnectionString = Utility.BuildDatabaseConnectionString();
|
|
||||||
Utility.TestDatabaseConnection();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hotReload)
|
|
||||||
{
|
{
|
||||||
OnMapStart(string.Empty);
|
OnMapStart(string.Empty);
|
||||||
|
|
||||||
List<CCSPlayerController> players = Utilities.GetPlayers();
|
foreach (var player in Utilities.GetPlayers())
|
||||||
|
|
||||||
foreach (CCSPlayerController player in players)
|
|
||||||
{
|
{
|
||||||
if (player == null || !player.IsValid || player.IsBot || player.IsHLTV || player.AuthorizedSteamID == null) continue;
|
if (weaponSync == null || player is null || !player.IsValid || !player.PawnIsAlive || player.IsBot || player.IsHLTV || player.Connected != PlayerConnectedState.PlayerConnected)
|
||||||
if (gPlayerWeaponsInfo.ContainsKey((int)player.Index)) continue;
|
continue;
|
||||||
|
|
||||||
|
g_knifePickupCount[(int)player.Index] = 0;
|
||||||
|
gPlayerWeaponsInfo.TryRemove((int)player.Index, out _);
|
||||||
|
g_playersKnife.TryRemove((int)player.Index, out _);
|
||||||
|
|
||||||
PlayerInfo playerInfo = new PlayerInfo
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
{
|
{
|
||||||
UserId = player.UserId,
|
UserId = player.UserId,
|
||||||
Index = (int)player.Index,
|
Index = (int)player.Index,
|
||||||
SteamId = player?.AuthorizedSteamID?.SteamId64.ToString(),
|
SteamId = player?.SteamID.ToString(),
|
||||||
Name = player?.PlayerName,
|
Name = player?.PlayerName,
|
||||||
IpAddress = player?.IpAddress?.Split(":")[0]
|
IpAddress = player?.IpAddress?.Split(":")[0]
|
||||||
};
|
};
|
||||||
|
|
||||||
if (Config.Additional.SkinEnabled && weaponSync != null)
|
if (Config.Additional.SkinEnabled)
|
||||||
_ = weaponSync.GetWeaponPaintsFromDatabase(playerInfo);
|
_ = weaponSync.GetWeaponPaintsFromDatabase(playerInfo);
|
||||||
if (Config.Additional.KnifeEnabled && weaponSync != null)
|
if (Config.Additional.KnifeEnabled)
|
||||||
_ = weaponSync.GetKnifeFromDatabase(playerInfo);
|
_ = weaponSync.GetKnifeFromDatabase(playerInfo);
|
||||||
|
|
||||||
g_knifePickupCount[(int)player!.Index] = 0;
|
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
RegisterListeners();
|
|
||||||
RegisterCommands();
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.Additional.KnifeEnabled)
|
if (Config.Additional.KnifeEnabled)
|
||||||
SetupKnifeMenu();
|
SetupKnifeMenu();
|
||||||
if (Config.Additional.SkinEnabled)
|
if (Config.Additional.SkinEnabled)
|
||||||
@@ -213,6 +208,25 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
|||||||
Logger.LogError("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!");
|
throw new Exception("[WeaponPaints] You need to setup Database credentials in config!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
DatabaseConnectionString = Utility.BuildDatabaseConnectionString();
|
||||||
|
Utility.TestDatabaseConnection();
|
||||||
|
*/
|
||||||
|
|
||||||
|
var builder = new MySqlConnectionStringBuilder
|
||||||
|
{
|
||||||
|
Server = config.DatabaseHost,
|
||||||
|
UserID = config.DatabaseUser,
|
||||||
|
Password = config.DatabasePassword,
|
||||||
|
Database = config.DatabaseName,
|
||||||
|
Port = (uint)config.DatabasePort,
|
||||||
|
Pooling = true
|
||||||
|
};
|
||||||
|
|
||||||
|
_database = new(builder.ConnectionString);
|
||||||
|
|
||||||
|
_ = Utility.CheckDatabaseTables();
|
||||||
}
|
}
|
||||||
|
|
||||||
Config = config;
|
Config = config;
|
||||||
@@ -253,7 +267,7 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
|||||||
Task<string> responseBodyTask = response.Content.ReadAsStringAsync();
|
Task<string> responseBodyTask = response.Content.ReadAsStringAsync();
|
||||||
responseBodyTask.Wait();
|
responseBodyTask.Wait();
|
||||||
string responseBody = responseBodyTask.Result;
|
string responseBody = responseBodyTask.Result;
|
||||||
GlobalShareServerId = Int32.Parse(responseBody);
|
GlobalShareServerId = int.Parse(responseBody);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,9 +9,9 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.121" />
|
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.163" />
|
||||||
<PackageReference Include="Dapper" Version="2.1.24" />
|
<PackageReference Include="Dapper" Version="2.1.28" />
|
||||||
<PackageReference Include="MySqlConnector" Version="2.3.1" />
|
<PackageReference Include="MySqlConnector" Version="2.3.5" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
using Dapper;
|
using Dapper;
|
||||||
using MySqlConnector;
|
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
|
||||||
namespace WeaponPaints
|
namespace WeaponPaints
|
||||||
{
|
{
|
||||||
internal class WeaponSynchronization
|
internal class WeaponSynchronization
|
||||||
{
|
{
|
||||||
private readonly WeaponPaintsConfig _config;
|
private readonly WeaponPaintsConfig _config;
|
||||||
private readonly string _databaseConnectionString;
|
private readonly Database _database;
|
||||||
private readonly Uri _globalShareApi;
|
private readonly Uri _globalShareApi;
|
||||||
private readonly int _globalShareServerId;
|
private readonly int _globalShareServerId;
|
||||||
|
|
||||||
internal WeaponSynchronization(string databaseConnectionString, WeaponPaintsConfig config, Uri globalShareApi, int globalShareServerId)
|
internal WeaponSynchronization(Database database, WeaponPaintsConfig config, Uri globalShareApi, int globalShareServerId)
|
||||||
{
|
{
|
||||||
_databaseConnectionString = databaseConnectionString;
|
_database = database;
|
||||||
_config = config;
|
_config = config;
|
||||||
_globalShareApi = globalShareApi;
|
_globalShareApi = globalShareApi;
|
||||||
_globalShareServerId = globalShareServerId;
|
_globalShareServerId = globalShareServerId;
|
||||||
@@ -63,21 +63,15 @@ namespace WeaponPaints
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var connection = new MySqlConnection(_databaseConnectionString))
|
await using (var connection = await _database.GetConnectionAsync())
|
||||||
{
|
{
|
||||||
await connection.OpenAsync();
|
|
||||||
string query = "SELECT `knife` FROM `wp_player_knife` WHERE `steamid` = @steamid";
|
string query = "SELECT `knife` FROM `wp_player_knife` WHERE `steamid` = @steamid";
|
||||||
string? PlayerKnife = await connection.QueryFirstOrDefaultAsync<string>(query, new { steamid = player.SteamId });
|
string? playerKnife = await connection.QueryFirstOrDefaultAsync<string>(query, new { steamid = player.SteamId });
|
||||||
|
|
||||||
if (PlayerKnife != null)
|
if (playerKnife != null)
|
||||||
{
|
{
|
||||||
WeaponPaints.g_playersKnife[player.Index] = PlayerKnife;
|
WeaponPaints.g_playersKnife[player.Index] = playerKnife;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await connection.CloseAsync();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -94,7 +88,7 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
if (!WeaponPaints.gPlayerWeaponsInfo.TryGetValue(player.Index, out _))
|
if (!WeaponPaints.gPlayerWeaponsInfo.TryGetValue(player.Index, out _))
|
||||||
{
|
{
|
||||||
WeaponPaints.gPlayerWeaponsInfo[player.Index] = new Dictionary<int, WeaponInfo>();
|
WeaponPaints.gPlayerWeaponsInfo[player.Index] = new ConcurrentDictionary<int, WeaponInfo>();
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -149,36 +143,26 @@ namespace WeaponPaints
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var connection = new MySqlConnection(_databaseConnectionString))
|
await using (var connection = await _database.GetConnectionAsync())
|
||||||
{
|
{
|
||||||
await connection.OpenAsync();
|
|
||||||
|
|
||||||
string query = "SELECT * FROM `wp_player_skins` WHERE `steamid` = @steamid";
|
string query = "SELECT * FROM `wp_player_skins` WHERE `steamid` = @steamid";
|
||||||
IEnumerable<dynamic> PlayerSkins = await connection.QueryAsync<dynamic>(query, new { steamid = player.SteamId });
|
var playerSkins = await connection.QueryAsync(query, new { steamid = player.SteamId });
|
||||||
|
|
||||||
if (PlayerSkins != null && PlayerSkins.AsList().Count > 0)
|
foreach (var row in playerSkins)
|
||||||
{
|
{
|
||||||
PlayerSkins.ToList().ForEach(row =>
|
int weaponDefIndex = row.weapon_defindex ?? default;
|
||||||
|
int weaponPaintId = row.weapon_paint_id ?? default;
|
||||||
|
float weaponWear = row.weapon_wear ?? default;
|
||||||
|
int weaponSeed = row.weapon_seed ?? default;
|
||||||
|
|
||||||
|
WeaponInfo weaponInfo = new WeaponInfo
|
||||||
{
|
{
|
||||||
int weaponDefIndex = row.weapon_defindex ?? default(int);
|
Paint = weaponPaintId,
|
||||||
int weaponPaintId = row.weapon_paint_id ?? default(int);
|
Seed = weaponSeed,
|
||||||
float weaponWear = row.weapon_wear ?? default(float);
|
Wear = weaponWear
|
||||||
int weaponSeed = row.weapon_seed ?? default(int);
|
};
|
||||||
|
WeaponPaints.gPlayerWeaponsInfo[player.Index][weaponDefIndex] = weaponInfo;
|
||||||
WeaponInfo weaponInfo = new WeaponInfo
|
|
||||||
{
|
|
||||||
Paint = weaponPaintId,
|
|
||||||
Seed = weaponSeed,
|
|
||||||
Wear = weaponWear
|
|
||||||
};
|
|
||||||
WeaponPaints.gPlayerWeaponsInfo[player.Index][weaponDefIndex] = weaponInfo;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await connection.CloseAsync();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -191,28 +175,25 @@ namespace WeaponPaints
|
|||||||
internal async Task SyncKnifeToDatabase(PlayerInfo player, string knife)
|
internal async Task SyncKnifeToDatabase(PlayerInfo player, string knife)
|
||||||
{
|
{
|
||||||
if (!_config.Additional.KnifeEnabled) return;
|
if (!_config.Additional.KnifeEnabled) return;
|
||||||
|
if (player.SteamId == null || player.Index == 0) return;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (player.SteamId == null || player.Index == 0) return;
|
await using var connection = await _database.GetConnectionAsync();
|
||||||
|
|
||||||
using var connection = new MySqlConnection(_databaseConnectionString);
|
|
||||||
await connection.OpenAsync();
|
|
||||||
string query = "INSERT INTO `wp_player_knife` (`steamid`, `knife`) VALUES(@steamid, @newKnife) ON DUPLICATE KEY UPDATE `knife` = @newKnife";
|
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 });
|
await connection.ExecuteAsync(query, new { steamid = player.SteamId, newKnife = knife });
|
||||||
await connection.CloseAsync();
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Utility.Log(e.Message);
|
Utility.Log(e.Message);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task SyncWeaponPaintsToDatabase(PlayerInfo player)
|
internal async Task SyncWeaponPaintsToDatabase(PlayerInfo player)
|
||||||
{
|
{
|
||||||
if (player == null || player.Index <= 0 || player.SteamId == null) return;
|
if (player == null || player.Index <= 0 || player.SteamId == null) return;
|
||||||
|
|
||||||
using var connection = new MySqlConnection(_databaseConnectionString);
|
await using var connection = await _database.GetConnectionAsync();
|
||||||
await connection.OpenAsync();
|
|
||||||
|
|
||||||
if (!WeaponPaints.gPlayerWeaponsInfo.ContainsKey(player.Index))
|
if (!WeaponPaints.gPlayerWeaponsInfo.ContainsKey(player.Index))
|
||||||
return;
|
return;
|
||||||
@@ -226,23 +207,15 @@ namespace WeaponPaints
|
|||||||
float wear = weaponInfo.Wear;
|
float wear = weaponInfo.Wear;
|
||||||
int seed = weaponInfo.Seed;
|
int seed = weaponInfo.Seed;
|
||||||
|
|
||||||
string updateSql = "UPDATE `wp_player_skins` SET `weapon_paint_id` = @paintId, " +
|
string updateSql = "INSERT INTO `wp_player_skins` (`steamid`, `weapon_defindex`, " +
|
||||||
"`weapon_wear` = @wear, `weapon_seed` = @seed WHERE `steamid` = @steamid " +
|
"`weapon_paint_id`, `weapon_wear`, `weapon_seed`) " +
|
||||||
"AND `weapon_defindex` = @weaponDefIndex";
|
"VALUES (@steamid, @weaponDefIndex, @paintId, @wear, @seed) " +
|
||||||
|
"ON DUPLICATE KEY UPDATE `weapon_paint_id` = @paintId, " +
|
||||||
|
"`weapon_wear` = @wear, `weapon_seed` = @seed";
|
||||||
|
|
||||||
var updateParams = new { paintId, wear, seed, steamid = player.SteamId, weaponDefIndex };
|
var updateParams = new { steamid = player.SteamId, weaponDefIndex, paintId, wear, seed };
|
||||||
int rowsAffected = await connection.ExecuteAsync(updateSql, updateParams);
|
await connection.ExecuteAsync(updateSql, updateParams);
|
||||||
|
|
||||||
if (rowsAffected == 0)
|
|
||||||
{
|
|
||||||
string insertSql = "INSERT INTO `wp_player_skins` (`steamid`, `weapon_defindex`, " +
|
|
||||||
"`weapon_paint_id`, `weapon_wear`, `weapon_seed`) " +
|
|
||||||
"VALUES (@steamid, @weaponDefIndex, @paintId, @wear, @seed)";
|
|
||||||
|
|
||||||
await connection.ExecuteAsync(insertSql, updateParams);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
await connection.CloseAsync();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
14
lang/ua.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"wp_prefix": "{lightblue}[WeaponPaints] {default}",
|
||||||
|
"wp_info_website": "Відвідайте веб-сайт {lime}{0},{default} щоб вибрати скин",
|
||||||
|
"wp_info_refresh": "Напишіть у чат {lime}!wp{default} для синхронізації вибраних скинів",
|
||||||
|
"wp_info_knife": "Напишіть у чат {lime}!knife,{default} щоб вибрати ніж",
|
||||||
|
"wp_command_cooldown": "{lightred}Ви не можете вибрати зброю зараз",
|
||||||
|
"wp_command_refresh_done": "{lime}Оновлення скинів для зброї",
|
||||||
|
"wp_knife_menu_select": "Ви вибрали скин {lime}{0}{default} для ножа",
|
||||||
|
"wp_knife_menu_kill": "Щоб правильно застосувати скин для ножа, напишіть у чат {lime}!kill{default}",
|
||||||
|
"wp_knife_menu_title": "Меню ножів",
|
||||||
|
"wp_skin_menu_weapon_title": "Меню зброї",
|
||||||
|
"wp_skin_menu_skin_title": "Виберіть скин для {lime}{0}{default}",
|
||||||
|
"wp_skin_menu_select": "Ви вибрали скин {lime}{0}{default} для зброї"
|
||||||
|
}
|
||||||
14
lang/zh-cn.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"wp_prefix": "{lightblue}[武器皮肤] {default}",
|
||||||
|
"wp_info_website": "在线访问 {lime}{0}{default} 更改你的武器皮肤",
|
||||||
|
"wp_info_refresh": "输入 {lime}!wp{default} 进行在线皮肤同步",
|
||||||
|
"wp_info_knife": "输入 {lime}!knife{default} 打开刀菜单",
|
||||||
|
"wp_command_cooldown": "{lightred}皮肤同步刷新冷却中",
|
||||||
|
"wp_command_refresh_done": "{lime}刷新武器皮肤中",
|
||||||
|
"wp_knife_menu_select": "你选择了 {lime}{0}{default} 作为你的刀",
|
||||||
|
"wp_knife_menu_kill": "如需完全应用皮肤到刀上, 你需要输入 {lime}!kill{default} 自杀来进行刷新",
|
||||||
|
"wp_knife_menu_title": "刀菜单",
|
||||||
|
"wp_skin_menu_weapon_title": "武器菜单",
|
||||||
|
"wp_skin_menu_skin_title": "选择 {lime}{0}{default} 的皮肤",
|
||||||
|
"wp_skin_menu_select": "你选择了 {lime}{0}{default} 作为你的皮肤"
|
||||||
|
}
|
||||||
@@ -5,6 +5,8 @@ define('DB_NAME', '');
|
|||||||
define('DB_USER', '');
|
define('DB_USER', '');
|
||||||
define('DB_PASS', '');
|
define('DB_PASS', '');
|
||||||
|
|
||||||
|
define('WEB_STYLE_DARK', true);
|
||||||
|
|
||||||
define('STEAM_API_KEY', '');
|
define('STEAM_API_KEY', '');
|
||||||
define('STEAM_DOMAIN_NAME', '');
|
define('STEAM_DOMAIN_NAME', '');
|
||||||
define('STEAM_LOGOUT_PAGE', '');
|
define('STEAM_LOGOUT_PAGE', '');
|
||||||
|
|||||||
@@ -4,7 +4,14 @@ class DataBase {
|
|||||||
private $PDO;
|
private $PDO;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->PDO = new PDO("mysql:host=".DB_HOST."; port=".DB_PORT."; dbname=".DB_NAME, DB_USER, DB_PASS, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
|
try {
|
||||||
|
$this->PDO = new PDO("mysql:host=".DB_HOST."; port=".DB_PORT."; dbname=".DB_NAME, DB_USER, DB_PASS, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
|
||||||
|
}
|
||||||
|
catch(PDOException $ex)
|
||||||
|
{
|
||||||
|
echo "<div style='display: flex; flex-direction: column;align-items: center;justify-content: center;text-align: center;'><h2>Problem with database!</h2>";
|
||||||
|
die("<pre style='padding: 10px;text-wrap: balance; border: 2px solid #ed6bd3;background: #252525; color: #ed6bd3; width: 50%;'>" . $ex . "</pre>");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public function select($query, $bindings = []) {
|
public function select($query, $bindings = []) {
|
||||||
$STH = $this->PDO->prepare($query);
|
$STH = $this->PDO->prepare($query);
|
||||||
|
|||||||
@@ -62,7 +62,8 @@ class UtilsClass
|
|||||||
521,
|
521,
|
||||||
522,
|
522,
|
||||||
523,
|
523,
|
||||||
525
|
525,
|
||||||
|
526
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
continue;
|
continue;
|
||||||
@@ -88,7 +89,11 @@ class UtilsClass
|
|||||||
$selected = [];
|
$selected = [];
|
||||||
|
|
||||||
foreach ($temp as $weapon) {
|
foreach ($temp as $weapon) {
|
||||||
$selected[$weapon['weapon_defindex']] = $weapon['weapon_paint_id'];
|
$selected[$weapon['weapon_defindex']] = [
|
||||||
|
'weapon_paint_id' => $weapon['weapon_paint_id'],
|
||||||
|
'weapon_seed' => $weapon['weapon_seed'],
|
||||||
|
'weapon_wear' => $weapon['weapon_wear'],
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $selected;
|
return $selected;
|
||||||
|
|||||||
73
website/getskins.php
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
$weapons = array (
|
||||||
|
"weapon_deagle" => 1,
|
||||||
|
"weapon_elite" => 2,
|
||||||
|
"weapon_fiveseven" => 3,
|
||||||
|
"weapon_glock" => 4,
|
||||||
|
"weapon_ak47" => 7,
|
||||||
|
"weapon_aug" => 8,
|
||||||
|
"weapon_awp" => 9,
|
||||||
|
"weapon_famas" => 10,
|
||||||
|
"weapon_g3sg1" => 10,
|
||||||
|
"weapon_galilar" => 13,
|
||||||
|
"weapon_m249" => 14,
|
||||||
|
"weapon_m4a1" => 16,
|
||||||
|
"weapon_mac10" => 17,
|
||||||
|
"weapon_p90" => 19,
|
||||||
|
"weapon_mp5sd" => 23,
|
||||||
|
"weapon_ump45" => 24,
|
||||||
|
"weapon_xm1014" => 25,
|
||||||
|
"weapon_bizon" => 26,
|
||||||
|
"weapon_mag7" => 27,
|
||||||
|
"weapon_negev" => 28,
|
||||||
|
"weapon_sawedoff" => 29,
|
||||||
|
"weapon_tec9" => 30,
|
||||||
|
"weapon_hkp2000" => 32,
|
||||||
|
"weapon_mp7" => 33,
|
||||||
|
"weapon_mp9" => 34,
|
||||||
|
"weapon_nova" => 35,
|
||||||
|
"weapon_p250" => 36,
|
||||||
|
"weapon_scar20" => 38,
|
||||||
|
"weapon_sg556" => 39,
|
||||||
|
"weapon_ssg08" => 40,
|
||||||
|
"weapon_m4a1_silencer" => 60,
|
||||||
|
"weapon_usp_silencer" => 61,
|
||||||
|
"weapon_cz75a" => 63,
|
||||||
|
"weapon_revolver" => 64,
|
||||||
|
"weapon_bayonet" => 500,
|
||||||
|
"weapon_knife_css" => 503,
|
||||||
|
"weapon_knife_flip" => 505,
|
||||||
|
"weapon_knife_gut" => 506,
|
||||||
|
"weapon_knife_karambit" => 507,
|
||||||
|
"weapon_knife_m9_bayonet" => 508,
|
||||||
|
"weapon_knife_tactical" => 509,
|
||||||
|
"weapon_knife_falchion" => 512,
|
||||||
|
"weapon_knife_survival_bowie"=> 514,
|
||||||
|
"weapon_knife_butterfly" => 515,
|
||||||
|
"weapon_knife_push" => 516,
|
||||||
|
"weapon_knife_cord" => 517,
|
||||||
|
"weapon_knife_canis" => 518,
|
||||||
|
"weapon_knife_ursus" => 519,
|
||||||
|
"weapon_knife_gypsy_jackknife" => 520,
|
||||||
|
"weapon_knife_outdoor" => 521,
|
||||||
|
"weapon_knife_stiletto" => 522,
|
||||||
|
"weapon_knife_widowmaker" => 523,
|
||||||
|
"weapon_knife_skeleton" => 525);
|
||||||
|
$json = json_decode(file_get_contents('skins.json'));
|
||||||
|
echo "<pre>";
|
||||||
|
foreach($json as $skin)
|
||||||
|
{
|
||||||
|
if(!str_contains($skin->weapon->id, "weapon_")) continue;
|
||||||
|
$name = $skin->name;
|
||||||
|
$name = str_replace("'","\'",$name);
|
||||||
|
$weapon = $skin->weapon->id;
|
||||||
|
$image = $skin->image;
|
||||||
|
$paint = $skin->paint_index;
|
||||||
|
echo "('{$weapon}', {$weapons[$weapon]}, {$paint}, '{$image}', '{$name}')";
|
||||||
|
echo ",<br>";
|
||||||
|
|
||||||
|
}
|
||||||
|
//print_r($json);
|
||||||
|
echo "</pre>";
|
||||||
|
|
||||||
|
?>
|
||||||
BIN
website/img/skins/weapon_ak47-1004.png
Normal file
|
After Width: | Height: | Size: 88 KiB |
BIN
website/img/skins/weapon_ak47-1018.png
Normal file
|
After Width: | Height: | Size: 93 KiB |
BIN
website/img/skins/weapon_ak47-1035.png
Normal file
|
After Width: | Height: | Size: 71 KiB |
BIN
website/img/skins/weapon_ak47-1070.png
Normal file
|
After Width: | Height: | Size: 83 KiB |
BIN
website/img/skins/weapon_ak47-1087.png
Normal file
|
After Width: | Height: | Size: 85 KiB |
BIN
website/img/skins/weapon_ak47-1141.png
Normal file
|
After Width: | Height: | Size: 102 KiB |
BIN
website/img/skins/weapon_ak47-1143.png
Normal file
|
After Width: | Height: | Size: 86 KiB |
BIN
website/img/skins/weapon_ak47-1171.png
Normal file
|
After Width: | Height: | Size: 90 KiB |
BIN
website/img/skins/weapon_ak47-122.png
Normal file
|
After Width: | Height: | Size: 76 KiB |
BIN
website/img/skins/weapon_ak47-1221.png
Normal file
|
After Width: | Height: | Size: 95 KiB |
BIN
website/img/skins/weapon_ak47-1238.png
Normal file
|
After Width: | Height: | Size: 82 KiB |
BIN
website/img/skins/weapon_ak47-14.png
Normal file
|
After Width: | Height: | Size: 81 KiB |
BIN
website/img/skins/weapon_ak47-170.png
Normal file
|
After Width: | Height: | Size: 76 KiB |
BIN
website/img/skins/weapon_ak47-172.png
Normal file
|
After Width: | Height: | Size: 84 KiB |
BIN
website/img/skins/weapon_ak47-180.png
Normal file
|
After Width: | Height: | Size: 85 KiB |
BIN
website/img/skins/weapon_ak47-226.png
Normal file
|
After Width: | Height: | Size: 83 KiB |
BIN
website/img/skins/weapon_ak47-282.png
Normal file
|
After Width: | Height: | Size: 70 KiB |
BIN
website/img/skins/weapon_ak47-300.png
Normal file
|
After Width: | Height: | Size: 78 KiB |
BIN
website/img/skins/weapon_ak47-302.png
Normal file
|
After Width: | Height: | Size: 85 KiB |
BIN
website/img/skins/weapon_ak47-316.png
Normal file
|
After Width: | Height: | Size: 91 KiB |
BIN
website/img/skins/weapon_ak47-340.png
Normal file
|
After Width: | Height: | Size: 85 KiB |
BIN
website/img/skins/weapon_ak47-341.png
Normal file
|
After Width: | Height: | Size: 75 KiB |
BIN
website/img/skins/weapon_ak47-380.png
Normal file
|
After Width: | Height: | Size: 90 KiB |
BIN
website/img/skins/weapon_ak47-394.png
Normal file
|
After Width: | Height: | Size: 82 KiB |
BIN
website/img/skins/weapon_ak47-422.png
Normal file
|
After Width: | Height: | Size: 70 KiB |
BIN
website/img/skins/weapon_ak47-44.png
Normal file
|
After Width: | Height: | Size: 84 KiB |
BIN
website/img/skins/weapon_ak47-456.png
Normal file
|
After Width: | Height: | Size: 79 KiB |
BIN
website/img/skins/weapon_ak47-474.png
Normal file
|
After Width: | Height: | Size: 84 KiB |
BIN
website/img/skins/weapon_ak47-490.png
Normal file
|
After Width: | Height: | Size: 96 KiB |
BIN
website/img/skins/weapon_ak47-506.png
Normal file
|
After Width: | Height: | Size: 91 KiB |
BIN
website/img/skins/weapon_ak47-524.png
Normal file
|
After Width: | Height: | Size: 86 KiB |
BIN
website/img/skins/weapon_ak47-600.png
Normal file
|
After Width: | Height: | Size: 90 KiB |
BIN
website/img/skins/weapon_ak47-639.png
Normal file
|
After Width: | Height: | Size: 87 KiB |
BIN
website/img/skins/weapon_ak47-656.png
Normal file
|
After Width: | Height: | Size: 75 KiB |
BIN
website/img/skins/weapon_ak47-675.png
Normal file
|
After Width: | Height: | Size: 89 KiB |
BIN
website/img/skins/weapon_ak47-707.png
Normal file
|
After Width: | Height: | Size: 98 KiB |
BIN
website/img/skins/weapon_ak47-72.png
Normal file
|
After Width: | Height: | Size: 77 KiB |
BIN
website/img/skins/weapon_ak47-724.png
Normal file
|
After Width: | Height: | Size: 90 KiB |
BIN
website/img/skins/weapon_ak47-745.png
Normal file
|
After Width: | Height: | Size: 79 KiB |
BIN
website/img/skins/weapon_ak47-795.png
Normal file
|
After Width: | Height: | Size: 84 KiB |
BIN
website/img/skins/weapon_ak47-801.png
Normal file
|
After Width: | Height: | Size: 78 KiB |
BIN
website/img/skins/weapon_ak47-836.png
Normal file
|
After Width: | Height: | Size: 80 KiB |
BIN
website/img/skins/weapon_ak47-885.png
Normal file
|
After Width: | Height: | Size: 89 KiB |
BIN
website/img/skins/weapon_ak47-921.png
Normal file
|
After Width: | Height: | Size: 85 KiB |
BIN
website/img/skins/weapon_ak47-941.png
Normal file
|
After Width: | Height: | Size: 89 KiB |
BIN
website/img/skins/weapon_ak47-959.png
Normal file
|
After Width: | Height: | Size: 81 KiB |
|
Before Width: | Height: | Size: 77 KiB |
|
Before Width: | Height: | Size: 82 KiB |
|
Before Width: | Height: | Size: 82 KiB |
|
Before Width: | Height: | Size: 83 KiB |
|
Before Width: | Height: | Size: 86 KiB |
|
Before Width: | Height: | Size: 81 KiB |
|
Before Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 70 KiB |
|
Before Width: | Height: | Size: 82 KiB |
|
Before Width: | Height: | Size: 78 KiB |
|
Before Width: | Height: | Size: 67 KiB |
|
Before Width: | Height: | Size: 97 KiB |
|
Before Width: | Height: | Size: 87 KiB |
|
Before Width: | Height: | Size: 80 KiB |
|
Before Width: | Height: | Size: 92 KiB |
|
Before Width: | Height: | Size: 88 KiB |
|
Before Width: | Height: | Size: 84 KiB |
|
Before Width: | Height: | Size: 88 KiB |
|
Before Width: | Height: | Size: 94 KiB |
|
Before Width: | Height: | Size: 85 KiB |
|
Before Width: | Height: | Size: 81 KiB |
|
Before Width: | Height: | Size: 72 KiB |
|
Before Width: | Height: | Size: 85 KiB |
|
Before Width: | Height: | Size: 75 KiB |
|
Before Width: | Height: | Size: 83 KiB |
|
Before Width: | Height: | Size: 81 KiB |
|
Before Width: | Height: | Size: 83 KiB |
|
Before Width: | Height: | Size: 85 KiB |
|
Before Width: | Height: | Size: 88 KiB |
|
Before Width: | Height: | Size: 83 KiB |
|
Before Width: | Height: | Size: 87 KiB |
|
Before Width: | Height: | Size: 74 KiB |