mirror of
https://github.com/Nereziel/cs2-WeaponPaints.git
synced 2026-02-17 18:39:07 +00:00
Compare commits
40 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f8533ab94 | ||
|
|
55905ccc33 | ||
|
|
24fcfa0222 | ||
|
|
cd059c6bfb | ||
|
|
e338bebaec | ||
|
|
efd7f5dbef | ||
|
|
6bd002cdec | ||
|
|
3a1adf8d4a | ||
|
|
7c3fa6469b | ||
|
|
52962518fe | ||
|
|
7e12b89a9e | ||
|
|
ae56b18a3c | ||
|
|
c907911cd1 | ||
|
|
1aa486cd7d | ||
|
|
5e62c7c597 | ||
|
|
819ac6233c | ||
|
|
ed24eb0dfc | ||
|
|
1a9f7ad108 | ||
|
|
6f1a29bb39 | ||
|
|
9e64cdcd43 | ||
|
|
22880070cd | ||
|
|
208cbe1aef | ||
|
|
c0cf9210dc | ||
|
|
5f61254b4e | ||
|
|
6cd1bb3bf5 | ||
|
|
4f94b831c2 | ||
|
|
969d40b970 | ||
|
|
0cd36a7877 | ||
|
|
7f41607d54 | ||
|
|
928c1e1466 | ||
|
|
78649f5dcf | ||
|
|
4e72f10326 | ||
|
|
3ddbf7e11e | ||
|
|
ee770fd8c2 | ||
|
|
72c5df53b5 | ||
|
|
d0ed0f4c0b | ||
|
|
a8cf33d404 | ||
|
|
1c026c018e | ||
|
|
4a410fd0d8 | ||
|
|
bb08e88371 |
25
Commands.cs
25
Commands.cs
@@ -22,9 +22,12 @@ namespace WeaponPaints
|
||||
IpAddress = player?.IpAddress?.Split(":")[0]
|
||||
};
|
||||
|
||||
if (playerIndex != 0 && 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);
|
||||
if (weaponSync != null)
|
||||
Task.Run(async () => await weaponSync.GetWeaponPaintsFromDatabase(playerInfo));
|
||||
if (Config.Additional.KnifeEnabled)
|
||||
@@ -145,11 +148,13 @@ namespace WeaponPaints
|
||||
AddCommand($"css_{Config.Additional.CommandKnife}", "Knife Menu", (player, info) =>
|
||||
{
|
||||
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);
|
||||
return;
|
||||
}
|
||||
@@ -210,7 +215,7 @@ namespace WeaponPaints
|
||||
int.TryParse(weaponDefIndexObj.ToString(), out var weaponDefIndex) &&
|
||||
int.TryParse(selectedPaintID, out var paintID))
|
||||
{
|
||||
p!.Print(Localizer["f", selectedSkin]);
|
||||
p!.Print(Localizer["wp_skin_menu_select", selectedSkin]);
|
||||
|
||||
if (!gPlayerWeaponsInfo[playerIndex].ContainsKey(weaponDefIndex))
|
||||
{
|
||||
@@ -271,11 +276,13 @@ namespace WeaponPaints
|
||||
AddCommand($"css_{Config.Additional.CommandSkinSelection}", "Skins selection menu", (player, info) =>
|
||||
{
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
||||
22
Events.cs
22
Events.cs
@@ -37,12 +37,16 @@ namespace WeaponPaints
|
||||
{
|
||||
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)
|
||||
g_playersKnife.Remove((int)player.Index);
|
||||
if (Config.Additional.SkinEnabled)
|
||||
gPlayerWeaponsInfo.Remove((int)player.Index);
|
||||
if (commandsCooldown.ContainsKey((int)player.UserId))
|
||||
{
|
||||
commandsCooldown.Remove((int)player.UserId);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEntityCreated(CEntityInstance entity)
|
||||
@@ -91,28 +95,22 @@ namespace WeaponPaints
|
||||
return HookResult.Continue;
|
||||
}
|
||||
|
||||
/*
|
||||
private HookResult OnItemPickup(EventItemPickup @event, GameEventInfo info)
|
||||
{
|
||||
if (@event.Defindex == 42 || @event.Defindex == 59)
|
||||
{
|
||||
Server.PrintToChatAll("test1");
|
||||
|
||||
CCSPlayerController? player = @event.Userid;
|
||||
if (player == null || !player.IsValid || !g_knifePickupCount.ContainsKey((int)player.Index) || player.IsBot || !g_playersKnife.ContainsKey((int)player.Index))
|
||||
return HookResult.Continue;
|
||||
|
||||
Server.PrintToChatAll("test2");
|
||||
|
||||
|
||||
if (g_knifePickupCount[(int)player.Index] >= 2) return HookResult.Continue;
|
||||
Server.PrintToChatAll("test3");
|
||||
|
||||
|
||||
if (g_playersKnife.ContainsKey((int)player.Index)
|
||||
&&
|
||||
g_playersKnife[(int)player.Index] != "weapon_knife")
|
||||
{
|
||||
Server.PrintToChatAll("usuwam noz");
|
||||
g_knifePickupCount[(int)player.Index]++;
|
||||
|
||||
RemovePlayerKnife(player, true);
|
||||
@@ -123,6 +121,7 @@ namespace WeaponPaints
|
||||
}
|
||||
return HookResult.Continue;
|
||||
}
|
||||
*/
|
||||
|
||||
public HookResult OnPickup(CEntityIOOutput output, string name, CEntityInstance activator, CEntityInstance caller, CVariant value, float delay)
|
||||
{
|
||||
@@ -145,15 +144,14 @@ namespace WeaponPaints
|
||||
if (g_playersKnife[(int)player.Index] != "weapon_knife")
|
||||
{
|
||||
g_knifePickupCount[(int)player.Index]++;
|
||||
weapon.Remove();
|
||||
if (!PlayerHasKnife(player) && Config.Additional.GiveKnifeAfterRemove)
|
||||
player.RemoveItemByDesignerName(weapon.DesignerName);
|
||||
if (Config.Additional.GiveKnifeAfterRemove)
|
||||
AddTimer(0.2f, () => GiveKnifeToPlayer(player));
|
||||
}
|
||||
|
||||
return HookResult.Continue;
|
||||
}
|
||||
|
||||
|
||||
private void OnMapStart(string mapName)
|
||||
{
|
||||
if (!Config.Additional.KnifeEnabled) return;
|
||||
@@ -236,7 +234,7 @@ namespace WeaponPaints
|
||||
return HookResult.Continue;
|
||||
}
|
||||
|
||||
if (Config.Additional.KnifeEnabled)
|
||||
if (Config.Additional.KnifeEnabled && !PlayerHasKnife(player))
|
||||
{
|
||||
g_knifePickupCount[(int)player.Index] = 0;
|
||||
AddTimer(0.1f, () => GiveKnifeToPlayer(player));
|
||||
|
||||
@@ -7,6 +7,7 @@ public static class PlayerExtensions
|
||||
{
|
||||
public static void Print(this CCSPlayerController controller, string message)
|
||||
{
|
||||
if (WeaponPaints._localizer == null) return;
|
||||
StringBuilder _message = new(WeaponPaints._localizer["wp_prefix"]);
|
||||
_message.Append(message);
|
||||
controller.PrintToChat(_message.ToString());
|
||||
|
||||
38
README.md
38
README.md
@@ -9,18 +9,19 @@ Unfinished, unoptimized and not fully functional ugly demo weapon paints plugin
|
||||
[](https://ko-fi.com/E1E2G0P2O) or [](https://steamcommunity.com/tradeoffer/new/?partner=41515647&token=gW2W-nXE)
|
||||
|
||||
## Features
|
||||
- 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;
|
||||
- Data sync on player connect;
|
||||
- Added command **`!wp`** to refresh skins; ***(with cooldown in second can be configured)***
|
||||
- Added command **`!ws`** to show website;
|
||||
- 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 ""`**;
|
||||
- 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
|
||||
- Data sync on player connect
|
||||
- Added command **`!wp`** to refresh skins ***(with cooldown in second can be configured)***
|
||||
- Added command **`!ws`** to show website
|
||||
- Added command **`!knife`** to show menu with knives
|
||||
- Knife change is now limited to have these cvars empty **`mp_t_default_melee ""`** and **`mp_ct_default_melee ""`**
|
||||
- Translations support, submit a PR if you want to share your translation
|
||||
|
||||
## CS2 Server
|
||||
- Compile and copy plugin to plugins, [more info here](https://docs.cssharp.dev/guides/hello-world-plugin/);
|
||||
- Setup **`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`**;
|
||||
- Compile and copy plugin to plugins, [more info here](https://docs.cssharp.dev/guides/hello-world-plugin/)
|
||||
- Setup **`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
|
||||
<details>
|
||||
@@ -69,12 +70,17 @@ Unfinished, unoptimized and not fully functional ugly demo weapon paints plugin
|
||||
</details>
|
||||
|
||||
## Web install
|
||||
Disregard if the config is **`GlobalShare = true`**;
|
||||
- Requires PHP >= 7.4; ***(Tested on php ver **`8.2.3`** and nginx webserver)***
|
||||
- Copy website to web server; ***(Folder `img` not needed)***
|
||||
- Get [Steam API Key](https://steamcommunity.com/dev/apikey);
|
||||
- Fill in database credentials and api key in `class/config.php`;
|
||||
- Visit website and login via steam;
|
||||
Disregard if the config is **`GlobalShare = true`**
|
||||
- Requires PHP >= 7.4 ***(Tested on php ver **`8.2.3`** and nginx webserver)***
|
||||
- Copy website to web server ***(Folder `img` not needed)***
|
||||
- Get [Steam API Key](https://steamcommunity.com/dev/apikey)
|
||||
- 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
|
||||
- Issue on Windows servers, no knives are given.
|
||||
|
||||
@@ -197,7 +197,7 @@ namespace WeaponPaints
|
||||
{
|
||||
if (weapon.Value.DesignerName.Contains("knife") || weapon.Value.DesignerName.Contains("bayonet"))
|
||||
{
|
||||
weapon.Value.Remove();
|
||||
player.RemoveItemByDesignerName(weapon.Value.DesignerName, true);
|
||||
GiveKnifeToPlayer(player);
|
||||
}
|
||||
else
|
||||
@@ -208,8 +208,8 @@ namespace WeaponPaints
|
||||
clip1 = weapon.Value.Clip1;
|
||||
reservedAmmo = weapon.Value.ReserveAmmo[0];
|
||||
|
||||
weapon.Value.Remove();
|
||||
string weaponByDefindex = weaponDefindex[weapon.Value.AttributeManager.Item.ItemDefinitionIndex];
|
||||
player.RemoveItemByDesignerName(weapon.Value.DesignerName, true);
|
||||
CBasePlayerWeapon newWeapon = new(player.GiveNamedItem(weaponByDefindex));
|
||||
|
||||
Server.NextFrame(() =>
|
||||
|
||||
@@ -8,7 +8,7 @@ using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace WeaponPaints;
|
||||
|
||||
[MinimumApiVersion(121)]
|
||||
[MinimumApiVersion(132)]
|
||||
public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
||||
{
|
||||
internal static readonly Dictionary<string, string> weaponList = new()
|
||||
@@ -81,7 +81,7 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
||||
|
||||
internal Uri GlobalShareApi = new("https://weaponpaints.fun/api.php");
|
||||
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;
|
||||
private CounterStrikeSharp.API.Modules.Timers.Timer? g_hTimerCheckSkinsData = null;
|
||||
public static Dictionary<int, string> weaponDefindex { get; } = new Dictionary<int, string>
|
||||
@@ -145,7 +145,7 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
||||
public override string ModuleAuthor => "Nereziel & daffyy";
|
||||
public override string ModuleDescription => "Skin and knife selector, standalone and web-based";
|
||||
public override string ModuleName => "WeaponPaints";
|
||||
public override string ModuleVersion => "1.3g";
|
||||
public override string ModuleVersion => "1.3h";
|
||||
|
||||
public static WeaponPaintsConfig GetWeaponPaintsConfig()
|
||||
{
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.121" />
|
||||
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.132" />
|
||||
<PackageReference Include="Dapper" Version="2.1.24" />
|
||||
<PackageReference Include="MySqlConnector" Version="2.3.1" />
|
||||
<PackageReference Include="MySqlConnector" Version="2.3.3" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
14
lang/pt-BR.json
Normal file
14
lang/pt-BR.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"wp_prefix": "{lightblue}[WeaponPaints] {default}",
|
||||
"wp_info_website": "Visite {lime}{0}{default} para mudar suas skins e faca",
|
||||
"wp_info_refresh": "Digite {lime}!wp{default} para sincronizar as suas skins",
|
||||
"wp_info_knife": "Digite {lime}!knife{default} para abrir o menu de facas",
|
||||
"wp_command_cooldown": "{lightred}Você não pode atualizar as skins das armas agora",
|
||||
"wp_command_refresh_done": "{lime}Sincronizando as suas skins",
|
||||
"wp_knife_menu_select": "Você escolheu {lime}{0}{default} como sua faca",
|
||||
"wp_knife_menu_kill": "Para aplicar corretamente a skin da faca, você precisa digitar {lime}!kill{default}",
|
||||
"wp_knife_menu_title": "Menu de Facas",
|
||||
"wp_skin_menu_weapon_title": "Menu de Armas",
|
||||
"wp_skin_menu_skin_title": "Selecionou a skin para {lime}{0}{default}",
|
||||
"wp_skin_menu_select": "Você escolheu {lime}{0}{default} como sua skin"
|
||||
}
|
||||
14
lang/pt-PT.json
Normal file
14
lang/pt-PT.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"wp_prefix": "{lightblue}[WeaponPaints] {default}",
|
||||
"wp_info_website": "Visita {lime}{0}{default} onde podes mudar as tuas skins",
|
||||
"wp_info_refresh": "Digita {lime}!wp{default} para sincronizar as tuas skins",
|
||||
"wp_info_knife": "Digita {lime}!knife{default} para abrir o menu de facas",
|
||||
"wp_command_cooldown": "{lightred}Tu não podes sincronizar agora as tuas skins",
|
||||
"wp_command_refresh_done": "{lime}Sincronizando as tuas skins",
|
||||
"wp_knife_menu_select": "Tu escolheste {lime}{0}{default} como a tua faca",
|
||||
"wp_knife_menu_kill": "Para aplicar corretamente a skins para a tua faca, digita {lime}!kill{default}",
|
||||
"wp_knife_menu_title": "Menu Facas",
|
||||
"wp_skin_menu_weapon_title": "Menu de Armas",
|
||||
"wp_skin_menu_skin_title": "Escolhe a skin para {lime}{0}{default}",
|
||||
"wp_skin_menu_select": "Tu escolheste {lime}{0}{default} como a tua skin"
|
||||
}
|
||||
14
lang/tr.json
Normal file
14
lang/tr.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"wp_prefix": "{lightblue}[WeaponPaints] {default}",
|
||||
"wp_info_website": "Görünümleri değiştirebileceğiniz {lime}{0}{default} adresini ziyaret edin",
|
||||
"wp_info_refresh": "Seçilen kaplamyı senkronize etmek için {lime}!wp{default} yazın",
|
||||
"wp_info_knife": "Bıçak menüsünü açmak için {lime}!knife{default} yazın",
|
||||
"wp_command_cooldown": "{lightred}Şu anda silah kaplamasını yenileyemezsiniz",
|
||||
"wp_command_refresh_done": "{lime}Silah kaplaması yenileniyor",
|
||||
"wp_knife_menu_select": "Bıçağınız olarak {lime}{0}{default} seçtiniz",
|
||||
"wp_knife_menu_kill": "Bıçak için doğru şekilde kaplama uygulamak için {lime}!kill{default} yazmanız gerekir",
|
||||
"wp_knife_menu_title": "Bıçak Menüsü",
|
||||
"wp_skin_menu_weapon_title": "Silah Menüsü",
|
||||
"wp_skin_menu_skin_title": "Select skin for {lime}{0}{default}",
|
||||
"wp_skin_menu_select": "Teniniz olarak {lime}{0}{default} seçtiniz"
|
||||
}
|
||||
14
lang/ua.json
Normal file
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
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_PASS', '');
|
||||
|
||||
define('WEB_STYLE_DARK', true);
|
||||
|
||||
define('STEAM_API_KEY', '');
|
||||
define('STEAM_DOMAIN_NAME', '');
|
||||
define('STEAM_LOGOUT_PAGE', '');
|
||||
|
||||
@@ -4,7 +4,14 @@ class DataBase {
|
||||
private $PDO;
|
||||
|
||||
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 = []) {
|
||||
$STH = $this->PDO->prepare($query);
|
||||
|
||||
@@ -88,7 +88,11 @@ class UtilsClass
|
||||
$selected = [];
|
||||
|
||||
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;
|
||||
|
||||
73
website/getskins.php
Normal file
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>";
|
||||
|
||||
?>
|
||||
@@ -4,16 +4,16 @@ require_once 'class/database.php';
|
||||
require_once 'steamauth/steamauth.php';
|
||||
require_once 'class/utils.php';
|
||||
|
||||
|
||||
$db = new DataBase();
|
||||
if (isset($_SESSION['steamid'])) {
|
||||
|
||||
$steamid = $_SESSION['steamid'];
|
||||
|
||||
$weapons = UtilsClass::getWeaponsFromArray();
|
||||
$skins = UtilsClass::skinsFromJson();
|
||||
$querySelected = $query3 = $db->select("SELECT `weapon_defindex`, `weapon_paint_id` FROM `wp_player_skins` WHERE `wp_player_skins`.`steamid` = :steamid", ["steamid" => $steamid]);
|
||||
$querySelected = $db->select("SELECT `weapon_defindex`, `weapon_paint_id`, `weapon_wear`, `weapon_seed` FROM `wp_player_skins` WHERE `wp_player_skins`.`steamid` = :steamid", ["steamid" => $steamid]);
|
||||
$selectedSkins = UtilsClass::getSelectedSkins($querySelected);
|
||||
$selectedKnife = $db->select("SELECT * FROM `wp_player_knife` WHERE `wp_player_knife`.`steamid` = :steamid", ["steamid" => $steamid])[0];
|
||||
$selectedKnife = $db->select("SELECT * FROM `wp_player_knife` WHERE `wp_player_knife`.`steamid` = :steamid", ["steamid" => $steamid]);
|
||||
$knifes = UtilsClass::getKnifeTypes();
|
||||
|
||||
if (isset($_POST['forma'])) {
|
||||
@@ -22,31 +22,30 @@ if (isset($_SESSION['steamid'])) {
|
||||
if ($ex[0] == "knife") {
|
||||
$db->query("INSERT INTO `wp_player_knife` (`steamid`, `knife`) VALUES(:steamid, :knife) ON DUPLICATE KEY UPDATE `knife` = :knife", ["steamid" => $steamid, "knife" => $knifes[$ex[1]]['weapon_name']]);
|
||||
} else {
|
||||
if (!is_int($ex[1]))
|
||||
header("Location: index.php");
|
||||
if (array_key_exists($ex[1], $skins[$ex[0]])) {
|
||||
if (array_key_exists($ex[1], $skins[$ex[0]]) && isset($_POST['wear']) && $_POST['wear'] >= 0.00 && $_POST['wear'] <= 1.00 && isset($_POST['seed'])) {
|
||||
$wear = floatval($_POST['wear']); // wear
|
||||
$seed = intval($_POST['seed']); // seed
|
||||
if (array_key_exists($ex[0], $selectedSkins)) {
|
||||
$db->query("UPDATE wp_player_skins SET weapon_paint_id = :weapon_paint_id WHERE steamid = :steamid AND weapon_defindex = :weapon_defindex", ["steamid" => $steamid, "weapon_defindex" => $ex[0], "weapon_paint_id" => $ex[1]]);
|
||||
$db->query("UPDATE wp_player_skins SET weapon_paint_id = :weapon_paint_id, weapon_wear = :weapon_wear, weapon_seed = :weapon_seed WHERE steamid = :steamid AND weapon_defindex = :weapon_defindex", ["steamid" => $steamid, "weapon_defindex" => $ex[0], "weapon_paint_id" => $ex[1], "weapon_wear" => $wear, "weapon_seed" => $seed]);
|
||||
} else {
|
||||
$db->query("INSERT INTO wp_player_skins (`steamid`, `weapon_defindex`, `weapon_paint_id`) VALUES (:steamid, :weapon_defindex, :weapon_paint_id)", ["steamid" => $steamid, "weapon_defindex" => $ex[0], "weapon_paint_id" => $ex[1]]);
|
||||
$db->query("INSERT INTO wp_player_skins (`steamid`, `weapon_defindex`, `weapon_paint_id`, `weapon_wear`, `weapon_seed`) VALUES (:steamid, :weapon_defindex, :weapon_paint_id, :weapon_wear, :weapon_seed)", ["steamid" => $steamid, "weapon_defindex" => $ex[0], "weapon_paint_id" => $ex[1], "weapon_wear" => $wear, "weapon_seed" => $seed]);
|
||||
}
|
||||
}
|
||||
}
|
||||
header("Location: index.php");
|
||||
header("Location: {$_SERVER['PHP_SELF']}");
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<html lang="en"<?php if(WEB_STYLE_DARK) echo 'data-bs-theme="dark"'?>>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet"
|
||||
integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"
|
||||
integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL"
|
||||
crossorigin="anonymous"></script>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
|
||||
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.min.js"></script>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<title>CS2 Simple Weapon Paints</title>
|
||||
</head>
|
||||
@@ -59,19 +58,22 @@ if (isset($_SESSION['steamid'])) {
|
||||
loginbutton("rectangle");
|
||||
echo "</h2></div>";
|
||||
} else {
|
||||
echo "<div class='bg-primary'>Your current weapon skin loadout<form action='' method='get'><button class='btn btn-secondary' name='logout' type='submit'>Logout</button></form></div>";
|
||||
echo "<div class='bg-primary'><h2>Your current weapon skin loadout <a class='btn btn-danger' href='{$_SERVER['PHP_SELF']}?logout'>Logout</a></h2> </div>";
|
||||
echo "<div class='card-group mt-2'>";
|
||||
?>
|
||||
?>
|
||||
|
||||
<div class="col-sm-2">
|
||||
<div class="card text-center mb-3 border border-primary">
|
||||
<div class="card-body">
|
||||
<?php
|
||||
$actualKnife = $knifes[0];
|
||||
foreach ($knifes as $knife) {
|
||||
if ($selectedKnife['knife'] == $knife['weapon_name']) {
|
||||
$actualKnife = $knife;
|
||||
break;
|
||||
if ($selectedKnife != null)
|
||||
{
|
||||
foreach ($knifes as $knife) {
|
||||
if ($selectedKnife[0]['knife'] == $knife['weapon_name']) {
|
||||
$actualKnife = $knife;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +90,7 @@ if (isset($_SESSION['steamid'])) {
|
||||
<option disabled>Select knife</option>
|
||||
<?php
|
||||
foreach ($knifes as $knifeKey => $knife) {
|
||||
if ($selectedKnife['knife'] == $knife['weapon_name'])
|
||||
if ($selectedKnife[0]['knife'] == $knife['weapon_name'])
|
||||
echo "<option selected value=\"knife-{$knifeKey}\">{$knife['paint_name']}</option>";
|
||||
else
|
||||
echo "<option value=\"knife-{$knifeKey}\">{$knife['paint_name']}</option>";
|
||||
@@ -108,9 +110,9 @@ if (isset($_SESSION['steamid'])) {
|
||||
<?php
|
||||
if (array_key_exists($defindex, $selectedSkins)) {
|
||||
echo "<div class='card-header'>";
|
||||
echo "<h5 class='card-title item-name'>{$skins[$defindex][$selectedSkins[$defindex]]["paint_name"]}</h5>";
|
||||
echo "<h5 class='card-title item-name'>{$skins[$defindex][$selectedSkins[$defindex]['weapon_paint_id']]["paint_name"]}</h5>";
|
||||
echo "</div>";
|
||||
echo "<img src='{$skins[$defindex][$selectedSkins[$defindex]]['image_url']}' class='skin-image'>";
|
||||
echo "<img src='{$skins[$defindex][$selectedSkins[$defindex]['weapon_paint_id']]['image_url']}' class='skin-image'>";
|
||||
} else {
|
||||
echo "<div class='card-header'>";
|
||||
echo "<h5 class='card-title item-name'>{$default["paint_name"]}</h5>";
|
||||
@@ -125,21 +127,135 @@ if (isset($_SESSION['steamid'])) {
|
||||
<option disabled>Select skin</option>
|
||||
<?php
|
||||
foreach ($skins[$defindex] as $paintKey => $paint) {
|
||||
if (array_key_exists($defindex, $selectedSkins) && $selectedSkins[$defindex] == $paintKey)
|
||||
if (array_key_exists($defindex, $selectedSkins) && $selectedSkins[$defindex]['weapon_paint_id'] == $paintKey)
|
||||
echo "<option selected value=\"{$defindex}-{$paintKey}\">{$paint['paint_name']}</option>";
|
||||
else
|
||||
echo "<option value=\"{$defindex}-{$paintKey}\">{$paint['paint_name']}</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</form>
|
||||
<br></br>
|
||||
<?php
|
||||
$selectedSkinInfo = isset($selectedSkins[$defindex]) ? $selectedSkins[$defindex] : null;
|
||||
$steamid = $_SESSION['steamid'];
|
||||
|
||||
if ($selectedSkinInfo) :
|
||||
?>
|
||||
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#weaponModal<?php echo $defindex ?>">
|
||||
Settings
|
||||
</button>
|
||||
<?php else : ?>
|
||||
<button type="button" class="btn btn-primary" onclick="showSkinSelectionAlert()">
|
||||
Settings
|
||||
</button>
|
||||
<script>
|
||||
function showSkinSelectionAlert() {
|
||||
alert("You need to select a skin first.");
|
||||
}
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
|
||||
<?php
|
||||
// wear value
|
||||
$selectedSkinInfo = isset($selectedSkins[$defindex]['weapon_paint_id']) ? $selectedSkins[$defindex] : null;
|
||||
$queryWear = $selectedSkins[$defindex]['weapon_wear'] ?? 1.0;
|
||||
$initialWearValue = isset($selectedSkinInfo['weapon_wear']) ? $selectedSkinInfo['weapon_wear'] : (isset($queryWear[0]['weapon_wear']) ? $queryWear[0] : 0.0);
|
||||
|
||||
// seed value
|
||||
$querySeed = $selectedSkins[$defindex]['weapon_seed'] ?? 0;
|
||||
$initialSeedValue = isset($selectedSkinInfo['weapon_seed']) ? $selectedSkinInfo['weapon_seed'] : 0;
|
||||
?>
|
||||
|
||||
|
||||
<div class="modal fade" id="weaponModal<?php echo $defindex ?>" tabindex="-1" role="dialog" aria-labelledby="weaponModalLabel<?php echo $defindex ?>" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class='card-title item-name'>
|
||||
<?php
|
||||
if (array_key_exists($defindex, $selectedSkins)) {
|
||||
echo "{$skins[$defindex][$selectedSkins[$defindex]['weapon_paint_id']]["paint_name"]} Settings";
|
||||
} else {
|
||||
echo "{$default["paint_name"]} Settings";
|
||||
}
|
||||
?>
|
||||
</h5>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<select class="form-select" id="wearSelect<?php echo $defindex ?>" name="wearSelect" onchange="updateWearValue<?php echo $defindex ?>(this.value)">
|
||||
<option disabled>Select Wear</option>
|
||||
<option value="0.00" <?php echo ($initialWearValue == 0.00) ? 'selected' : ''; ?>>Factory New</option>
|
||||
<option value="0.07" <?php echo ($initialWearValue == 0.07) ? 'selected' : ''; ?>>Minimal Wear</option>
|
||||
<option value="0.15" <?php echo ($initialWearValue == 0.15) ? 'selected' : ''; ?>>Field-Tested</option>
|
||||
<option value="0.38" <?php echo ($initialWearValue == 0.38) ? 'selected' : ''; ?>>Well-Worn</option>
|
||||
<option value="0.45" <?php echo ($initialWearValue == 0.45) ? 'selected' : ''; ?>>Battle-Scarred</option>
|
||||
</select>
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="wear">Wear:</label>
|
||||
<input type="text" value="<?php echo $initialWearValue; ?>" class="form-control" id="wear<?php echo $defindex ?>" name="wear">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="seed">Seed:</label>
|
||||
<input type="text" value="<?php echo $initialSeedValue; ?>" class="form-control" id="seed<?php echo $defindex ?>" name="seed" oninput="validateSeed(this)">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||
<button type="submit" class="btn btn-danger">Use</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
// wear
|
||||
function updateWearValue<?php echo $defindex ?>(selectedValue) {
|
||||
var wearInputElement = document.getElementById("wear<?php echo $defindex ?>");
|
||||
wearInputElement.value = selectedValue;
|
||||
}
|
||||
|
||||
function validateWear(inputElement) {
|
||||
inputElement.value = inputElement.value.replace(/[^0-9]/g, '');
|
||||
}
|
||||
// seed
|
||||
function validateSeed(input) {
|
||||
// Check entered value
|
||||
var inputValue = input.value.replace(/[^0-9]/g, ''); // Just get the numbers
|
||||
|
||||
if (inputValue === "") {
|
||||
input.value = 0; // Set to 0 if empty or no numbers
|
||||
} else {
|
||||
var numericValue = parseInt(inputValue);
|
||||
numericValue = Math.min(1000, Math.max(1, numericValue)); // Interval control
|
||||
|
||||
input.value = numericValue;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="container">
|
||||
<footer class="d-flex flex-wrap justify-content-between align-items-center py-3 my-4 border-top">
|
||||
<div class="col-md-4 d-flex align-items-center">
|
||||
<span class="mb-3 mb-md-0 text-body-secondary">© 2023 <a href="https://github.com/Nereziel/cs2-WeaponPaints">Nereziel/cs2-WeaponPaints</a></span>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 142 KiB After Width: | Height: | Size: 126 KiB |
Reference in New Issue
Block a user