Compare commits
65 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be4de02d50 | ||
|
|
52e4fd7195 | ||
|
|
d7631c51b6 | ||
|
|
74aa5fa40c | ||
|
|
2a1ef7b489 | ||
|
|
a6f5eac440 | ||
|
|
deb18acb8f | ||
|
|
e6d935e16b | ||
|
|
c3d2209a13 | ||
|
|
67b35d9117 | ||
|
|
d102ac371b | ||
|
|
26a31d4bd7 | ||
|
|
4e9a4b2925 | ||
|
|
d6384f4ecf | ||
|
|
85fc0bd4bc | ||
|
|
5c7df833cc | ||
|
|
5640919b09 | ||
|
|
0550ef68f4 | ||
|
|
c0d42a3d9c | ||
|
|
5636b401ea | ||
|
|
06cfda21f2 | ||
|
|
c291005d4d | ||
|
|
322b1b425b | ||
|
|
771a832ae8 | ||
|
|
323c74b49c | ||
|
|
ee1dffa06b | ||
|
|
d90055ad89 | ||
|
|
48854c4eaf | ||
|
|
c06f7ae3be | ||
|
|
29461e9de2 | ||
|
|
74ec584d9a | ||
|
|
ec0d4f4d5a | ||
|
|
a8ba645292 | ||
|
|
e04dd312e8 | ||
|
|
702dea9450 | ||
|
|
c594cd534e | ||
|
|
5aaf0e6f62 | ||
|
|
942e776688 | ||
|
|
36046fee2d | ||
|
|
d6de0ce6c8 | ||
|
|
d2c19d8af8 | ||
|
|
0f6d334621 | ||
|
|
f99c9b2767 | ||
|
|
6a2d28c303 | ||
|
|
27a2ae5be9 | ||
|
|
0af9177f07 | ||
|
|
cfb49e1498 | ||
|
|
bbdb4b82ce | ||
|
|
bfb7defcaa | ||
|
|
5626c32d30 | ||
|
|
a6575e9ab2 | ||
|
|
683efbd0ae | ||
|
|
3bc9123a71 | ||
|
|
f75ea76deb | ||
|
|
bf0deda5d7 | ||
|
|
548fdb642d | ||
|
|
8cb9563994 | ||
|
|
e45714cb9a | ||
|
|
97e73bfd53 | ||
|
|
6dc047477c | ||
|
|
ced010645d | ||
|
|
b030d5c7e1 | ||
|
|
90771f76c7 | ||
|
|
ad8e51a403 | ||
|
|
8c1edddd1e |
2
.github/workflows/build.yml
vendored
@@ -64,6 +64,8 @@ jobs:
|
||||
run: cp website/data/gloves.json ${{ env.OUTPUT_PATH }}/gloves.json
|
||||
- name: Copy agents.json
|
||||
run: cp website/data/agents.json ${{ env.OUTPUT_PATH }}/agents.json
|
||||
- name: Copy music.json
|
||||
run: cp website/data/music.json ${{ env.OUTPUT_PATH }}/music.json
|
||||
- name: Zip
|
||||
run: zip -r "${{ env.PROJECT_NAME }}.zip" "${{ env.OUTPUT_PATH }}" gamedata/
|
||||
- name: Clean files Website
|
||||
|
||||
1
.gitignore
vendored
@@ -2,3 +2,4 @@
|
||||
bin/
|
||||
obj/
|
||||
website/getskins.php
|
||||
.idea/
|
||||
869
Commands.cs
128
Config.cs
@@ -3,61 +3,8 @@ using System.Text.Json.Serialization;
|
||||
|
||||
namespace WeaponPaints
|
||||
{
|
||||
public class Additional
|
||||
public class DatabaseCredentials
|
||||
{
|
||||
[JsonPropertyName("KnifeEnabled")]
|
||||
public bool KnifeEnabled { get; set; } = true;
|
||||
|
||||
[JsonPropertyName("GloveEnabled")]
|
||||
public bool GloveEnabled { get; set; } = true;
|
||||
|
||||
[JsonPropertyName("AgentEnabled")]
|
||||
public bool AgentEnabled { get; set; } = true;
|
||||
|
||||
[JsonPropertyName("SkinEnabled")]
|
||||
public bool SkinEnabled { get; set; } = true;
|
||||
|
||||
[JsonPropertyName("CommandWpEnabled")]
|
||||
public bool CommandWpEnabled { get; set; } = true;
|
||||
|
||||
[JsonPropertyName("CommandKillEnabled")]
|
||||
public bool CommandKillEnabled { get; set; } = true;
|
||||
|
||||
[JsonPropertyName("CommandKnife")]
|
||||
public string CommandKnife { get; set; } = "knife";
|
||||
|
||||
[JsonPropertyName("CommandGlove")]
|
||||
public string CommandGlove { get; set; } = "gloves";
|
||||
|
||||
[JsonPropertyName("CommandAgent")]
|
||||
public string CommandAgent { get; set; } = "agents";
|
||||
|
||||
[JsonPropertyName("CommandSkin")]
|
||||
public string CommandSkin { get; set; } = "ws";
|
||||
|
||||
[JsonPropertyName("CommandSkinSelection")]
|
||||
public string CommandSkinSelection { get; set; } = "skins";
|
||||
|
||||
[JsonPropertyName("CommandRefresh")]
|
||||
public string CommandRefresh { get; set; } = "wp";
|
||||
|
||||
[JsonPropertyName("CommandKill")]
|
||||
public string CommandKill { get; set; } = "kill";
|
||||
|
||||
[JsonPropertyName("GiveRandomKnife")]
|
||||
public bool GiveRandomKnife { get; set; } = false;
|
||||
|
||||
[JsonPropertyName("GiveRandomSkin")]
|
||||
public bool GiveRandomSkin { get; set; } = false;
|
||||
|
||||
[JsonPropertyName("ShowSkinImage")]
|
||||
public bool ShowSkinImage { get; set; } = true;
|
||||
}
|
||||
|
||||
public class WeaponPaintsConfig : BasePluginConfig
|
||||
{
|
||||
public override int Version { get; set; } = 6;
|
||||
|
||||
[JsonPropertyName("DatabaseHost")]
|
||||
public string DatabaseHost { get; set; } = "";
|
||||
|
||||
@@ -72,7 +19,78 @@ namespace WeaponPaints
|
||||
|
||||
[JsonPropertyName("DatabaseName")]
|
||||
public string DatabaseName { get; set; } = "";
|
||||
}
|
||||
|
||||
public class Additional
|
||||
{
|
||||
[JsonPropertyName("KnifeEnabled")]
|
||||
public bool KnifeEnabled { get; set; } = true;
|
||||
|
||||
[JsonPropertyName("GloveEnabled")]
|
||||
public bool GloveEnabled { get; set; } = true;
|
||||
|
||||
[JsonPropertyName("MusicEnabled")]
|
||||
public bool MusicEnabled { get; set; } = true;
|
||||
|
||||
[JsonPropertyName("AgentEnabled")]
|
||||
public bool AgentEnabled { get; set; } = true;
|
||||
|
||||
[JsonPropertyName("SkinEnabled")]
|
||||
public bool SkinEnabled { get; set; } = true;
|
||||
|
||||
[JsonPropertyName("NameTagEnabled")]
|
||||
public bool NameTagEnabled { get; set; } = true;
|
||||
|
||||
[JsonPropertyName("PinEnabled")]
|
||||
public bool PinEnabled { get; set; } = true;
|
||||
|
||||
[JsonPropertyName("CommandsKnife")]
|
||||
public List<string> CommandsKnife { get; set; } = ["knife", "knives"];
|
||||
|
||||
[JsonPropertyName("CommandsMusic")]
|
||||
public List<string> CommandsMusic { get; set; } = ["music", "musickits", "mkit"];
|
||||
|
||||
[JsonPropertyName("CommandsGlove")]
|
||||
public List<string> CommandsGlove { get; set; } = ["gloves", "glove"];
|
||||
|
||||
[JsonPropertyName("CommandsAgent")]
|
||||
public List<string> CommandsAgent { get; set; } = ["agents", "agent"];
|
||||
|
||||
[JsonPropertyName("CommandsInfo")]
|
||||
public List<string> CommandsInfo { get; set; } = ["ws", "skininfo"];
|
||||
|
||||
[JsonPropertyName("CommandsSkinSelection")]
|
||||
public List<string> CommandsSkinSelection { get; set; } = ["skins", "skin"];
|
||||
|
||||
[JsonPropertyName("CommandsRefresh")]
|
||||
public List<string> CommandsRefresh { get; set; } = ["wp", "refreshskins"];
|
||||
|
||||
[JsonPropertyName("CommandsKill")]
|
||||
public List<string> CommandsKill { get; set; } = ["kill", "suicide"];
|
||||
|
||||
[JsonPropertyName("GiveRandomKnife")]
|
||||
public bool GiveRandomKnife { get; set; } = false;
|
||||
|
||||
[JsonPropertyName("GiveRandomSkin")]
|
||||
public bool GiveRandomSkin { get; set; } = false;
|
||||
|
||||
[JsonPropertyName("ShowSkinImage")]
|
||||
public bool ShowSkinImage { get; set; } = true;
|
||||
|
||||
[JsonPropertyName("UseHtmlMenu")]
|
||||
public bool UseHtmlMenu { get; set; } = true;
|
||||
|
||||
[JsonPropertyName("ExpireOlderThan")]
|
||||
public int ExpireOlderThan { get; set; } = 90;
|
||||
}
|
||||
|
||||
public class WeaponPaintsConfig : BasePluginConfig
|
||||
{
|
||||
public override int Version { get; set; } = 7;
|
||||
|
||||
[JsonPropertyName("DatabaseCredentials")]
|
||||
public DatabaseCredentials DatabaseCredentials { get; set; } = new();
|
||||
|
||||
[JsonPropertyName("CmdRefreshCooldownSeconds")]
|
||||
public int CmdRefreshCooldownSeconds { get; set; } = 60;
|
||||
|
||||
@@ -83,6 +101,6 @@ namespace WeaponPaints
|
||||
public string Website { get; set; } = "example.com/skins";
|
||||
|
||||
[JsonPropertyName("Additional")]
|
||||
public Additional Additional { get; set; } = new Additional();
|
||||
public Additional Additional { get; set; } = new();
|
||||
}
|
||||
}
|
||||
17
Database.cs
@@ -1,26 +1,21 @@
|
||||
using MySqlConnector;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using MySqlConnector;
|
||||
|
||||
namespace WeaponPaints
|
||||
{
|
||||
public class Database
|
||||
public class Database(string dbConnectionString)
|
||||
{
|
||||
private readonly string _dbConnectionString;
|
||||
|
||||
public Database(string dbConnectionString)
|
||||
{
|
||||
_dbConnectionString = dbConnectionString;
|
||||
}
|
||||
|
||||
public async Task<MySqlConnection> GetConnectionAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var connection = new MySqlConnection(_dbConnectionString);
|
||||
var connection = new MySqlConnection(dbConnectionString);
|
||||
await connection.OpenAsync();
|
||||
return connection;
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception ex)
|
||||
{
|
||||
WeaponPaints.Instance.Logger.LogError($"Unable to connect to database: {ex.Message}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
269
Events.cs
@@ -1,6 +1,10 @@
|
||||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Core.Attributes.Registration;
|
||||
using CounterStrikeSharp.API.Modules.Entities;
|
||||
using CounterStrikeSharp.API.Modules.Memory;
|
||||
using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace WeaponPaints
|
||||
{
|
||||
@@ -11,7 +15,7 @@ namespace WeaponPaints
|
||||
{
|
||||
CCSPlayerController? player = @event.Userid;
|
||||
|
||||
if (player is null || !player.IsValid || player.IsBot || player.IsHLTV || player.SteamID.ToString().Length != 17 ||
|
||||
if (player is null || !player.IsValid || player.IsBot ||
|
||||
weaponSync == null || _database == null) return HookResult.Continue;
|
||||
|
||||
PlayerInfo playerInfo = new PlayerInfo
|
||||
@@ -19,42 +23,41 @@ namespace WeaponPaints
|
||||
UserId = player.UserId,
|
||||
Slot = player.Slot,
|
||||
Index = (int)player.Index,
|
||||
SteamId = player.SteamID.ToString(),
|
||||
SteamId = player.SteamID,
|
||||
Name = player.PlayerName,
|
||||
IpAddress = player.IpAddress?.Split(":")[0]
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
List<Task> tasks = new List<Task>();
|
||||
|
||||
_ = Task.Run(async () => await weaponSync.GetPlayerDatabaseIndex(playerInfo));
|
||||
/*
|
||||
if (Config.Additional.SkinEnabled)
|
||||
{
|
||||
tasks.Add(Task.Run(() => weaponSync.GetWeaponPaintsFromDatabase(playerInfo)));
|
||||
_ = Task.Run(async () => await weaponSync.GetWeaponPaintsFromDatabase(playerInfo));
|
||||
}
|
||||
if (Config.Additional.KnifeEnabled)
|
||||
{
|
||||
tasks.Add(Task.Run(() => weaponSync.GetKnifeFromDatabase(playerInfo)));
|
||||
_ = Task.Run(async () => await weaponSync.GetKnifeFromDatabase(playerInfo));
|
||||
}
|
||||
if (Config.Additional.GloveEnabled)
|
||||
{
|
||||
tasks.Add(Task.Run(() => weaponSync.GetGloveFromDatabase(playerInfo)));
|
||||
_ = Task.Run(async () => await weaponSync.GetGloveFromDatabase(playerInfo));
|
||||
}
|
||||
if (Config.Additional.AgentEnabled)
|
||||
{
|
||||
tasks.Add(Task.Run(() => weaponSync.GetAgentFromDatabase(playerInfo)));
|
||||
_ = Task.Run(async () => await weaponSync.GetAgentFromDatabase(playerInfo));
|
||||
}
|
||||
|
||||
Task.WaitAll(tasks.ToArray());
|
||||
}
|
||||
catch (AggregateException ex)
|
||||
{
|
||||
// Handle the exception
|
||||
foreach (var innerException in ex.InnerExceptions)
|
||||
if (Config.Additional.MusicEnabled)
|
||||
{
|
||||
Console.WriteLine($"An error occurred for player {player}: {innerException.Message}");
|
||||
_ = Task.Run(async () => await weaponSync.GetMusicFromDatabase(playerInfo));
|
||||
}
|
||||
*/
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return HookResult.Continue;
|
||||
}
|
||||
|
||||
return HookResult.Continue;
|
||||
}
|
||||
@@ -62,22 +65,13 @@ namespace WeaponPaints
|
||||
[GameEventHandler]
|
||||
public HookResult OnPlayerDisconnect(EventPlayerDisconnect @event, GameEventInfo info)
|
||||
{
|
||||
CCSPlayerController player = @event.Userid;
|
||||
CCSPlayerController? player = @event.Userid;
|
||||
|
||||
if (player is null || !player.IsValid || player.IsBot ||
|
||||
player.IsHLTV || player.SteamID.ToString().Length != 17) return HookResult.Continue;
|
||||
if (player is null || !player.IsValid || player.IsBot) return HookResult.Continue;
|
||||
|
||||
PlayerInfo playerInfo = new PlayerInfo
|
||||
{
|
||||
UserId = player.UserId,
|
||||
Slot = player.Slot,
|
||||
Index = (int)player.Index,
|
||||
SteamId = player.SteamID.ToString(),
|
||||
Name = player.PlayerName,
|
||||
IpAddress = player.IpAddress?.Split(":")[0]
|
||||
};
|
||||
g_playersDatabaseIndex.TryRemove(player.Slot, out _);
|
||||
|
||||
if (Config.Additional.SkinEnabled)
|
||||
if (Config.Additional.SkinEnabled)
|
||||
{
|
||||
gPlayerWeaponsInfo.TryRemove(player.Slot, out _);
|
||||
}
|
||||
@@ -93,117 +87,36 @@ namespace WeaponPaints
|
||||
{
|
||||
g_playersAgent.TryRemove(player.Slot, out _);
|
||||
}
|
||||
if (Config.Additional.MusicEnabled)
|
||||
{
|
||||
g_playersMusic.TryRemove(player.Slot, out _);
|
||||
}
|
||||
if (Config.Additional.PinEnabled)
|
||||
{
|
||||
g_playersPin.TryRemove(player.Slot, out _);
|
||||
}
|
||||
|
||||
commandsCooldown.Remove(player.Slot);
|
||||
|
||||
return HookResult.Continue;
|
||||
}
|
||||
|
||||
private void GivePlayerWeaponSkin(CCSPlayerController player, CBasePlayerWeapon weapon)
|
||||
{
|
||||
if (!Config.Additional.SkinEnabled) return;
|
||||
|
||||
if (player is null || weapon is null || !weapon.IsValid || !Utility.IsPlayerValid(player)) return;
|
||||
|
||||
if (!gPlayerWeaponsInfo.ContainsKey(player.Slot)) return;
|
||||
|
||||
bool isKnife = weapon.DesignerName.Contains("knife") || weapon.DesignerName.Contains("bayonet");
|
||||
|
||||
if (isKnife && !g_playersKnife.ContainsKey(player.Slot) || isKnife && g_playersKnife[player.Slot] == "weapon_knife") return;
|
||||
|
||||
int[] newPaints = { 1171, 1170, 1169, 1164, 1162, 1161, 1159, 1175, 1174, 1167, 1165, 1168, 1163, 1160, 1166, 1173 };
|
||||
|
||||
if (isKnife)
|
||||
{
|
||||
var newDefIndex = WeaponDefindex.FirstOrDefault(x => x.Value == g_playersKnife[player.Slot]);
|
||||
if (newDefIndex.Key == 0) return;
|
||||
|
||||
if (weapon.AttributeManager.Item.ItemDefinitionIndex != newDefIndex.Key)
|
||||
{
|
||||
SubclassChange(weapon, (ushort)newDefIndex.Key);
|
||||
}
|
||||
|
||||
weapon.AttributeManager.Item.ItemDefinitionIndex = (ushort)newDefIndex.Key;
|
||||
weapon.AttributeManager.Item.EntityQuality = 3;
|
||||
}
|
||||
|
||||
int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;
|
||||
int fallbackPaintKit = 0;
|
||||
|
||||
if (_config.Additional.GiveRandomSkin &&
|
||||
!gPlayerWeaponsInfo[player.Slot].ContainsKey(weaponDefIndex))
|
||||
{
|
||||
// Random skins
|
||||
weapon.AttributeManager.Item.ItemID = 16384;
|
||||
weapon.AttributeManager.Item.ItemIDLow = 16384 & 0xFFFFFFFF;
|
||||
weapon.AttributeManager.Item.ItemIDHigh = weapon.AttributeManager.Item.ItemIDLow >> 32;
|
||||
weapon.FallbackPaintKit = GetRandomPaint(weaponDefIndex);
|
||||
weapon.FallbackSeed = 0;
|
||||
weapon.FallbackWear = 0.000001f;
|
||||
CAttributeList_SetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, "set item texture prefab", weapon.FallbackPaintKit);
|
||||
|
||||
fallbackPaintKit = weapon.FallbackPaintKit;
|
||||
|
||||
if (fallbackPaintKit == 0)
|
||||
return;
|
||||
|
||||
if (!isKnife)
|
||||
{
|
||||
if (newPaints.Contains(fallbackPaintKit))
|
||||
{
|
||||
UpdatePlayerWeaponMeshGroupMask(player, weapon, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdatePlayerWeaponMeshGroupMask(player, weapon, true);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gPlayerWeaponsInfo[player.Slot].ContainsKey(weaponDefIndex)) return;
|
||||
WeaponInfo weaponInfo = gPlayerWeaponsInfo[player.Slot][weaponDefIndex];
|
||||
//Log($"Apply on {weapon.DesignerName}({weapon.AttributeManager.Item.ItemDefinitionIndex}) paint {gPlayerWeaponPaints[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex]} seed {gPlayerWeaponSeed[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex]} wear {gPlayerWeaponWear[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex]}");
|
||||
weapon.AttributeManager.Item.ItemID = 16384;
|
||||
weapon.AttributeManager.Item.ItemIDLow = 16384 & 0xFFFFFFFF;
|
||||
weapon.AttributeManager.Item.ItemIDHigh = weapon.AttributeManager.Item.ItemIDLow >> 32;
|
||||
weapon.FallbackPaintKit = weaponInfo.Paint;
|
||||
weapon.FallbackSeed = weaponInfo.Seed;
|
||||
weapon.FallbackWear = weaponInfo.Wear;
|
||||
CAttributeList_SetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, "set item texture prefab", weapon.FallbackPaintKit);
|
||||
|
||||
fallbackPaintKit = weapon.FallbackPaintKit;
|
||||
|
||||
if (fallbackPaintKit == 0)
|
||||
return;
|
||||
|
||||
if (!isKnife)
|
||||
{
|
||||
if (newPaints.Contains(fallbackPaintKit))
|
||||
{
|
||||
UpdatePlayerWeaponMeshGroupMask(player, weapon, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdatePlayerWeaponMeshGroupMask(player, weapon, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void OnMapStart(string mapName)
|
||||
{
|
||||
if (!Config.Additional.KnifeEnabled && !Config.Additional.SkinEnabled && !Config.Additional.GloveEnabled) return;
|
||||
if (Config.Additional is { KnifeEnabled: false, SkinEnabled: false, GloveEnabled: false }) return;
|
||||
|
||||
if (_database != null)
|
||||
weaponSync = new WeaponSynchronization(_database, Config);
|
||||
|
||||
if (weaponSync != null)
|
||||
Task.Run(async () => await weaponSync.PurgeExpiredUsers());
|
||||
}
|
||||
|
||||
private HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
|
||||
{
|
||||
CCSPlayerController? player = @event.Userid;
|
||||
|
||||
if (player is null || !player.IsValid || !Config.Additional.KnifeEnabled && !Config.Additional.GloveEnabled)
|
||||
if (player is null || !player.IsValid || Config.Additional is { KnifeEnabled: false, GloveEnabled: false })
|
||||
return HookResult.Continue;
|
||||
|
||||
CCSPlayerPawn? pawn = player.PlayerPawn.Value;
|
||||
@@ -213,11 +126,10 @@ namespace WeaponPaints
|
||||
|
||||
g_knifePickupCount[player.Slot] = 0;
|
||||
|
||||
GivePlayerMusicKit(player);
|
||||
GivePlayerAgent(player);
|
||||
Server.NextFrame(() =>
|
||||
{
|
||||
RefreshGloves(player);
|
||||
});
|
||||
GivePlayerGloves(player);
|
||||
GivePlayerPin(player);
|
||||
|
||||
return HookResult.Continue;
|
||||
}
|
||||
@@ -231,33 +143,29 @@ namespace WeaponPaints
|
||||
|
||||
private HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info)
|
||||
{
|
||||
/*
|
||||
NativeAPI.IssueServerCommand("mp_t_default_melee \"\"");
|
||||
NativeAPI.IssueServerCommand("mp_ct_default_melee \"\"");
|
||||
NativeAPI.IssueServerCommand("mp_equipment_reset_rounds 0");
|
||||
*/
|
||||
g_bCommandsAllowed = true;
|
||||
|
||||
return HookResult.Continue;
|
||||
}
|
||||
|
||||
/*
|
||||
public HookResult OnGiveNamedItemPost(DynamicHook hook)
|
||||
{
|
||||
var itemServices = hook.GetParam<CCSPlayer_ItemServices>(0);
|
||||
var weapon = hook.GetReturn<CBasePlayerWeapon>(0);
|
||||
if (!weapon.DesignerName.Contains("weapon"))
|
||||
return HookResult.Continue;
|
||||
try
|
||||
{
|
||||
var itemServices = hook.GetParam<CCSPlayer_ItemServices>(0);
|
||||
var weapon = hook.GetReturn<CBasePlayerWeapon>();
|
||||
if (!weapon.DesignerName.Contains("weapon"))
|
||||
return HookResult.Continue;
|
||||
|
||||
var player = GetPlayerFromItemServices(itemServices);
|
||||
if (player != null)
|
||||
GivePlayerWeaponSkin(player, weapon);
|
||||
var player = GetPlayerFromItemServices(itemServices);
|
||||
if (player != null)
|
||||
GivePlayerWeaponSkin(player, weapon);
|
||||
}
|
||||
catch { }
|
||||
|
||||
return HookResult.Continue;
|
||||
}
|
||||
*/
|
||||
|
||||
public void OnEntitySpawned(CEntityInstance entity)
|
||||
public void OnEntityCreated(CEntityInstance entity)
|
||||
{
|
||||
var designerName = entity.DesignerName;
|
||||
|
||||
@@ -266,42 +174,89 @@ namespace WeaponPaints
|
||||
Server.NextFrame(() =>
|
||||
{
|
||||
var weapon = new CBasePlayerWeapon(entity.Handle);
|
||||
if (weapon == null || !weapon.IsValid || weapon.OwnerEntity.Value == null) return;
|
||||
if (!weapon.IsValid) return;
|
||||
|
||||
CCSPlayerController? player = Utilities.GetPlayerFromIndex((int)weapon.OwnerEntity.Value.Index);
|
||||
if (player == null || !player.IsValid || !Utility.IsPlayerValid(player)) return;
|
||||
try
|
||||
{
|
||||
SteamID? _steamid = null;
|
||||
|
||||
GivePlayerWeaponSkin(player, weapon);
|
||||
if (weapon.OriginalOwnerXuidLow > 0)
|
||||
_steamid = new(weapon.OriginalOwnerXuidLow);
|
||||
|
||||
CCSPlayerController? player = null;
|
||||
|
||||
if (_steamid != null && _steamid.IsValid())
|
||||
{
|
||||
player = Utilities.GetPlayers().FirstOrDefault(p => p.IsValid && p.SteamID == _steamid.SteamId64);
|
||||
|
||||
if (player == null)
|
||||
player = Utilities.GetPlayerFromSteamId(weapon.OriginalOwnerXuidLow);
|
||||
}
|
||||
else
|
||||
{
|
||||
CCSWeaponBaseGun gun = weapon.As<CCSWeaponBaseGun>();
|
||||
player = Utilities.GetPlayerFromIndex((int)weapon.OwnerEntity.Index) ?? Utilities.GetPlayerFromIndex((int)gun.OwnerEntity.Value!.Index);
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(player?.PlayerName)) return;
|
||||
if (!Utility.IsPlayerValid(player)) return;
|
||||
|
||||
GivePlayerWeaponSkin(player, weapon);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTick()
|
||||
{
|
||||
if (!Config.Additional.ShowSkinImage) return;
|
||||
|
||||
foreach (var player in Utilities.GetPlayers().Where(p =>
|
||||
p is not null && p.IsValid && p.PlayerPawn != null && p.PlayerPawn.IsValid &&
|
||||
(LifeState_t)p.LifeState == LifeState_t.LIFE_ALIVE && p.SteamID.ToString().Length == 17
|
||||
&& !p.IsBot && !p.IsHLTV && p.Connected == PlayerConnectedState.PlayerConnected
|
||||
p is { IsValid: true, PlayerPawn.IsValid: true } &&
|
||||
(LifeState_t)p.LifeState == LifeState_t.LIFE_ALIVE
|
||||
&& !p.IsBot && p is { Connected: PlayerConnectedState.PlayerConnected }
|
||||
)
|
||||
)
|
||||
{
|
||||
if (Config.Additional.ShowSkinImage && PlayerWeaponImage.TryGetValue(player.Slot, out string? value) && !string.IsNullOrEmpty(value))
|
||||
if (PlayerWeaponImage.TryGetValue(player.Slot, out var value) && !string.IsNullOrEmpty(value))
|
||||
{
|
||||
player.PrintToCenterHtml("<img src='{PATH}'</img>".Replace("{PATH}", value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[GameEventHandler]
|
||||
public HookResult OnItemPickup(EventItemPickup @event, GameEventInfo _)
|
||||
{
|
||||
if (!IsWindows) return HookResult.Continue;
|
||||
|
||||
var player = @event.Userid;
|
||||
if (player != null && player is { IsValid: true, Connected: PlayerConnectedState.PlayerConnected, PawnIsAlive: true, PlayerPawn.IsValid: true })
|
||||
{
|
||||
GiveOnItemPickup(player);
|
||||
}
|
||||
|
||||
return HookResult.Continue;
|
||||
}
|
||||
|
||||
private void RegisterListeners()
|
||||
{
|
||||
RegisterListener<Listeners.OnMapStart>(OnMapStart);
|
||||
|
||||
RegisterEventHandler<EventPlayerSpawn>(OnPlayerSpawn);
|
||||
RegisterEventHandler<EventRoundStart>(OnRoundStart, HookMode.Pre);
|
||||
RegisterEventHandler<EventRoundStart>(OnRoundStart);
|
||||
RegisterEventHandler<EventRoundEnd>(OnRoundEnd);
|
||||
RegisterListener<Listeners.OnEntitySpawned>(OnEntitySpawned);
|
||||
RegisterListener<Listeners.OnTick>(OnTick);
|
||||
//VirtualFunctions.GiveNamedItemFunc.Hook(OnGiveNamedItemPost, HookMode.Post);
|
||||
RegisterListener<Listeners.OnEntityCreated>(OnEntityCreated);
|
||||
|
||||
if (Config.Additional.ShowSkinImage)
|
||||
RegisterListener<Listeners.OnTick>(OnTick);
|
||||
|
||||
if (!IsWindows)
|
||||
VirtualFunctions.GiveNamedItemFunc.Hook(OnGiveNamedItemPost, HookMode.Post);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,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());
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
public class PlayerInfo
|
||||
{
|
||||
public int Index { get; set; }
|
||||
public int Slot { get; set; }
|
||||
public int Slot { get; init; }
|
||||
public int? UserId { get; set; }
|
||||
public string? SteamId { get; set; }
|
||||
public ulong? SteamId { get; init; }
|
||||
public string? Name { get; set; }
|
||||
public string? IpAddress { get; set; }
|
||||
}
|
||||
|
||||
178
Utility.cs
@@ -1,11 +1,9 @@
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Modules.Utils;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Core.Translations;
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using MySqlConnector;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace WeaponPaints
|
||||
{
|
||||
@@ -13,22 +11,6 @@ namespace WeaponPaints
|
||||
{
|
||||
internal static WeaponPaintsConfig? Config { get; set; }
|
||||
|
||||
internal static string BuildDatabaseConnectionString()
|
||||
{
|
||||
if (Config == null) return string.Empty;
|
||||
var builder = new MySqlConnectionStringBuilder
|
||||
{
|
||||
Server = Config.DatabaseHost,
|
||||
UserID = Config.DatabaseUser,
|
||||
Password = Config.DatabasePassword,
|
||||
Database = Config.DatabaseName,
|
||||
Port = (uint)Config.DatabasePort,
|
||||
Pooling = true
|
||||
};
|
||||
|
||||
return builder.ConnectionString;
|
||||
}
|
||||
|
||||
internal static async Task CheckDatabaseTables()
|
||||
{
|
||||
if (WeaponPaints._database is null) return;
|
||||
@@ -40,33 +22,17 @@ namespace WeaponPaints
|
||||
await using var transaction = await connection.BeginTransactionAsync();
|
||||
|
||||
try
|
||||
{
|
||||
string[] createTableQueries = new[]
|
||||
{
|
||||
@"CREATE TABLE IF NOT EXISTS `wp_player_skins` (
|
||||
`steamid` varchar(18) NOT NULL,
|
||||
`weapon_defindex` int(6) NOT NULL,
|
||||
`weapon_paint_id` int(6) NOT NULL,
|
||||
`weapon_wear` float NOT NULL DEFAULT 0.000001,
|
||||
`weapon_seed` int(16) NOT NULL DEFAULT 0
|
||||
) ENGINE=InnoDB",
|
||||
@"CREATE TABLE IF NOT EXISTS `wp_player_knife` (
|
||||
`steamid` varchar(18) NOT NULL,
|
||||
`knife` varchar(64) NOT NULL,
|
||||
UNIQUE (`steamid`)
|
||||
) ENGINE = InnoDB",
|
||||
@"CREATE TABLE IF NOT EXISTS `wp_player_gloves` (
|
||||
`steamid` varchar(18) NOT NULL,
|
||||
`weapon_defindex` int(11) NOT NULL,
|
||||
UNIQUE (`steamid`)
|
||||
) ENGINE=InnoDB",
|
||||
@"CREATE TABLE `wp_player_agents` (
|
||||
`steamid` varchar(18) NOT NULL,
|
||||
`agent_ct` varchar(64) DEFAULT NULL,
|
||||
`agent_t` varchar(64) DEFAULT NULL,
|
||||
UNIQUE KEY `steamid` (`steamid`)
|
||||
) ENGINE=InnoDB"
|
||||
};
|
||||
{
|
||||
var createTableQueries = new[]
|
||||
{
|
||||
"CREATE TABLE IF NOT EXISTS `wp_users` (`id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `steamid` BIGINT UNSIGNED NOT NULL, `last_online` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `unique_steamid` (`steamid`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;",
|
||||
"CREATE TABLE IF NOT EXISTS `wp_users_skins` (`user_id` INT UNSIGNED NOT NULL, `weapon` SMALLINT UNSIGNED NOT NULL, `paint` SMALLINT UNSIGNED NOT NULL, `wear` FLOAT NOT NULL DEFAULT 0.001, `seed` SMALLINT UNSIGNED NOT NULL DEFAULT 0, `nametag` VARCHAR(20) DEFAULT NULL, `stattrack` INT UNSIGNED NOT NULL DEFAULT 0, `stattrack_enabled` SMALLINT NOT NULL DEFAULT 0, `quality` SMALLINT UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (`user_id`,`weapon`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;",
|
||||
"CREATE TABLE IF NOT EXISTS `wp_users_knives` (`user_id` INT UNSIGNED NOT NULL, `knife` SMALLINT UNSIGNED NOT NULL, PRIMARY KEY (`user_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;",
|
||||
"CREATE TABLE IF NOT EXISTS `wp_users_gloves` (`user_id` INT UNSIGNED NOT NULL, `weapon_defindex` SMALLINT UNSIGNED DEFAULT NULL, PRIMARY KEY (`user_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;",
|
||||
"CREATE TABLE IF NOT EXISTS `wp_users_musics` (`user_id` INT UNSIGNED NOT NULL, `music` SMALLINT UNSIGNED DEFAULT NULL, PRIMARY KEY (`user_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;",
|
||||
"CREATE TABLE IF NOT EXISTS `wp_users_agents` (`user_id` INT UNSIGNED NOT NULL,`agent_ct` varchar(64) DEFAULT NULL,`agent_t` varchar(64) DEFAULT NULL, PRIMARY KEY (`user_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;",
|
||||
"CREATE TABLE IF NOT EXISTS `wp_users_pins` (`user_id` INT UNSIGNED NOT NULL, `pin` SMALLINT UNSIGNED DEFAULT NULL, PRIMARY KEY (`user_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;",
|
||||
};
|
||||
|
||||
foreach (var query in createTableQueries)
|
||||
{
|
||||
@@ -89,51 +55,64 @@ namespace WeaponPaints
|
||||
|
||||
internal static bool IsPlayerValid(CCSPlayerController? player)
|
||||
{
|
||||
if (player is null) return false;
|
||||
if (player is null || WeaponPaints.weaponSync is null) return false;
|
||||
|
||||
return (player is not null && player.IsValid && !player.IsBot && !player.IsHLTV && player.UserId.HasValue
|
||||
&& WeaponPaints.weaponSync != null && player.Connected == PlayerConnectedState.PlayerConnected && player.SteamID.ToString().Length == 17);
|
||||
return player is { IsValid: true, IsBot: false, IsHLTV: false, UserId: not null };
|
||||
}
|
||||
|
||||
internal static void LoadSkinsFromFile(string filePath)
|
||||
internal static void LoadSkinsFromFile(string filePath, ILogger logger)
|
||||
{
|
||||
var json = File.ReadAllText(filePath);
|
||||
try
|
||||
{
|
||||
string json = File.ReadAllText(filePath);
|
||||
var deserializedSkins = JsonConvert.DeserializeObject<List<JObject>>(json);
|
||||
WeaponPaints.skinsList = deserializedSkins ?? new List<JObject>();
|
||||
WeaponPaints.skinsList = deserializedSkins ?? [];
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
throw;
|
||||
logger?.LogError("Not found \"skins.json\" file");
|
||||
}
|
||||
}
|
||||
|
||||
internal static void LoadGlovesFromFile(string filePath)
|
||||
internal static void LoadGlovesFromFile(string filePath, ILogger logger)
|
||||
{
|
||||
try
|
||||
{
|
||||
string json = File.ReadAllText(filePath);
|
||||
var json = File.ReadAllText(filePath);
|
||||
var deserializedSkins = JsonConvert.DeserializeObject<List<JObject>>(json);
|
||||
WeaponPaints.glovesList = deserializedSkins ?? new List<JObject>();
|
||||
WeaponPaints.glovesList = deserializedSkins ?? [];
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
throw;
|
||||
logger?.LogError("Not found \"gloves.json\" file");
|
||||
}
|
||||
}
|
||||
|
||||
internal static void LoadAgentsFromFile(string filePath)
|
||||
internal static void LoadAgentsFromFile(string filePath, ILogger logger)
|
||||
{
|
||||
try
|
||||
{
|
||||
string json = File.ReadAllText(filePath);
|
||||
var json = File.ReadAllText(filePath);
|
||||
var deserializedSkins = JsonConvert.DeserializeObject<List<JObject>>(json);
|
||||
WeaponPaints.agentsList = deserializedSkins ?? new List<JObject>();
|
||||
WeaponPaints.agentsList = deserializedSkins ?? [];
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
throw;
|
||||
logger?.LogError("Not found \"agents.json\" file");
|
||||
}
|
||||
}
|
||||
|
||||
internal static void LoadMusicFromFile(string filePath, ILogger logger)
|
||||
{
|
||||
try
|
||||
{
|
||||
var json = File.ReadAllText(filePath);
|
||||
var deserializedSkins = JsonConvert.DeserializeObject<List<JObject>>(json);
|
||||
WeaponPaints.musicList = deserializedSkins ?? [];
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
logger?.LogError("Not found \"music.json\" file");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,69 +126,50 @@ namespace WeaponPaints
|
||||
|
||||
internal static string ReplaceTags(string message)
|
||||
{
|
||||
if (message.Contains('{'))
|
||||
{
|
||||
string modifiedValue = message;
|
||||
if (Config != null)
|
||||
{
|
||||
modifiedValue = modifiedValue.Replace("{WEBSITE}", Config.Website);
|
||||
}
|
||||
foreach (FieldInfo field in typeof(ChatColors).GetFields())
|
||||
{
|
||||
string pattern = $"{{{field.Name}}}";
|
||||
if (message.Contains(pattern, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
modifiedValue = modifiedValue.Replace(pattern, field.GetValue(null)!.ToString(), StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
return modifiedValue;
|
||||
}
|
||||
|
||||
return message;
|
||||
return message.ReplaceColorTags();
|
||||
}
|
||||
|
||||
internal static async Task CheckVersion(string version, ILogger logger)
|
||||
{
|
||||
using (HttpClient client = new HttpClient())
|
||||
using HttpClient client = new();
|
||||
|
||||
try
|
||||
{
|
||||
try
|
||||
var response = await client.GetAsync("https://raw.githubusercontent.com/Nereziel/cs2-WeaponPaints/main/VERSION").ConfigureAwait(false);
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
HttpResponseMessage response = await client.GetAsync("https://raw.githubusercontent.com/Nereziel/cs2-WeaponPaints/main/VERSION").ConfigureAwait(false);
|
||||
var remoteVersion = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
remoteVersion = remoteVersion.Trim();
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
var comparisonResult = string.CompareOrdinal(version, remoteVersion);
|
||||
|
||||
switch (comparisonResult)
|
||||
{
|
||||
string remoteVersion = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
remoteVersion = remoteVersion.Trim();
|
||||
|
||||
int comparisonResult = string.Compare(version, remoteVersion);
|
||||
|
||||
if (comparisonResult < 0)
|
||||
{
|
||||
case < 0:
|
||||
logger.LogWarning("Plugin is outdated! Check https://github.com/Nereziel/cs2-WeaponPaints");
|
||||
}
|
||||
else if (comparisonResult > 0)
|
||||
{
|
||||
break;
|
||||
case > 0:
|
||||
logger.LogInformation("Probably dev version detected");
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
default:
|
||||
logger.LogInformation("Plugin is up to date");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.LogWarning("Failed to check version");
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (HttpRequestException ex)
|
||||
else
|
||||
{
|
||||
logger.LogError(ex, "Failed to connect to the version server.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "An error occurred while checking version.");
|
||||
logger.LogWarning("Failed to check version");
|
||||
}
|
||||
}
|
||||
catch (HttpRequestException ex)
|
||||
{
|
||||
logger.LogError(ex, "Failed to connect to the version server.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "An error occurred while checking version.");
|
||||
}
|
||||
}
|
||||
|
||||
internal static void ShowAd(string moduleVersion)
|
||||
|
||||
805
WeaponAction.cs
@@ -1,354 +1,469 @@
|
||||
using CounterStrikeSharp.API;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
using System.Runtime.InteropServices;
|
||||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Modules.Entities.Constants;
|
||||
using CounterStrikeSharp.API.Modules.Memory;
|
||||
using CounterStrikeSharp.API.Modules.Timers;
|
||||
using CounterStrikeSharp.API.Modules.Utils;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace WeaponPaints
|
||||
namespace WeaponPaints;
|
||||
|
||||
public partial class WeaponPaints
|
||||
{
|
||||
public partial class WeaponPaints
|
||||
{
|
||||
internal static void GiveKnifeToPlayer(CCSPlayerController? player)
|
||||
{
|
||||
if (!_config.Additional.KnifeEnabled || player == null || !player.IsValid) return;
|
||||
|
||||
if (PlayerHasKnife(player)) return;
|
||||
|
||||
string knifeToGive = (CsTeam)player.TeamNum == CsTeam.Terrorist ? "weapon_knife_t" : "weapon_knife";
|
||||
player.GiveNamedItem(CsItem.Knife);
|
||||
}
|
||||
|
||||
internal static bool PlayerHasKnife(CCSPlayerController? player)
|
||||
{
|
||||
if (!_config.Additional.KnifeEnabled) return false;
|
||||
|
||||
if (player == null || !player.IsValid || player.PlayerPawn == null || !player.PlayerPawn.IsValid)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player.PlayerPawn.Value == null || player.PlayerPawn.Value.WeaponServices == null || player.PlayerPawn.Value.ItemServices == null)
|
||||
return false;
|
||||
|
||||
var weapons = player.PlayerPawn.Value.WeaponServices?.MyWeapons;
|
||||
if (weapons == null) return false;
|
||||
foreach (var weapon in weapons)
|
||||
{
|
||||
if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid)
|
||||
{
|
||||
if (weapon.Value.DesignerName.Contains("knife") || weapon.Value.DesignerName.Contains("bayonet"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
internal void RefreshWeapons(CCSPlayerController? player)
|
||||
{
|
||||
if (!g_bCommandsAllowed) return;
|
||||
if (player == null || !player.IsValid || player.PlayerPawn?.Value == null || (LifeState_t)player.LifeState != LifeState_t.LIFE_ALIVE)
|
||||
return;
|
||||
if (player.PlayerPawn.Value.WeaponServices == null || player.PlayerPawn.Value.ItemServices == null)
|
||||
return;
|
||||
|
||||
var weapons = player.PlayerPawn.Value.WeaponServices.MyWeapons;
|
||||
|
||||
if (weapons == null || weapons.Count == 0)
|
||||
return;
|
||||
if (player.Team == CsTeam.None || player.Team == CsTeam.Spectator)
|
||||
return;
|
||||
|
||||
int playerTeam = player.TeamNum;
|
||||
|
||||
Dictionary<string, List<(int, int)>> weaponsWithAmmo = new Dictionary<string, List<(int, int)>>();
|
||||
|
||||
foreach (var weapon in weapons)
|
||||
{
|
||||
if (weapon == null || !weapon.IsValid || weapon.Value == null ||
|
||||
!weapon.Value.IsValid || !weapon.Value.DesignerName.Contains("weapon_"))
|
||||
continue;
|
||||
|
||||
CCSWeaponBaseGun gun = weapon.Value.As<CCSWeaponBaseGun>();
|
||||
|
||||
if (weapon.Value.Entity == null) continue;
|
||||
if (weapon.Value.OwnerEntity == null) continue;
|
||||
if (!weapon.Value.OwnerEntity.IsValid) continue;
|
||||
if (gun == null) continue;
|
||||
if (gun.Entity == null) continue;
|
||||
if (!gun.IsValid) continue;
|
||||
if (!gun.VisibleinPVS) continue;
|
||||
|
||||
try
|
||||
{
|
||||
string? weaponByDefindex = null;
|
||||
|
||||
CCSWeaponBaseVData? weaponData = weapon.Value.As<CCSWeaponBase>().VData;
|
||||
|
||||
if (weaponData == null) continue;
|
||||
|
||||
if (weaponData.GearSlot == gear_slot_t.GEAR_SLOT_RIFLE || weaponData.GearSlot == gear_slot_t.GEAR_SLOT_PISTOL)
|
||||
{
|
||||
if (!WeaponDefindex.TryGetValue(weapon.Value.AttributeManager.Item.ItemDefinitionIndex, out weaponByDefindex))
|
||||
continue;
|
||||
|
||||
int clip1 = weapon.Value.Clip1;
|
||||
int reservedAmmo = weapon.Value.ReserveAmmo[0];
|
||||
|
||||
if (!weaponsWithAmmo.ContainsKey(weaponByDefindex))
|
||||
{
|
||||
weaponsWithAmmo.Add(weaponByDefindex, new List<(int, int)>());
|
||||
}
|
||||
|
||||
weaponsWithAmmo[weaponByDefindex].Add((clip1, reservedAmmo));
|
||||
|
||||
if (gun == null || gun.VData == null) return;
|
||||
|
||||
weapon.Value.Remove();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogWarning(ex.Message);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
player.ExecuteClientCommand("slot 3");
|
||||
player.ExecuteClientCommand("slot 3");
|
||||
|
||||
var weapon = player.PlayerPawn.Value.WeaponServices.ActiveWeapon;
|
||||
if (weapon is null || !weapon.IsValid || weapon.Value == null) return;
|
||||
CCSWeaponBaseVData? weaponData = weapon.Value.As<CCSWeaponBase>().VData;
|
||||
|
||||
if (weapon.Value.DesignerName.Contains("knife") || weaponData?.GearSlot == gear_slot_t.GEAR_SLOT_KNIFE)
|
||||
{
|
||||
CCSWeaponBaseGun gun = weapon.Value.As<CCSWeaponBaseGun>();
|
||||
|
||||
AddTimer(0.3f, () =>
|
||||
{
|
||||
if (player.TeamNum != playerTeam) return;
|
||||
|
||||
player.ExecuteClientCommand("slot 3");
|
||||
gun = weapon.Value.As<CCSWeaponBaseGun>();
|
||||
player.DropActiveWeapon();
|
||||
|
||||
AddTimer(0.7f, () =>
|
||||
{
|
||||
if (player.TeamNum != playerTeam) return;
|
||||
|
||||
if (gun == null || !gun.IsValid || gun.State != CSWeaponState_t.WEAPON_NOT_CARRIED) return;
|
||||
|
||||
gun.Remove();
|
||||
});
|
||||
|
||||
GiveKnifeToPlayer(player);
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogWarning($"Cannot remove knife: {ex.Message}");
|
||||
}
|
||||
|
||||
AddTimer(0.6f, () =>
|
||||
{
|
||||
if (!g_bCommandsAllowed) return;
|
||||
|
||||
foreach (var entry in weaponsWithAmmo)
|
||||
{
|
||||
foreach (var ammo in entry.Value)
|
||||
{
|
||||
var newWeapon = new CBasePlayerWeapon(player.GiveNamedItem(entry.Key));
|
||||
Server.NextFrame(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (newWeapon != null)
|
||||
{
|
||||
newWeapon.Clip1 = ammo.Item1;
|
||||
newWeapon.ReserveAmmo[0] = ammo.Item2;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogWarning("Error setting weapon properties: " + ex.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}, TimerFlags.STOP_ON_MAPCHANGE);
|
||||
}
|
||||
|
||||
private static void RefreshGloves(CCSPlayerController player)
|
||||
{
|
||||
if (!Utility.IsPlayerValid(player) || (LifeState_t)player.LifeState != LifeState_t.LIFE_ALIVE) return;
|
||||
|
||||
CCSPlayerPawn? pawn = player.PlayerPawn.Value;
|
||||
if (pawn == null || !pawn.IsValid || pawn.LifeState != (byte)LifeState_t.LIFE_ALIVE)
|
||||
return;
|
||||
|
||||
string model = pawn.CBodyComponent?.SceneNode?.GetSkeletonInstance()?.ModelState.ModelName ?? string.Empty;
|
||||
if (!string.IsNullOrEmpty(model))
|
||||
{
|
||||
pawn.SetModel("characters/models/tm_jumpsuit/tm_jumpsuit_varianta.vmdl");
|
||||
pawn.SetModel(model);
|
||||
}
|
||||
|
||||
Instance.AddTimer(0.06f, () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (player == null || !player.IsValid)
|
||||
return;
|
||||
|
||||
if (pawn == null || !pawn.IsValid || pawn.LifeState != (byte)LifeState_t.LIFE_ALIVE)
|
||||
return;
|
||||
|
||||
if (g_playersGlove.TryGetValue(player.Slot, out var gloveInfo) && gloveInfo != 0)
|
||||
{
|
||||
CCSPlayerPawn? pawn = player.PlayerPawn.Value;
|
||||
if (pawn == null || !pawn.IsValid || pawn.LifeState != (byte)LifeState_t.LIFE_ALIVE)
|
||||
return;
|
||||
|
||||
WeaponInfo weaponInfo = gPlayerWeaponsInfo[player.Slot][gloveInfo];
|
||||
|
||||
CEconItemView item = pawn.EconGloves;
|
||||
item.ItemDefinitionIndex = gloveInfo;
|
||||
item.ItemIDLow = 16384 & 0xFFFFFFFF;
|
||||
item.ItemIDHigh = 16384;
|
||||
|
||||
CAttributeList_SetOrAddAttributeValueByName.Invoke(item.NetworkedDynamicAttributes.Handle, "set item texture prefab", weaponInfo.Paint);
|
||||
CAttributeList_SetOrAddAttributeValueByName.Invoke(item.NetworkedDynamicAttributes.Handle, "set item texture seed", weaponInfo.Seed);
|
||||
CAttributeList_SetOrAddAttributeValueByName.Invoke(item.NetworkedDynamicAttributes.Handle, "set item texture wear", weaponInfo.Wear);
|
||||
|
||||
item.Initialized = true;
|
||||
|
||||
CBaseModelEntity_SetBodygroup.Invoke(pawn, "default_gloves", 1);
|
||||
}
|
||||
}
|
||||
catch (Exception) { }
|
||||
}, TimerFlags.STOP_ON_MAPCHANGE);
|
||||
}
|
||||
|
||||
private static int GetRandomPaint(int defindex)
|
||||
{
|
||||
if (skinsList == null || skinsList.Count == 0)
|
||||
return 0;
|
||||
|
||||
Random rnd = new Random();
|
||||
|
||||
// Filter weapons by the provided defindex
|
||||
var filteredWeapons = skinsList.Where(w => w["weapon_defindex"]?.ToString() == defindex.ToString()).ToList();
|
||||
|
||||
if (filteredWeapons.Count == 0)
|
||||
return 0;
|
||||
|
||||
var randomWeapon = filteredWeapons[rnd.Next(filteredWeapons.Count)];
|
||||
|
||||
if (int.TryParse(randomWeapon["paint"]?.ToString(), out int paintValue))
|
||||
return paintValue;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void SubclassChange(CBasePlayerWeapon weapon, ushort itemD)
|
||||
{
|
||||
var SubclassChangeFunc = VirtualFunction.Create<nint, string, int>(
|
||||
GameData.GetSignature("ChangeSubclass")
|
||||
);
|
||||
|
||||
SubclassChangeFunc(weapon.Handle, itemD.ToString());
|
||||
}
|
||||
|
||||
public static void UpdateWeaponMeshGroupMask(CBaseEntity weapon, bool isLegacy = false)
|
||||
{
|
||||
if (weapon.CBodyComponent != null && weapon.CBodyComponent.SceneNode != null)
|
||||
{
|
||||
var skeleton = weapon.CBodyComponent.SceneNode.GetSkeletonInstance();
|
||||
if (skeleton != null)
|
||||
{
|
||||
var value = (ulong)(isLegacy ? 2 : 1);
|
||||
|
||||
if (skeleton.ModelState.MeshGroupMask != value)
|
||||
{
|
||||
skeleton.ModelState.MeshGroupMask = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void UpdatePlayerWeaponMeshGroupMask(CCSPlayerController player, CBasePlayerWeapon weapon, bool isLegacy)
|
||||
{
|
||||
UpdateWeaponMeshGroupMask(weapon, isLegacy);
|
||||
|
||||
var viewModel = GetPlayerViewModel(player);
|
||||
if (viewModel != null && viewModel.Weapon.Value != null && viewModel.Weapon.Value.Index == weapon.Index)
|
||||
{
|
||||
UpdateWeaponMeshGroupMask(viewModel, isLegacy);
|
||||
Utilities.SetStateChanged(viewModel, "CBaseEntity", "m_CBodyComponent");
|
||||
}
|
||||
}
|
||||
|
||||
public static void GivePlayerAgent(CCSPlayerController player)
|
||||
{
|
||||
if (!g_playersAgent.ContainsKey(player.Slot)) return;
|
||||
|
||||
try
|
||||
{
|
||||
Server.NextFrame(() =>
|
||||
{
|
||||
string? model = player.TeamNum == 3 ? g_playersAgent[player.Slot].CT : g_playersAgent[player.Slot].T;
|
||||
if (string.IsNullOrEmpty(model)) return;
|
||||
|
||||
player.PlayerPawn.Value!.SetModel(
|
||||
$"characters/models/{model}.vmdl"
|
||||
);
|
||||
});
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public static CCSPlayerController? GetPlayerFromItemServices(CCSPlayer_ItemServices itemServices)
|
||||
{
|
||||
var pawn = itemServices.Pawn.Value;
|
||||
if (pawn == null || !pawn.IsValid || !pawn.Controller.IsValid || pawn.Controller.Value == null) return null;
|
||||
var player = new CCSPlayerController(pawn.Controller.Value.Handle);
|
||||
if (!Utility.IsPlayerValid(player)) return null;
|
||||
return player;
|
||||
}
|
||||
|
||||
private static unsafe CBaseViewModel? GetPlayerViewModel(CCSPlayerController player)
|
||||
{
|
||||
if (player.PlayerPawn.Value == null || player.PlayerPawn.Value.ViewModelServices == null) return null;
|
||||
CCSPlayer_ViewModelServices viewModelServices = new(player.PlayerPawn.Value.ViewModelServices!.Handle);
|
||||
nint ptr = viewModelServices.Handle + Schema.GetSchemaOffset("CCSPlayer_ViewModelServices", "m_hViewModel");
|
||||
var references = MemoryMarshal.CreateSpan(ref ptr, 3);
|
||||
var viewModel = (CHandle<CBaseViewModel>)Activator.CreateInstance(typeof(CHandle<CBaseViewModel>), references[0])!;
|
||||
if (viewModel == null || viewModel.Value == null) return null;
|
||||
return viewModel.Value;
|
||||
}
|
||||
|
||||
public static unsafe T[] GetFixedArray<T>(nint pointer, string @class, string member, int length) where T : CHandle<CBaseViewModel>
|
||||
{
|
||||
nint ptr = pointer + Schema.GetSchemaOffset(@class, member);
|
||||
Span<nint> references = MemoryMarshal.CreateSpan(ref ptr, length);
|
||||
T[] values = new T[length];
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
values[i] = (T)Activator.CreateInstance(typeof(T), references[i])!;
|
||||
}
|
||||
|
||||
return values;
|
||||
}
|
||||
}
|
||||
private void GivePlayerWeaponSkin(CCSPlayerController player, CBasePlayerWeapon weapon)
|
||||
{
|
||||
if (!Config.Additional.SkinEnabled) return;
|
||||
if (!gPlayerWeaponsInfo.TryGetValue(player.Slot, out _)) return;
|
||||
|
||||
var isKnife = weapon.DesignerName.Contains("knife") || weapon.DesignerName.Contains("bayonet");
|
||||
|
||||
if ((isKnife && !g_playersKnife.ContainsKey(player.Slot)) ||
|
||||
(isKnife && g_playersKnife[player.Slot] < 500)) return;
|
||||
|
||||
int[] newPaints =
|
||||
[1171, 1170, 1169, 1164, 1162, 1161, 1159, 1175, 1174, 1167, 1165, 1168, 1163, 1160, 1166, 1173];
|
||||
|
||||
if (isKnife)
|
||||
{
|
||||
//var newDefIndex = WeaponDefindex.FirstOrDefault(x => x.Value == g_playersKnife[player.Slot]);
|
||||
//if (newDefIndex.Key == 0) return;
|
||||
|
||||
if (weapon.AttributeManager.Item.ItemDefinitionIndex != g_playersKnife[player.Slot])
|
||||
SubclassChange(weapon, (ushort)g_playersKnife[player.Slot]);
|
||||
|
||||
weapon.AttributeManager.Item.ItemDefinitionIndex = (ushort)g_playersKnife[player.Slot];
|
||||
weapon.AttributeManager.Item.EntityQuality = 3;
|
||||
}
|
||||
|
||||
UpdatePlayerEconItemId(weapon.AttributeManager.Item);
|
||||
|
||||
int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;
|
||||
var fallbackPaintKit = 0;
|
||||
|
||||
weapon.AttributeManager.Item.AccountID = (uint)player.SteamID;
|
||||
|
||||
if (_config.Additional.GiveRandomSkin &&
|
||||
!gPlayerWeaponsInfo[player.Slot].ContainsKey((ushort)weaponDefIndex))
|
||||
{
|
||||
// Random skins
|
||||
weapon.FallbackPaintKit = GetRandomPaint(weaponDefIndex);
|
||||
weapon.FallbackSeed = 0;
|
||||
weapon.FallbackWear = 0.01f;
|
||||
|
||||
weapon.AttributeManager.Item.NetworkedDynamicAttributes.Attributes.RemoveAll();
|
||||
CAttributeListSetOrAddAttributeValueByName.Invoke(
|
||||
weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, "set item texture prefab",
|
||||
GetRandomPaint(weaponDefIndex));
|
||||
CAttributeListSetOrAddAttributeValueByName.Invoke(
|
||||
weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, "set item texture seed", 0);
|
||||
CAttributeListSetOrAddAttributeValueByName.Invoke(
|
||||
weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, "set item texture wear", 0.01f);
|
||||
|
||||
weapon.AttributeManager.Item.AttributeList.Attributes.RemoveAll();
|
||||
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.AttributeList.Handle,
|
||||
"set item texture prefab", GetRandomPaint(weaponDefIndex));
|
||||
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.AttributeList.Handle,
|
||||
"set item texture seed", 0);
|
||||
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.AttributeList.Handle,
|
||||
"set item texture wear", 0.01f);
|
||||
|
||||
fallbackPaintKit = weapon.FallbackPaintKit;
|
||||
|
||||
if (fallbackPaintKit == 0)
|
||||
return;
|
||||
|
||||
if (isKnife) return;
|
||||
UpdatePlayerWeaponMeshGroupMask(player, weapon, !newPaints.Contains(fallbackPaintKit));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gPlayerWeaponsInfo[player.Slot].TryGetValue((ushort)weaponDefIndex, out var value) || value.Paint == 0) return;
|
||||
|
||||
var weaponInfo = value;
|
||||
//Log($"Apply on {weapon.DesignerName}({weapon.AttributeManager.Item.ItemDefinitionIndex}) paint {gPlayerWeaponPaints[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex]} seed {gPlayerWeaponSeed[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex]} wear {gPlayerWeaponWear[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex]}");
|
||||
weapon.AttributeManager.Item.ItemID = 16384;
|
||||
weapon.AttributeManager.Item.ItemIDLow = 16384 & 0xFFFFFFFF;
|
||||
weapon.AttributeManager.Item.ItemIDHigh = weapon.AttributeManager.Item.ItemIDLow >> 32;
|
||||
weapon.FallbackPaintKit = weaponInfo.Paint;
|
||||
weapon.FallbackSeed = weaponInfo.Seed;
|
||||
weapon.FallbackWear = weaponInfo.Wear;
|
||||
CAttributeListSetOrAddAttributeValueByName.Invoke(
|
||||
weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, "set item texture prefab",
|
||||
weapon.FallbackPaintKit);
|
||||
|
||||
fallbackPaintKit = weapon.FallbackPaintKit;
|
||||
|
||||
if (fallbackPaintKit == 0)
|
||||
return;
|
||||
|
||||
if (isKnife) return;
|
||||
UpdatePlayerWeaponMeshGroupMask(player, weapon, !newPaints.Contains(fallbackPaintKit));
|
||||
}
|
||||
|
||||
private static void GiveKnifeToPlayer(CCSPlayerController? player)
|
||||
{
|
||||
if (!_config.Additional.KnifeEnabled || player == null || !player.IsValid) return;
|
||||
|
||||
if (PlayerHasKnife(player)) return;
|
||||
|
||||
//string knifeToGive = (CsTeam)player.TeamNum == CsTeam.Terrorist ? "weapon_knife_t" : "weapon_knife";
|
||||
player.GiveNamedItem(CsItem.Knife);
|
||||
}
|
||||
|
||||
private static bool PlayerHasKnife(CCSPlayerController? player)
|
||||
{
|
||||
if (!_config.Additional.KnifeEnabled) return false;
|
||||
|
||||
if (player == null || !player.IsValid || !player.PlayerPawn.IsValid) return false;
|
||||
|
||||
if (player.PlayerPawn.Value == null || player.PlayerPawn.Value.WeaponServices == null ||
|
||||
player.PlayerPawn.Value.ItemServices == null)
|
||||
return false;
|
||||
|
||||
var weapons = player.PlayerPawn.Value.WeaponServices?.MyWeapons;
|
||||
if (weapons == null) return false;
|
||||
foreach (var weapon in weapons)
|
||||
{
|
||||
if (!weapon.IsValid || weapon.Value == null || !weapon.Value.IsValid) continue;
|
||||
if (weapon.Value.DesignerName.Contains("knife") || weapon.Value.DesignerName.Contains("bayonet"))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void RefreshWeapons(CCSPlayerController? player)
|
||||
{
|
||||
if (!g_bCommandsAllowed) return;
|
||||
if (player == null || !player.IsValid || player.PlayerPawn?.Value == null ||
|
||||
(LifeState_t)player.LifeState != LifeState_t.LIFE_ALIVE)
|
||||
return;
|
||||
if (player.PlayerPawn.Value.WeaponServices == null || player.PlayerPawn.Value.ItemServices == null)
|
||||
return;
|
||||
|
||||
var weapons = player.PlayerPawn.Value.WeaponServices.MyWeapons;
|
||||
|
||||
if (weapons.Count == 0)
|
||||
return;
|
||||
if (player.Team is CsTeam.None or CsTeam.Spectator)
|
||||
return;
|
||||
|
||||
int playerTeam = player.TeamNum;
|
||||
|
||||
Dictionary<string, List<(int, int)>> weaponsWithAmmo = [];
|
||||
|
||||
foreach (var weapon in weapons)
|
||||
{
|
||||
if (!weapon.IsValid || weapon.Value == null ||
|
||||
!weapon.Value.IsValid || !weapon.Value.DesignerName.Contains("weapon_"))
|
||||
continue;
|
||||
|
||||
var gun = weapon.Value.As<CCSWeaponBaseGun>();
|
||||
|
||||
if (weapon.Value.Entity == null) continue;
|
||||
if (!weapon.Value.OwnerEntity.IsValid) continue;
|
||||
if (gun.Entity == null) continue;
|
||||
if (!gun.IsValid) continue;
|
||||
if (!gun.VisibleinPVS) continue;
|
||||
|
||||
try
|
||||
{
|
||||
var weaponData = weapon.Value.As<CCSWeaponBase>().VData;
|
||||
|
||||
if (weaponData == null) continue;
|
||||
|
||||
if (weaponData.GearSlot == gear_slot_t.GEAR_SLOT_RIFLE ||
|
||||
weaponData.GearSlot == gear_slot_t.GEAR_SLOT_PISTOL)
|
||||
{
|
||||
if (!WeaponDefindex.TryGetValue(weapon.Value.AttributeManager.Item.ItemDefinitionIndex,
|
||||
out var weaponByDefindex))
|
||||
continue;
|
||||
|
||||
var clip1 = weapon.Value.Clip1;
|
||||
var reservedAmmo = weapon.Value.ReserveAmmo[0];
|
||||
|
||||
if (!weaponsWithAmmo.TryGetValue(weaponByDefindex, out var value))
|
||||
{
|
||||
value = [];
|
||||
weaponsWithAmmo.Add(weaponByDefindex, value);
|
||||
}
|
||||
|
||||
value.Add((clip1, reservedAmmo));
|
||||
|
||||
if (gun.VData == null) return;
|
||||
|
||||
weapon.Value.Remove();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogWarning(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
player.ExecuteClientCommand("slot 3");
|
||||
player.ExecuteClientCommand("slot 3");
|
||||
|
||||
var weapon = player.PlayerPawn.Value.WeaponServices.ActiveWeapon;
|
||||
if (!weapon.IsValid || weapon.Value == null) return;
|
||||
var weaponData = weapon.Value.As<CCSWeaponBase>().VData;
|
||||
|
||||
if (weapon.Value.DesignerName.Contains("knife") || weaponData?.GearSlot == gear_slot_t.GEAR_SLOT_KNIFE)
|
||||
{
|
||||
CCSWeaponBaseGun gun;
|
||||
|
||||
AddTimer(0.3f, () =>
|
||||
{
|
||||
if (player.TeamNum != playerTeam) return;
|
||||
|
||||
player.ExecuteClientCommand("slot 3");
|
||||
gun = weapon.Value.As<CCSWeaponBaseGun>();
|
||||
player.DropActiveWeapon();
|
||||
|
||||
AddTimer(0.7f, () =>
|
||||
{
|
||||
if (player.TeamNum != playerTeam) return;
|
||||
|
||||
if (!gun.IsValid || gun.State != CSWeaponState_t.WEAPON_NOT_CARRIED) return;
|
||||
|
||||
gun.Remove();
|
||||
});
|
||||
|
||||
GiveKnifeToPlayer(player);
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogWarning($"Cannot remove knife: {ex.Message}");
|
||||
}
|
||||
|
||||
AddTimer(0.6f, () =>
|
||||
{
|
||||
if (!g_bCommandsAllowed) return;
|
||||
|
||||
foreach (var entry in weaponsWithAmmo)
|
||||
foreach (var ammo in entry.Value)
|
||||
{
|
||||
var newWeapon = new CBasePlayerWeapon(player.GiveNamedItem(entry.Key));
|
||||
Server.NextFrame(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
newWeapon.Clip1 = ammo.Item1;
|
||||
newWeapon.ReserveAmmo[0] = ammo.Item2;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogWarning("Error setting weapon properties: " + ex.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, TimerFlags.STOP_ON_MAPCHANGE);
|
||||
}
|
||||
|
||||
private void GivePlayerGloves(CCSPlayerController player)
|
||||
{
|
||||
if (!Utility.IsPlayerValid(player) || (LifeState_t)player.LifeState != LifeState_t.LIFE_ALIVE) return;
|
||||
|
||||
var pawn = player.PlayerPawn.Value;
|
||||
if (pawn == null || !pawn.IsValid)
|
||||
return;
|
||||
|
||||
var model = pawn.CBodyComponent?.SceneNode?.GetSkeletonInstance()?.ModelState.ModelName ?? string.Empty;
|
||||
if (!string.IsNullOrEmpty(model))
|
||||
{
|
||||
pawn.SetModel("characters/models/tm_jumpsuit/tm_jumpsuit_varianta.vmdl");
|
||||
pawn.SetModel(model);
|
||||
}
|
||||
|
||||
Instance.AddTimer(0.06f, () =>
|
||||
{
|
||||
var item = pawn.EconGloves;
|
||||
try
|
||||
{
|
||||
if (!player.IsValid)
|
||||
return;
|
||||
|
||||
if (!player.PawnIsAlive)
|
||||
return;
|
||||
|
||||
if (!g_playersGlove.TryGetValue(player.Slot, out var gloveInfo) || gloveInfo == 0) return;
|
||||
|
||||
var weaponInfo = gPlayerWeaponsInfo[player.Slot][gloveInfo];
|
||||
|
||||
item.ItemDefinitionIndex = gloveInfo;
|
||||
item.ItemIDLow = 16384 & 0xFFFFFFFF;
|
||||
item.ItemIDHigh = 16384;
|
||||
|
||||
CAttributeListSetOrAddAttributeValueByName.Invoke(item.NetworkedDynamicAttributes.Handle,
|
||||
"set item texture prefab", weaponInfo.Paint);
|
||||
CAttributeListSetOrAddAttributeValueByName.Invoke(item.NetworkedDynamicAttributes.Handle,
|
||||
"set item texture seed", weaponInfo.Seed);
|
||||
CAttributeListSetOrAddAttributeValueByName.Invoke(item.NetworkedDynamicAttributes.Handle,
|
||||
"set item texture wear", weaponInfo.Wear);
|
||||
|
||||
item.Initialized = true;
|
||||
|
||||
SetBodygroup(pawn.Handle, "default_gloves", 1);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}, TimerFlags.STOP_ON_MAPCHANGE);
|
||||
}
|
||||
|
||||
private static int GetRandomPaint(int defindex)
|
||||
{
|
||||
if (skinsList.Count == 0)
|
||||
return 0;
|
||||
|
||||
var rnd = new Random();
|
||||
|
||||
// Filter weapons by the provided defindex
|
||||
var filteredWeapons = skinsList.Where(w => w["weapon_defindex"]?.ToString() == defindex.ToString()).ToList();
|
||||
|
||||
if (filteredWeapons.Count == 0)
|
||||
return 0;
|
||||
|
||||
var randomWeapon = filteredWeapons[rnd.Next(filteredWeapons.Count)];
|
||||
|
||||
return int.TryParse(randomWeapon["paint"]?.ToString(), out var paintValue) ? paintValue : 0;
|
||||
}
|
||||
|
||||
private static void SubclassChange(CBasePlayerWeapon weapon, ushort itemD)
|
||||
{
|
||||
var subclassChangeFunc = VirtualFunction.Create<nint, string, int>(
|
||||
GameData.GetSignature("ChangeSubclass")
|
||||
);
|
||||
|
||||
subclassChangeFunc(weapon.Handle, itemD.ToString());
|
||||
}
|
||||
|
||||
private static void UpdateWeaponMeshGroupMask(CBaseEntity weapon, bool isLegacy = false)
|
||||
{
|
||||
if (weapon.CBodyComponent?.SceneNode == null) return;
|
||||
var skeleton = weapon.CBodyComponent.SceneNode.GetSkeletonInstance();
|
||||
var value = (ulong)(isLegacy ? 2 : 1);
|
||||
|
||||
if (skeleton.ModelState.MeshGroupMask != value) skeleton.ModelState.MeshGroupMask = value;
|
||||
}
|
||||
|
||||
private static void UpdatePlayerWeaponMeshGroupMask(CCSPlayerController player, CBasePlayerWeapon weapon,
|
||||
bool isLegacy)
|
||||
{
|
||||
UpdateWeaponMeshGroupMask(weapon, isLegacy);
|
||||
|
||||
var viewModel = GetPlayerViewModel(player);
|
||||
if (viewModel == null || viewModel.Weapon.Value == null ||
|
||||
viewModel.Weapon.Value.Index != weapon.Index) return;
|
||||
UpdateWeaponMeshGroupMask(viewModel, isLegacy);
|
||||
Utilities.SetStateChanged(viewModel, "CBaseEntity", "m_CBodyComponent");
|
||||
}
|
||||
|
||||
private static void GivePlayerAgent(CCSPlayerController player)
|
||||
{
|
||||
if (!g_playersAgent.TryGetValue(player.Slot, out var value)) return;
|
||||
|
||||
var model = player.TeamNum == 3 ? value.CT : value.T;
|
||||
if (string.IsNullOrEmpty(model)) return;
|
||||
|
||||
if (player.PlayerPawn.Value == null)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
Server.NextFrame(() =>
|
||||
{
|
||||
player.PlayerPawn.Value.SetModel(
|
||||
$"characters/models/{model}.vmdl"
|
||||
);
|
||||
});
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private static void GivePlayerMusicKit(CCSPlayerController player)
|
||||
{
|
||||
if (!g_playersMusic.TryGetValue(player.Slot, out var value)) return;
|
||||
if (player.InventoryServices == null) return;
|
||||
|
||||
player.InventoryServices.MusicID = value;
|
||||
Utilities.SetStateChanged(player, "CCSPlayerController", "m_pInventoryServices");
|
||||
player.MusicKitID = value;
|
||||
Utilities.SetStateChanged(player, "CCSPlayerController", "m_iMusicKitID");
|
||||
}
|
||||
|
||||
private static void GivePlayerPin(CCSPlayerController player)
|
||||
{
|
||||
if (!g_playersPin.TryGetValue(player.Slot, out var value)) return;
|
||||
if (player.InventoryServices == null) return;
|
||||
|
||||
for (var index = 0; index < player.InventoryServices.Rank.Length; index++)
|
||||
{
|
||||
player.InventoryServices.Rank[index] = index == 5 ? (MedalRank_t)value : MedalRank_t.MEDAL_RANK_NONE;
|
||||
Utilities.SetStateChanged(player, "CCSPlayerController", "m_pInventoryServices");
|
||||
}
|
||||
}
|
||||
|
||||
private void GiveOnItemPickup(CCSPlayerController player)
|
||||
{
|
||||
var pawn = player.PlayerPawn.Value;
|
||||
if (pawn == null) return;
|
||||
|
||||
var myWeapons = pawn.WeaponServices?.MyWeapons;
|
||||
if (myWeapons == null) return;
|
||||
foreach (var handle in myWeapons)
|
||||
{
|
||||
var weapon = handle.Value;
|
||||
if (weapon != null && weapon.DesignerName.Contains("knife")) GivePlayerWeaponSkin(player, weapon);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdatePlayerEconItemId(CEconItemView econItemView)
|
||||
{
|
||||
var itemId = _nextItemId++;
|
||||
econItemView.ItemID = itemId;
|
||||
|
||||
econItemView.ItemIDLow = (uint)itemId & 0xFFFFFFFF;
|
||||
econItemView.ItemIDHigh = (uint)itemId >> 32;
|
||||
}
|
||||
|
||||
private static CCSPlayerController? GetPlayerFromItemServices(CCSPlayer_ItemServices itemServices)
|
||||
{
|
||||
var pawn = itemServices.Pawn.Value;
|
||||
if (!pawn.IsValid || !pawn.Controller.IsValid || pawn.Controller.Value == null) return null;
|
||||
var player = new CCSPlayerController(pawn.Controller.Value.Handle);
|
||||
return !Utility.IsPlayerValid(player) ? null : player;
|
||||
}
|
||||
|
||||
private static CBaseViewModel? GetPlayerViewModel(CCSPlayerController player)
|
||||
{
|
||||
if (player.PlayerPawn.Value == null || player.PlayerPawn.Value.ViewModelServices == null) return null;
|
||||
CCSPlayer_ViewModelServices viewModelServices = new(player.PlayerPawn.Value.ViewModelServices!.Handle);
|
||||
var ptr = viewModelServices.Handle + Schema.GetSchemaOffset("CCSPlayer_ViewModelServices", "m_hViewModel");
|
||||
var references = MemoryMarshal.CreateSpan(ref ptr, 3);
|
||||
var viewModel =
|
||||
(CHandle<CBaseViewModel>)Activator.CreateInstance(typeof(CHandle<CBaseViewModel>), references[0])!;
|
||||
return viewModel.Value == null ? null : viewModel.Value;
|
||||
}
|
||||
|
||||
public static T[] GetFixedArray<T>(nint pointer, string @class, string member, int length)
|
||||
where T : CHandle<CBaseViewModel>
|
||||
{
|
||||
var ptr = pointer + Schema.GetSchemaOffset(@class, member);
|
||||
var references = MemoryMarshal.CreateSpan(ref ptr, length);
|
||||
var values = new T[length];
|
||||
|
||||
for (var i = 0; i < length; i++) values[i] = (T)Activator.CreateInstance(typeof(T), references[i])!;
|
||||
|
||||
return values;
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,12 @@
|
||||
{
|
||||
public class WeaponInfo
|
||||
{
|
||||
public int Paint { get; set; }
|
||||
public int Seed { get; set; } = 0;
|
||||
public ushort Paint { get; set; }
|
||||
public ushort Seed { get; set; } = 0;
|
||||
public float Wear { get; set; } = 0f;
|
||||
}
|
||||
public string? NameTag { get; set; }
|
||||
public ushort Quality { get; set; }
|
||||
public uint StatTrack { get; set; }
|
||||
public bool StatTrackEnabled { get; set; }
|
||||
}
|
||||
}
|
||||
131
WeaponPaints.cs
@@ -7,15 +7,17 @@ using Microsoft.Extensions.Logging;
|
||||
using MySqlConnector;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Runtime.InteropServices;
|
||||
using CounterStrikeSharp.API.Modules.Entities.Constants;
|
||||
|
||||
namespace WeaponPaints;
|
||||
|
||||
[MinimumApiVersion(191)]
|
||||
[MinimumApiVersion(238)]
|
||||
public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
||||
{
|
||||
internal static WeaponPaints Instance { get; private set; } = new();
|
||||
|
||||
internal static readonly Dictionary<string, string> weaponList = new()
|
||||
private static readonly Dictionary<string, string> WeaponList = new()
|
||||
{
|
||||
{"weapon_deagle", "Desert Eagle"},
|
||||
{"weapon_elite", "Dual Berettas"},
|
||||
@@ -75,27 +77,36 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
||||
{ "weapon_knife_kukri", "Kukri Knife" }
|
||||
};
|
||||
|
||||
internal static WeaponPaintsConfig _config = new WeaponPaintsConfig();
|
||||
private static WeaponPaintsConfig _config = new();
|
||||
internal static IStringLocalizer? _localizer;
|
||||
internal static Dictionary<int, int> g_knifePickupCount = new Dictionary<int, int>();
|
||||
internal static ConcurrentDictionary<int, string> g_playersKnife = new ConcurrentDictionary<int, string>();
|
||||
internal static ConcurrentDictionary<int, ushort> g_playersGlove = new ConcurrentDictionary<int, ushort>();
|
||||
internal static ConcurrentDictionary<int, (string? CT, string? T)> g_playersAgent = new ConcurrentDictionary<int, (string?, string?)>();
|
||||
internal static ConcurrentDictionary<int, ConcurrentDictionary<int, WeaponInfo>> gPlayerWeaponsInfo = new ConcurrentDictionary<int, ConcurrentDictionary<int, WeaponInfo>>();
|
||||
internal static List<JObject> skinsList = new List<JObject>();
|
||||
internal static List<JObject> glovesList = new List<JObject>();
|
||||
internal static List<JObject> agentsList = new List<JObject>();
|
||||
internal static WeaponSynchronization? weaponSync;
|
||||
public static bool g_bCommandsAllowed = true;
|
||||
internal Dictionary<int, string> PlayerWeaponImage = new();
|
||||
private static Dictionary<int, int> g_knifePickupCount = new();
|
||||
internal static ConcurrentDictionary<int, ushort> g_playersKnife = new();
|
||||
internal static ConcurrentDictionary<int, ushort> g_playersGlove = new();
|
||||
internal static ConcurrentDictionary<int, ushort> g_playersMusic = new();
|
||||
internal static ConcurrentDictionary<int, ushort> g_playersPin = new();
|
||||
internal static ConcurrentDictionary<int, (string? CT, string? T)> g_playersAgent = new();
|
||||
internal static ConcurrentDictionary<int, ConcurrentDictionary<ushort, WeaponInfo>> gPlayerWeaponsInfo = new();
|
||||
internal static ConcurrentDictionary<int, int> g_playersDatabaseIndex = new();
|
||||
|
||||
internal static Dictionary<int, DateTime> commandsCooldown = new Dictionary<int, DateTime>();
|
||||
internal static List<JObject> skinsList = [];
|
||||
internal static List<JObject> glovesList = [];
|
||||
internal static List<JObject> agentsList = [];
|
||||
internal static List<JObject> musicList = [];
|
||||
internal static WeaponSynchronization? weaponSync;
|
||||
private static bool g_bCommandsAllowed = true;
|
||||
private Dictionary<int, string> PlayerWeaponImage = new();
|
||||
|
||||
private static Dictionary<int, DateTime> commandsCooldown = new();
|
||||
internal static Database? _database;
|
||||
|
||||
internal static MemoryFunctionVoid<nint, string, float> CAttributeList_SetOrAddAttributeValueByName = new(GameData.GetSignature("CAttributeList_SetOrAddAttributeValueByName"));
|
||||
internal static MemoryFunctionVoid<CBaseModelEntity, string, UInt64> CBaseModelEntity_SetBodygroup = new(GameData.GetSignature("CBaseModelEntity_SetBodygroup"));
|
||||
private static readonly MemoryFunctionVoid<nint, string, float> CAttributeListSetOrAddAttributeValueByName = new(GameData.GetSignature("CAttributeList_SetOrAddAttributeValueByName"));
|
||||
|
||||
public static Dictionary<int, string> WeaponDefindex { get; } = new Dictionary<int, string>
|
||||
private static readonly MemoryFunctionWithReturn<nint, string, int, int> SetBodygroupFunc = new(
|
||||
GameData.GetSignature("CBaseModelEntity_SetBodygroup"));
|
||||
|
||||
private static readonly Func<nint, string, int, int> SetBodygroup = SetBodygroupFunc.Invoke;
|
||||
|
||||
private static Dictionary<int, string> WeaponDefindex { get; } = new Dictionary<int, string>
|
||||
{
|
||||
{ 1, "weapon_deagle" },
|
||||
{ 2, "weapon_elite" },
|
||||
@@ -153,17 +164,15 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
||||
{ 525, "weapon_knife_skeleton" },
|
||||
{ 526, "weapon_knife_kukri" }
|
||||
};
|
||||
private const ulong MinimumCustomItemId = 65578;
|
||||
private ulong _nextItemId = MinimumCustomItemId;
|
||||
public static readonly bool IsWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
|
||||
|
||||
public WeaponPaintsConfig Config { get; set; } = new();
|
||||
public override string ModuleAuthor => "Nereziel & daffyy";
|
||||
public override string ModuleDescription => "Skin, gloves, agents and knife selector, standalone and web-based";
|
||||
public override string ModuleName => "WeaponPaints";
|
||||
public override string ModuleVersion => "2.2c";
|
||||
|
||||
public static WeaponPaintsConfig GetWeaponPaintsConfig()
|
||||
{
|
||||
return _config;
|
||||
}
|
||||
public override string ModuleVersion => "2.5a";
|
||||
|
||||
public override void Load(bool hotReload)
|
||||
{
|
||||
@@ -172,49 +181,40 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
||||
if (hotReload)
|
||||
{
|
||||
OnMapStart(string.Empty);
|
||||
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
|
||||
foreach (var player in Enumerable
|
||||
.OfType<CCSPlayerController>(Utilities.GetPlayers().TakeWhile(player => weaponSync != null))
|
||||
.Where(player => player.IsValid &&
|
||||
!string.IsNullOrEmpty(player.IpAddress) && player is
|
||||
{ IsBot: false, Connected: PlayerConnectedState.PlayerConnected }))
|
||||
{
|
||||
if (weaponSync == null || player is null || !player.IsValid || player.SteamID.ToString().Length != 17 || !player.PawnIsAlive || player.IsBot ||
|
||||
player.IsHLTV || player.Connected != PlayerConnectedState.PlayerConnected)
|
||||
continue;
|
||||
|
||||
g_knifePickupCount[player.Slot] = 0;
|
||||
gPlayerWeaponsInfo.TryRemove(player.Slot, out _);
|
||||
g_playersKnife.TryRemove(player.Slot, out _);
|
||||
g_playersGlove.TryRemove(player.Slot, out _);
|
||||
g_playersAgent.TryRemove(player.Slot, out _);
|
||||
|
||||
PlayerInfo playerInfo = new PlayerInfo
|
||||
PlayerInfo? playerInfo = new PlayerInfo
|
||||
{
|
||||
UserId = player.UserId,
|
||||
Slot = player.Slot,
|
||||
Index = (int)player.Index,
|
||||
SteamId = player?.SteamID.ToString(),
|
||||
SteamId = player?.SteamID,
|
||||
Name = player?.PlayerName,
|
||||
IpAddress = player?.IpAddress?.Split(":")[0]
|
||||
};
|
||||
|
||||
if (Config.Additional.SkinEnabled)
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
Task.Run(() => weaponSync.GetWeaponPaintsFromDatabase(playerInfo));
|
||||
}
|
||||
if (Config.Additional.KnifeEnabled)
|
||||
{
|
||||
Task.Run(() => weaponSync.GetKnifeFromDatabase(playerInfo));
|
||||
}
|
||||
if (Config.Additional.GloveEnabled)
|
||||
{
|
||||
Task.Run(() => weaponSync.GetGloveFromDatabase(playerInfo));
|
||||
}
|
||||
if (Config.Additional.AgentEnabled)
|
||||
{
|
||||
Task.Run(() => weaponSync.GetAgentFromDatabase(playerInfo));
|
||||
}
|
||||
if (weaponSync != null) await weaponSync.GetPlayerDatabaseIndex(playerInfo);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Utility.LoadSkinsFromFile(ModuleDirectory + "/skins.json");
|
||||
Utility.LoadGlovesFromFile(ModuleDirectory + "/gloves.json");
|
||||
Utility.LoadAgentsFromFile(ModuleDirectory + "/agents.json");
|
||||
Utility.LoadSkinsFromFile(ModuleDirectory + "/skins.json", Logger);
|
||||
Utility.LoadGlovesFromFile(ModuleDirectory + "/gloves.json", Logger);
|
||||
Utility.LoadAgentsFromFile(ModuleDirectory + "/agents.json", Logger);
|
||||
Utility.LoadMusicFromFile(ModuleDirectory + "/music.json", Logger);
|
||||
|
||||
if (Config.Additional.KnifeEnabled)
|
||||
SetupKnifeMenu();
|
||||
@@ -224,6 +224,8 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
||||
SetupGlovesMenu();
|
||||
if (Config.Additional.AgentEnabled)
|
||||
SetupAgentsMenu();
|
||||
if (Config.Additional.MusicEnabled)
|
||||
SetupMusicMenu();
|
||||
|
||||
RegisterListeners();
|
||||
RegisterCommands();
|
||||
@@ -231,23 +233,32 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
||||
|
||||
public void OnConfigParsed(WeaponPaintsConfig config)
|
||||
{
|
||||
if (config.DatabaseHost.Length < 1 || config.DatabaseName.Length < 1 || config.DatabaseUser.Length < 1)
|
||||
if (config.DatabaseCredentials.DatabaseHost.Length < 1 || config.DatabaseCredentials.DatabaseName.Length < 1 || config.DatabaseCredentials.DatabaseUser.Length < 1)
|
||||
{
|
||||
Logger.LogError("You need to setup Database credentials in config!");
|
||||
throw new Exception("[WeaponPaints] You need to setup Database credentials in config!");
|
||||
Logger.LogError("You need to setup Database credentials in \"configs/plugins/WeaponPaints/WeaponPaints.json\"!");
|
||||
Unload(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!File.Exists(Path.GetDirectoryName(Path.GetDirectoryName(ModuleDirectory)) + "/gamedata/weaponpaints.json"))
|
||||
{
|
||||
Logger.LogError("You need to upload \"weaponpaints.json\" to \"gamedata directory\"!");
|
||||
Unload(false);
|
||||
return;
|
||||
}
|
||||
|
||||
var builder = new MySqlConnectionStringBuilder
|
||||
{
|
||||
Server = config.DatabaseHost,
|
||||
UserID = config.DatabaseUser,
|
||||
Password = config.DatabasePassword,
|
||||
Database = config.DatabaseName,
|
||||
Port = (uint)config.DatabasePort,
|
||||
Pooling = true
|
||||
Server = config.DatabaseCredentials.DatabaseHost,
|
||||
UserID = config.DatabaseCredentials.DatabaseUser,
|
||||
Password = config.DatabaseCredentials.DatabasePassword,
|
||||
Database = config.DatabaseCredentials.DatabaseName,
|
||||
Port = (uint)config.DatabaseCredentials.DatabasePort,
|
||||
Pooling = true,
|
||||
MaximumPoolSize = 640,
|
||||
};
|
||||
|
||||
_database = new(builder.ConnectionString);
|
||||
_database = new Database(builder.ConnectionString);
|
||||
|
||||
_ = Utility.CheckDatabaseTables();
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
@@ -9,9 +9,9 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.193" />
|
||||
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.233" />
|
||||
<PackageReference Include="Dapper" Version="2.1.35" />
|
||||
<PackageReference Include="MySqlConnector" Version="2.3.5" />
|
||||
<PackageReference Include="MySqlConnector" Version="2.3.7" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -1,232 +1,401 @@
|
||||
using Dapper;
|
||||
using System.Collections.Concurrent;
|
||||
using Dapper;
|
||||
using MySqlConnector;
|
||||
|
||||
namespace WeaponPaints
|
||||
namespace WeaponPaints;
|
||||
|
||||
internal class WeaponSynchronization
|
||||
{
|
||||
internal class WeaponSynchronization
|
||||
{
|
||||
private readonly WeaponPaintsConfig _config;
|
||||
private readonly Database _database;
|
||||
private readonly WeaponPaintsConfig _config;
|
||||
private readonly Database _database;
|
||||
|
||||
internal WeaponSynchronization(Database database, WeaponPaintsConfig config)
|
||||
{
|
||||
_database = database;
|
||||
_config = config;
|
||||
}
|
||||
internal WeaponSynchronization(Database database, WeaponPaintsConfig config)
|
||||
{
|
||||
_database = database;
|
||||
_config = config;
|
||||
}
|
||||
|
||||
public async Task GetKnifeFromDatabase(PlayerInfo player)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_config.Additional.KnifeEnabled || string.IsNullOrEmpty(player?.SteamId))
|
||||
return;
|
||||
internal async Task GetPlayerDatabaseIndex(PlayerInfo playerInfo)
|
||||
{
|
||||
if (playerInfo.SteamId == null) return;
|
||||
Console.WriteLine("test");
|
||||
try
|
||||
{
|
||||
await using var connection = await _database.GetConnectionAsync();
|
||||
var query = "SELECT `id` FROM `wp_users` WHERE `steamid` = @steamid";
|
||||
var databaseIndex =
|
||||
await connection.QueryFirstOrDefaultAsync<int?>(query, new { steamid = playerInfo.SteamId });
|
||||
|
||||
await using var connection = await _database.GetConnectionAsync();
|
||||
string query = "SELECT `knife` FROM `wp_player_knife` WHERE `steamid` = @steamid";
|
||||
string? playerKnife = await connection.QueryFirstOrDefaultAsync<string>(query, new { steamid = player.SteamId });
|
||||
if (databaseIndex != null)
|
||||
{
|
||||
WeaponPaints.g_playersDatabaseIndex[playerInfo.Slot] = (int)databaseIndex;
|
||||
query = "UPDATE `wp_users` SET `last_online` = @lastUpdate WHERE `id` = @databaseIndex";
|
||||
await connection.ExecuteAsync(query, new
|
||||
{
|
||||
lastUpdate = DateTime.Now,
|
||||
databaseIndex
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("test");
|
||||
const string insertQuery = "INSERT INTO `wp_users` (`steamid`) VALUES (@steamid)";
|
||||
await connection.ExecuteAsync(insertQuery, new { steamid = playerInfo.SteamId });
|
||||
Console.WriteLine("SQL Insert Query: " + insertQuery);
|
||||
databaseIndex =
|
||||
await connection.QueryFirstOrDefaultAsync<int?>(query, new { steamid = playerInfo.SteamId });
|
||||
WeaponPaints.g_playersDatabaseIndex[playerInfo.Slot] = (int)databaseIndex;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(playerKnife))
|
||||
{
|
||||
WeaponPaints.g_playersKnife[player.Slot] = playerKnife;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utility.Log($"An error occurred in GetKnifeFromDatabase: {ex.Message}");
|
||||
}
|
||||
}
|
||||
await GetPlayerData(playerInfo);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utility.Log($"An error occurred in GetPlayerDatabaseIndex: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task GetGloveFromDatabase(PlayerInfo player)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_config.Additional.GloveEnabled || string.IsNullOrEmpty(player?.SteamId))
|
||||
return;
|
||||
internal async Task GetPlayerData(PlayerInfo? player)
|
||||
{
|
||||
try
|
||||
{
|
||||
await using var connection = await _database.GetConnectionAsync();
|
||||
|
||||
if (_config.Additional.KnifeEnabled)
|
||||
GetKnifeFromDatabase(player, connection);
|
||||
if (_config.Additional.GloveEnabled)
|
||||
GetGloveFromDatabase(player, connection);
|
||||
if (_config.Additional.AgentEnabled)
|
||||
GetAgentFromDatabase(player, connection);
|
||||
if (_config.Additional.MusicEnabled)
|
||||
GetMusicFromDatabase(player, connection);
|
||||
if (_config.Additional.SkinEnabled)
|
||||
GetWeaponPaintsFromDatabase(player, connection);
|
||||
if (_config.Additional.PinEnabled)
|
||||
GetPinFromDatabase(player, connection);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Log the exception or handle it appropriately
|
||||
Console.WriteLine($"An error occurred: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
await using var connection = await _database.GetConnectionAsync();
|
||||
string query = "SELECT `weapon_defindex` FROM `wp_player_gloves` WHERE `steamid` = @steamid";
|
||||
ushort? gloveData = await connection.QueryFirstOrDefaultAsync<ushort?>(query, new { steamid = player.SteamId });
|
||||
private void GetKnifeFromDatabase(PlayerInfo? player, MySqlConnection connection)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_config.Additional.KnifeEnabled || string.IsNullOrEmpty(player?.SteamId.ToString()))
|
||||
return;
|
||||
|
||||
if (gloveData != null)
|
||||
{
|
||||
WeaponPaints.g_playersGlove[player.Slot] = gloveData.Value;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utility.Log($"An error occurred in GetGloveFromDatabase: {ex.Message}");
|
||||
}
|
||||
}
|
||||
const string query = "SELECT `knife` FROM `wp_users_knives` WHERE `user_id` = @userId";
|
||||
var playerKnife = connection.QueryFirstOrDefault<int>(query,
|
||||
new { userId = WeaponPaints.g_playersDatabaseIndex[player.Slot] });
|
||||
|
||||
public async Task GetAgentFromDatabase(PlayerInfo player)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_config.Additional.AgentEnabled || string.IsNullOrEmpty(player?.SteamId))
|
||||
return;
|
||||
WeaponPaints.g_playersKnife[player.Slot] = (ushort)playerKnife;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utility.Log($"An error occurred in GetKnifeFromDatabase: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
await using var connection = await _database.GetConnectionAsync();
|
||||
string query = "SELECT `agent_ct`, `agent_t` FROM `wp_player_agents` WHERE `steamid` = @steamid";
|
||||
var agentData = await connection.QueryFirstOrDefaultAsync<(string, string)>(query, new { steamid = player.SteamId });
|
||||
private void GetGloveFromDatabase(PlayerInfo? player, MySqlConnection connection)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_config.Additional.GloveEnabled || string.IsNullOrEmpty(player?.SteamId.ToString()))
|
||||
return;
|
||||
|
||||
if (agentData != default)
|
||||
{
|
||||
string agentCT = agentData.Item1;
|
||||
string agentT = agentData.Item2;
|
||||
const string query = "SELECT `weapon_defindex` FROM `wp_users_gloves` WHERE `user_id` = @userId";
|
||||
var gloveData = connection.QueryFirstOrDefault<ushort?>(query, new { userId = WeaponPaints.g_playersDatabaseIndex[player.Slot] });
|
||||
|
||||
if (!string.IsNullOrEmpty(agentCT) || !string.IsNullOrEmpty(agentT))
|
||||
{
|
||||
WeaponPaints.g_playersAgent[player.Slot] = (
|
||||
agentCT,
|
||||
agentT
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utility.Log($"An error occurred in GetGloveFromDatabase: {ex.Message}");
|
||||
}
|
||||
}
|
||||
if (gloveData != null) WeaponPaints.g_playersGlove[player.Slot] = gloveData.Value;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utility.Log($"An error occurred in GetGloveFromDatabase: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task GetWeaponPaintsFromDatabase(PlayerInfo player)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_config.Additional.SkinEnabled || player == null || string.IsNullOrEmpty(player.SteamId))
|
||||
return;
|
||||
private void GetAgentFromDatabase(PlayerInfo? player, MySqlConnection connection)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_config.Additional.AgentEnabled || string.IsNullOrEmpty(player?.SteamId.ToString()))
|
||||
return;
|
||||
|
||||
await using var connection = await _database.GetConnectionAsync();
|
||||
string query = "SELECT * FROM `wp_player_skins` WHERE `steamid` = @steamid";
|
||||
var playerSkins = await connection.QueryAsync<dynamic>(query, new { steamid = player.SteamId });
|
||||
const string query = "SELECT `agent_ct`, `agent_t` FROM `wp_users_agents` WHERE `user_id` = @userId";
|
||||
var agentData = connection.QueryFirstOrDefault<(string, string)>(query, new { userId = WeaponPaints.g_playersDatabaseIndex[player.Slot] });
|
||||
|
||||
if (playerSkins == null)
|
||||
return;
|
||||
if (agentData == default) return;
|
||||
var agentCT = agentData.Item1;
|
||||
var agentT = agentData.Item2;
|
||||
|
||||
var weaponInfos = new ConcurrentDictionary<int, WeaponInfo>();
|
||||
if (!string.IsNullOrEmpty(agentCT) || !string.IsNullOrEmpty(agentT))
|
||||
WeaponPaints.g_playersAgent[player.Slot] = (
|
||||
agentCT,
|
||||
agentT
|
||||
);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utility.Log($"An error occurred in GetAgentFromDatabase: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var row in playerSkins)
|
||||
{
|
||||
int weaponDefIndex = row?.weapon_defindex ?? 0;
|
||||
int weaponPaintId = row?.weapon_paint_id ?? 0;
|
||||
float weaponWear = row?.weapon_wear ?? 0f;
|
||||
int weaponSeed = row?.weapon_seed ?? 0;
|
||||
private void GetWeaponPaintsFromDatabase(PlayerInfo? player, MySqlConnection connection)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_config.Additional.SkinEnabled || player == null || string.IsNullOrEmpty(player.SteamId.ToString()))
|
||||
return;
|
||||
|
||||
WeaponInfo weaponInfo = new WeaponInfo
|
||||
{
|
||||
Paint = weaponPaintId,
|
||||
Seed = weaponSeed,
|
||||
Wear = weaponWear
|
||||
};
|
||||
var weaponInfos = new ConcurrentDictionary<ushort, WeaponInfo>();
|
||||
|
||||
weaponInfos[weaponDefIndex] = weaponInfo;
|
||||
}
|
||||
|
||||
WeaponPaints.gPlayerWeaponsInfo[player.Slot] = weaponInfos;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utility.Log($"An error occurred in GetWeaponPaintsFromDatabase: {ex.Message}");
|
||||
}
|
||||
}
|
||||
const string query = "SELECT `weapon`, `paint`, `wear`, `seed`, `nametag` FROM `wp_users_skins` WHERE `user_id` = @userId";
|
||||
var playerSkins = connection.Query<dynamic>(query, new { userId = WeaponPaints.g_playersDatabaseIndex[player.Slot] });
|
||||
|
||||
internal async Task SyncKnifeToDatabase(PlayerInfo player, string knife)
|
||||
{
|
||||
if (!_config.Additional.KnifeEnabled || player == null || string.IsNullOrEmpty(player.SteamId) || string.IsNullOrEmpty(knife)) return;
|
||||
foreach (var row in playerSkins)
|
||||
{
|
||||
ushort weaponDefIndex = (ushort)(row.weapon ?? 0);
|
||||
ushort weaponPaintId = (ushort)(row.paint ?? 0);
|
||||
float weaponWear = row.wear ?? 0f;
|
||||
ushort weaponSeed = (ushort)(row.seed ?? 0);
|
||||
string weaponNameTag = row.nametag ?? string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
await using var connection = await _database.GetConnectionAsync();
|
||||
string query = "INSERT INTO `wp_player_knife` (`steamid`, `knife`) VALUES(@steamid, @newKnife) ON DUPLICATE KEY UPDATE `knife` = @newKnife";
|
||||
await connection.ExecuteAsync(query, new { steamid = player.SteamId, newKnife = knife });
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utility.Log($"Error syncing knife to database: {e.Message}");
|
||||
}
|
||||
}
|
||||
var weaponInfo = new WeaponInfo
|
||||
{
|
||||
Paint = weaponPaintId,
|
||||
Seed = weaponSeed,
|
||||
Wear = weaponWear,
|
||||
NameTag = weaponNameTag
|
||||
};
|
||||
|
||||
internal async Task SyncGloveToDatabase(PlayerInfo player, int defindex)
|
||||
{
|
||||
if (!_config.Additional.GloveEnabled || player == null || string.IsNullOrEmpty(player.SteamId)) return;
|
||||
weaponInfos[weaponDefIndex] = weaponInfo;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
await using var connection = await _database.GetConnectionAsync();
|
||||
string query = "INSERT INTO `wp_player_gloves` (`steamid`, `weapon_defindex`) VALUES(@steamid, @weapon_defindex) ON DUPLICATE KEY UPDATE `weapon_defindex` = @weapon_defindex";
|
||||
await connection.ExecuteAsync(query, new { steamid = player.SteamId, weapon_defindex = defindex });
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utility.Log($"Error syncing glove to database: {e.Message}");
|
||||
}
|
||||
}
|
||||
WeaponPaints.gPlayerWeaponsInfo[player.Slot] = weaponInfos;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utility.Log($"An error occurred in GetWeaponPaintsFromDatabase: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
internal async Task SyncAgentToDatabase(PlayerInfo player)
|
||||
{
|
||||
if (!_config.Additional.AgentEnabled || player == null || string.IsNullOrEmpty(player.SteamId)) return;
|
||||
private void GetMusicFromDatabase(PlayerInfo? player, MySqlConnection connection)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_config.Additional.MusicEnabled || string.IsNullOrEmpty(player?.SteamId.ToString()))
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
await using var connection = await _database.GetConnectionAsync();
|
||||
string query = @"
|
||||
INSERT INTO `wp_player_agents` (`steamid`, `agent_ct`, `agent_t`)
|
||||
VALUES(@steamid, @agent_ct, @agent_t)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
`agent_ct` = @agent_ct,
|
||||
`agent_t` = @agent_t";
|
||||
const string query = "SELECT `music` FROM `wp_users_musics` WHERE `user_id` = @userId";
|
||||
var musicData = connection.QueryFirstOrDefault<ushort?>(query, new { userId = WeaponPaints.g_playersDatabaseIndex[player.Slot] });
|
||||
|
||||
await connection.ExecuteAsync(query, new { steamid = player.SteamId, agent_ct = WeaponPaints.g_playersAgent[player.Slot].CT, agent_t = WeaponPaints.g_playersAgent[player.Slot].T });
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utility.Log($"Error syncing agents to database: {e.Message}");
|
||||
}
|
||||
}
|
||||
if (musicData != null) WeaponPaints.g_playersMusic[player.Slot] = musicData.Value;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utility.Log($"An error occurred in GetMusicFromDatabase: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
internal async Task SyncWeaponPaintsToDatabase(PlayerInfo player)
|
||||
{
|
||||
if (player == null || string.IsNullOrEmpty(player.SteamId) || !WeaponPaints.gPlayerWeaponsInfo.TryGetValue(player.Slot, out var weaponsInfo))
|
||||
return;
|
||||
private void GetPinFromDatabase(PlayerInfo? player, MySqlConnection connection)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_config.Additional.PinEnabled || string.IsNullOrEmpty(player?.SteamId.ToString()))
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
await using var connection = await _database.GetConnectionAsync();
|
||||
const string query = "SELECT `pin` FROM `wp_users_pins` WHERE `user_id` = @userId";
|
||||
var pinData = connection.QueryFirstOrDefault<ushort?>(query, new { userId = WeaponPaints.g_playersDatabaseIndex[player.Slot] });
|
||||
|
||||
foreach (var weaponInfoPair in weaponsInfo)
|
||||
{
|
||||
int weaponDefIndex = weaponInfoPair.Key;
|
||||
WeaponInfo weaponInfo = weaponInfoPair.Value;
|
||||
if (pinData != null) WeaponPaints.g_playersPin[player.Slot] = pinData.Value;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utility.Log($"An error occurred in GetPinFromDatabase: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
int paintId = weaponInfo.Paint;
|
||||
float wear = weaponInfo.Wear;
|
||||
int seed = weaponInfo.Seed;
|
||||
internal async Task PurgeExpiredUsers()
|
||||
{
|
||||
try
|
||||
{
|
||||
await using var connection = await _database.GetConnectionAsync();
|
||||
await using var transaction = await connection.BeginTransactionAsync();
|
||||
|
||||
var userIds = await connection.QueryAsync<int>(
|
||||
$"SELECT id FROM wp_users WHERE last_online < NOW() - INTERVAL {_config.Additional.ExpireOlderThan} DAY",
|
||||
transaction: transaction
|
||||
);
|
||||
|
||||
string queryCheckExistence = "SELECT COUNT(*) FROM `wp_player_skins` WHERE `steamid` = @steamid AND `weapon_defindex` = @weaponDefIndex";
|
||||
var ids = string.Join(",", userIds);
|
||||
|
||||
int existingRecordCount = await connection.ExecuteScalarAsync<int>(queryCheckExistence, new { steamid = player.SteamId, weaponDefIndex });
|
||||
string query;
|
||||
|
||||
string query;
|
||||
object parameters;
|
||||
if (existingRecordCount > 0)
|
||||
{
|
||||
query = "UPDATE `wp_player_skins` SET `weapon_paint_id` = @paintId, `weapon_wear` = @wear, `weapon_seed` = @seed WHERE `steamid` = @steamid AND `weapon_defindex` = @weaponDefIndex";
|
||||
parameters = new { steamid = player.SteamId, weaponDefIndex, paintId, wear, seed };
|
||||
}
|
||||
else
|
||||
{
|
||||
query = "INSERT INTO `wp_player_skins` (`steamid`, `weapon_defindex`, `weapon_paint_id`, `weapon_wear`, `weapon_seed`) " +
|
||||
"VALUES (@steamid, @weaponDefIndex, @paintId, @wear, @seed)";
|
||||
parameters = new { steamid = player.SteamId, weaponDefIndex, paintId, wear, seed };
|
||||
}
|
||||
if (userIds.AsList().Count > 0)
|
||||
{
|
||||
// Step 2: Delete related records in other tables using the retrieved IDs
|
||||
query = $"DELETE FROM wp_users_agents WHERE user_id IN ({ids})";
|
||||
await connection.ExecuteAsync(query, transaction: transaction);
|
||||
|
||||
await connection.ExecuteAsync(query, parameters);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utility.Log($"Error syncing weapon paints to database: {e.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
query = $"DELETE FROM wp_users_gloves WHERE user_id IN ({ids})";
|
||||
await connection.ExecuteAsync(query, transaction: transaction);
|
||||
|
||||
query = $"DELETE FROM wp_users_skins WHERE user_id IN ({ids})";
|
||||
await connection.ExecuteAsync(query, transaction: transaction);
|
||||
|
||||
query = $"DELETE FROM wp_users_knives WHERE user_id IN ({ids})";
|
||||
await connection.ExecuteAsync(query, transaction: transaction);
|
||||
|
||||
query = $"DELETE FROM wp_users_musics WHERE user_id IN ({ids})";
|
||||
await connection.ExecuteAsync(query, transaction: transaction);
|
||||
|
||||
query = $"DELETE FROM wp_users_pins WHERE user_id IN ({ids})";
|
||||
await connection.ExecuteAsync(query, transaction: transaction);
|
||||
|
||||
// Step 3: Delete users from wp_users
|
||||
query = $"DELETE FROM wp_users WHERE id IN ({ids})";
|
||||
await connection.ExecuteAsync(query, transaction: transaction);
|
||||
|
||||
// Commit transaction
|
||||
await transaction.CommitAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utility.Log($"An error occurred in GetMusicFromDatabase: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
internal async Task SyncKnifeToDatabase(PlayerInfo player, ushort knife)
|
||||
{
|
||||
if (!_config.Additional.KnifeEnabled || string.IsNullOrEmpty(player.SteamId.ToString())) return;
|
||||
|
||||
const string query =
|
||||
"INSERT INTO `wp_users_knives` (`user_id`, `knife`) VALUES(@userId, @newKnife) ON DUPLICATE KEY UPDATE `knife` = @newKnife";
|
||||
|
||||
try
|
||||
{
|
||||
await using var connection = await _database.GetConnectionAsync();
|
||||
await connection.ExecuteAsync(query, new { userId = WeaponPaints.g_playersDatabaseIndex[player.Slot], newKnife = knife });
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utility.Log($"Error syncing knife to database: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
internal async Task SyncGloveToDatabase(PlayerInfo player, int defindex)
|
||||
{
|
||||
if (!_config.Additional.GloveEnabled || string.IsNullOrEmpty(player.SteamId.ToString())) return;
|
||||
|
||||
try
|
||||
{
|
||||
await using var connection = await _database.GetConnectionAsync();
|
||||
const string query =
|
||||
"INSERT INTO `wp_users_gloves` (`user_id`, `weapon_defindex`) VALUES(@userId, @weapon_defindex) ON DUPLICATE KEY UPDATE `weapon_defindex` = @weapon_defindex";
|
||||
await connection.ExecuteAsync(query, new { userId = WeaponPaints.g_playersDatabaseIndex[player.Slot], weapon_defindex = defindex });
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utility.Log($"Error syncing glove to database: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
internal async Task SyncAgentToDatabase(PlayerInfo player)
|
||||
{
|
||||
if (!_config.Additional.AgentEnabled || string.IsNullOrEmpty(player.SteamId.ToString())) return;
|
||||
|
||||
const string query = """
|
||||
INSERT INTO `wp_users_agents` (`user_id`, `agent_ct`, `agent_t`)
|
||||
VALUES(@userId, @agent_ct, @agent_t)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
`agent_ct` = @agent_ct,
|
||||
`agent_t` = @agent_t
|
||||
""";
|
||||
try
|
||||
{
|
||||
await using var connection = await _database.GetConnectionAsync();
|
||||
|
||||
await connection.ExecuteAsync(query,
|
||||
new
|
||||
{
|
||||
userId = WeaponPaints.g_playersDatabaseIndex[player.Slot], agent_ct = WeaponPaints.g_playersAgent[player.Slot].CT,
|
||||
agent_t = WeaponPaints.g_playersAgent[player.Slot].T
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utility.Log($"Error syncing agents to database: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
internal async Task SyncWeaponPaintsToDatabase(PlayerInfo player)
|
||||
{
|
||||
if (string.IsNullOrEmpty(player.SteamId.ToString()) ||
|
||||
!WeaponPaints.gPlayerWeaponsInfo.TryGetValue(player.Slot, out var weaponsInfo))
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
await using var connection = await _database.GetConnectionAsync();
|
||||
|
||||
foreach (var (weaponDefIndex, weaponInfo) in weaponsInfo)
|
||||
{
|
||||
var paintId = weaponInfo.Paint;
|
||||
var wear = weaponInfo.Wear;
|
||||
var seed = weaponInfo.Seed;
|
||||
|
||||
const string queryCheckExistence =
|
||||
"SELECT COUNT(*) FROM `wp_users_skins` WHERE `user_id` = @userId AND `weapon` = @weaponDefIndex";
|
||||
|
||||
var existingRecordCount = await connection.ExecuteScalarAsync<int>(queryCheckExistence,
|
||||
new { userId = WeaponPaints.g_playersDatabaseIndex[player.Slot], weaponDefIndex });
|
||||
|
||||
string query;
|
||||
object parameters;
|
||||
|
||||
if (existingRecordCount > 0)
|
||||
{
|
||||
query =
|
||||
"UPDATE `wp_users_skins` SET `paint` = @paintId, `wear` = @wear, `seed` = @seed WHERE `user_id` = @userId AND `weapon` = @weaponDefIndex";
|
||||
parameters = new { userId = WeaponPaints.g_playersDatabaseIndex[player.Slot], weaponDefIndex, paintId, wear, seed };
|
||||
}
|
||||
else
|
||||
{
|
||||
query =
|
||||
"INSERT INTO `wp_users_skins` (`user_id`, `weapon`, `paint`, `wear`, `seed`) " +
|
||||
"VALUES (@userId, @weaponDefIndex, @paintId, @wear, @seed)";
|
||||
parameters = new { userId = WeaponPaints.g_playersDatabaseIndex[player.Slot], weaponDefIndex, paintId, wear, seed };
|
||||
}
|
||||
|
||||
await connection.ExecuteAsync(query, parameters);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utility.Log($"Error syncing weapon paints to database: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
internal async Task SyncMusicToDatabase(PlayerInfo player, ushort music)
|
||||
{
|
||||
if (!_config.Additional.MusicEnabled || string.IsNullOrEmpty(player.SteamId.ToString())) return;
|
||||
|
||||
try
|
||||
{
|
||||
await using var connection = await _database.GetConnectionAsync();
|
||||
const string query =
|
||||
"INSERT INTO `wp_users_musics` (`user_id`, `music`) VALUES(@userId, @newMusic) ON DUPLICATE KEY UPDATE `music` = @newMusic";
|
||||
await connection.ExecuteAsync(query, new { userId = WeaponPaints.g_playersDatabaseIndex[player.Slot], newMusic = music });
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utility.Log($"Error syncing music kit to database: {e.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,22 +2,22 @@
|
||||
"ChangeSubclass": {
|
||||
"signatures": {
|
||||
"library": "server",
|
||||
"windows": "\\x48\\x89\\x5C\\x24\\x08\\x57\\x48\\x83\\xEC\\x20\\x48\\x8B\\xDA\\x48\\x8B\\xF9\\xE8\\x2A\\x2A\\x2A\\x2A\\x84\\xC0\\x74\\x2A\\x41\\xB0\\x01",
|
||||
"linux": "\\x55\\x48\\x89\\xE5\\x41\\x57\\x41\\x56\\x41\\x55\\x49\\x89\\xF5\\x41\\x54\\x49\\x89\\xFC\\x53\\x48\\x81\\xEC\\xA8\\x00\\x00\\x00"
|
||||
"windows": "40 57 48 83 EC 20 48 8B F9 41 B0 01",
|
||||
"linux": "55 48 89 E5 41 57 41 56 49 89 FE 41 55 41 54 45 31 E4 53 48 81 EC 98 00 00 00"
|
||||
}
|
||||
},
|
||||
"CAttributeList_SetOrAddAttributeValueByName": {
|
||||
"signatures": {
|
||||
"library": "server",
|
||||
"windows": "\\x40\\x53\\x41\\x56\\x41\\x57\\x48\\x81\\xEC\\x90\\x00\\x00\\x00\\x0F\\x29\\x74\\x24\\x70",
|
||||
"linux": "\\x55\\x48\\x89\\xE5\\x41\\x57\\x41\\x56\\x49\\x89\\xFE\\x41\\x55\\x41\\x54\\x49\\x89\\xF4\\x53\\x48\\x83\\xEC\\x78"
|
||||
"windows": "40 53 41 56 41 57 48 81 EC 90 00 00 00 0F 29 74 24 70",
|
||||
"linux": "55 48 89 E5 41 57 41 56 49 89 FE 41 55 41 54 49 89 F4 53 48 83 EC 78"
|
||||
}
|
||||
},
|
||||
"CBaseModelEntity_SetBodygroup": {
|
||||
"signatures": {
|
||||
"library": "server",
|
||||
"windows": "\\x48\\x89\\x5C\\x24\\x08\\x48\\x89\\x74\\x24\\x10\\x57\\x48\\x83\\xEC\\x20\\x41\\x8B\\xF8\\x48\\x8B\\xF2\\x48\\x8B\\xD9\\xE8\\x2A\\x2A\\x2A\\x2A",
|
||||
"linux": "\\x55\\x48\\x89\\xE5\\x41\\x56\\x49\\x89\\xF6\\x41\\x55\\x41\\x89\\xD5\\x41\\x54\\x49\\x89\\xFC\\x48\\x83\\xEC\\x08"
|
||||
"windows": "48 89 5C 24 08 48 89 74 24 10 57 48 83 EC 20 41 8B F8 48 8B F2 48 8B D9 E8 ? ? ? ?",
|
||||
"linux": "55 48 89 E5 41 56 49 89 F6 41 55 41 89 D5 41 54 49 89 FC 48 83 EC 08"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
"wp_info_knife": "Type {lime}!knife{default} to open knife menu",
|
||||
"wp_info_glove": "Type {lime}!gloves{default} to open gloves menu",
|
||||
"wp_info_agent": "Type {lime}!agents{default} to open agents menu",
|
||||
"wp_info_music": "Type {lime}!music{default} to open music menu",
|
||||
"wp_command_cooldown": "{lightred}You can't refresh weapon paints right now",
|
||||
"wp_command_refresh_done": "{lime}Refreshing weapon paints",
|
||||
"wp_knife_menu_select": "You have chosen {lime}{0}{default} as your knife",
|
||||
@@ -14,6 +15,8 @@
|
||||
"wp_glove_menu_title": "Gloves Menu",
|
||||
"wp_agent_menu_select": "You have chosen {lime}{0}{default} as your agent",
|
||||
"wp_agent_menu_title": "Agents Menu",
|
||||
"wp_music_menu_title": "Music Menu",
|
||||
"wp_music_menu_select": "You have chosen {lime}{0}{default} as your music kit",
|
||||
"wp_skin_menu_weapon_title": "Weapon Menu",
|
||||
"wp_skin_menu_skin_title": "Select skin for {lime}{0}{default}",
|
||||
"wp_skin_menu_select": "You have chosen {lime}{0}{default} as your skin",
|
||||
|
||||
21
lang/lv.json
@@ -1,21 +1,24 @@
|
||||
{
|
||||
"wp_prefix": "{lightblue}[WeaponPaints] {default}",
|
||||
"wp_info_website": "Apmeklējiet {lime}{0}{default}, kur varat mainīt ādas",
|
||||
"wp_info_website": "Apmeklē {lime}{0}{default}, kur varat mainīt ādas",
|
||||
"wp_info_refresh": "Ievadiet {lime}!wp{default}, lai sinhronizētu izvēlētās ādas",
|
||||
"wp_info_knife": "Ievadiet {lime}!knife{default}, lai atvērtu nazis izvēlni",
|
||||
"wp_info_glove": "Ievadiet {lime}!gloves{default}, lai atvērtu cimdi izvēlni",
|
||||
"wp_info_agent": "Ierakstiet {lime}!agents{default}, lai atvērtu aģentu izvēlni",
|
||||
"wp_command_cooldown": "{lightred}Šobrīd jūs nevarat atjaunot ieroču ādas",
|
||||
"wp_command_refresh_done": "{lime}Atjauno ieroču ādas",
|
||||
"wp_info_agent": "Ievadiet {lime}!agents{default}, lai atvērtu aģentu izvēlni",
|
||||
"wp_info_music": "Ievadiet {lime}!music{default}, lai atvērtu mūzikas izvēlni",
|
||||
"wp_command_cooldown": "{lightred}Šobrīd nevarat atsvaidzināt ieroča krāsas",
|
||||
"wp_command_refresh_done": "{lime}Atsvaidzinot ieroča krāsas",
|
||||
"wp_knife_menu_select": "Jūs esat izvēlējies {lime}{0}{default} kā savu nazi",
|
||||
"wp_knife_menu_kill": "",
|
||||
"wp_knife_menu_title": "Nazis Izvēlne",
|
||||
"wp_glove_menu_select": "Jūs esat izvēlējies {lime}{0}{default} kā savus cimdus",
|
||||
"wp_knife_menu_title": "Nazi Izvēlne",
|
||||
"wp_glove_menu_select": "Jūs esat izvēlējies {lime}{0}{default} kā savu cimdu",
|
||||
"wp_glove_menu_title": "Cimdu Izvēlne",
|
||||
"wp_agent_menu_select": "Jūs esat izvēlējušies {lime}{0}{default} kā savu aģentu",
|
||||
"wp_agent_menu_title": "Aģentu izvēlnes",
|
||||
"wp_agent_menu_select": "Jūs esat izvēlējies {lime}{0}{default} kā savu aģentu",
|
||||
"wp_agent_menu_title": "Aģentu Izvēlne",
|
||||
"wp_music_menu_title": "Mūzikas Izvēlne",
|
||||
"wp_music_menu_select": "Jūs esat izvēlējies {lime}{0}{default} kā savu mūzikas komplektu",
|
||||
"wp_skin_menu_weapon_title": "Ieroču Izvēlne",
|
||||
"wp_skin_menu_skin_title": "Izvēlieties ādu {lime}{0}{default}",
|
||||
"wp_skin_menu_skin_title": "Izvēlieties ādu priekš {lime}{0}{default}",
|
||||
"wp_skin_menu_select": "Jūs esat izvēlējies {lime}{0}{default} kā savu ādu",
|
||||
|
||||
"None": "Nav"
|
||||
|
||||
15
lang/pl.json
@@ -3,17 +3,20 @@
|
||||
"wp_info_website": "Odwiedź {lime}{0}{default}, gdzie możesz zmieniać skórki",
|
||||
"wp_info_refresh": "Wpisz {lime}!wp{default}, aby zsynchronizować wybrane skórki",
|
||||
"wp_info_knife": "Wpisz {lime}!knife{default}, aby otworzyć menu noży",
|
||||
"wp_info_glove": "Wpisz {lime}!gloves{default}, aby otworzyć menu rękawiczek",
|
||||
"wp_info_glove": "Wpisz {lime}!gloves{default}, aby otworzyć menu rękawic",
|
||||
"wp_info_agent": "Wpisz {lime}!agents{default}, aby otworzyć menu agentów",
|
||||
"wp_command_cooldown": "{lightred}Nie możesz teraz odświeżyć skórek broni",
|
||||
"wp_command_refresh_done": "{lime}Odświeżanie skórek broni",
|
||||
"wp_info_music": "Wpisz {lime}!music{default}, aby otworzyć menu muzyczne",
|
||||
"wp_command_cooldown": "{lightred}Nie możesz teraz odświeżyć kolorów broni",
|
||||
"wp_command_refresh_done": "{lime}Odświeżanie kolorów broni",
|
||||
"wp_knife_menu_select": "Wybrałeś {lime}{0}{default} jako swój nóż",
|
||||
"wp_knife_menu_kill": "{lime}Wybrane skiny będą ustawione dopiero po ponownym wejściu na serwer lub wpisaniu komendy {orange}!kill",
|
||||
"wp_knife_menu_kill": "",
|
||||
"wp_knife_menu_title": "Menu Noży",
|
||||
"wp_glove_menu_select": "Wybrałeś {lime}{0}{default} jako swoje rękawiczki",
|
||||
"wp_glove_menu_select": "Wybrałeś {lime}{0}{default} jako swoją rękawiczkę",
|
||||
"wp_glove_menu_title": "Menu Rękawiczek",
|
||||
"wp_agent_menu_select": "Wybrałeś {lime}{0}{default} jako swojego agenta",
|
||||
"wp_agent_menu_title": "Menu agentów",
|
||||
"wp_agent_menu_title": "Menu Agentów",
|
||||
"wp_music_menu_title": "Menu Muzyczne",
|
||||
"wp_music_menu_select": "Wybrałeś {lime}{0}{default} jako swój zestaw muzyczny",
|
||||
"wp_skin_menu_weapon_title": "Menu Broni",
|
||||
"wp_skin_menu_skin_title": "Wybierz skórkę dla {lime}{0}{default}",
|
||||
"wp_skin_menu_select": "Wybrałeś {lime}{0}{default} jako swoją skórkę",
|
||||
|
||||
@@ -1,21 +1,24 @@
|
||||
{
|
||||
"wp_prefix": "{lightblue}[WeaponPaints] {default}",
|
||||
"wp_info_website": "Visite {lime}{0}{default}, onde você pode alterar skins",
|
||||
"wp_info_refresh": "Digite {lime}!wp{default} para sincronizar as skins selecionadas",
|
||||
"wp_info_website": "Visite {lime}{0}{default}, onde você pode alterar as skins",
|
||||
"wp_info_refresh": "Digite {lime}!wp{default} para sincronizar as skins escolhidas",
|
||||
"wp_info_knife": "Digite {lime}!knife{default} para abrir o menu de facas",
|
||||
"wp_info_glove": "Digite {lime}!gloves{default} para abrir o menu de luvas",
|
||||
"wp_info_agent": "Digite {lime}!agents{default} para abrir o menu de agentes",
|
||||
"wp_command_cooldown": "{lightred}Você não pode atualizar as skins de arma agora",
|
||||
"wp_command_refresh_done": "{lime}Atualizando as skins de arma",
|
||||
"wp_info_music": "Digite {lime}!music{default} para abrir o menu de música",
|
||||
"wp_command_cooldown": "{lightred}Você não pode atualizar as skins de armas agora",
|
||||
"wp_command_refresh_done": "{lime}Atualizando as skins de armas",
|
||||
"wp_knife_menu_select": "Você escolheu {lime}{0}{default} como sua faca",
|
||||
"wp_knife_menu_kill": "",
|
||||
"wp_knife_menu_title": "Menu de Facas",
|
||||
"wp_glove_menu_select": "Você escolheu {lime}{0}{default} como suas luvas",
|
||||
"wp_glove_menu_select": "Você escolheu {lime}{0}{default} como sua luva",
|
||||
"wp_glove_menu_title": "Menu de Luvas",
|
||||
"wp_agent_menu_select": "Você escolheu {lime}{0}{default} como seu agente",
|
||||
"wp_agent_menu_title": "Menu de Agentes",
|
||||
"wp_music_menu_title": "Menu de Música",
|
||||
"wp_music_menu_select": "Você escolheu {lime}{0}{default} como seu kit de música",
|
||||
"wp_skin_menu_weapon_title": "Menu de Armas",
|
||||
"wp_skin_menu_skin_title": "Selecione uma skin para {lime}{0}{default}",
|
||||
"wp_skin_menu_skin_title": "Selecione a skin para {lime}{0}{default}",
|
||||
"wp_skin_menu_select": "Você escolheu {lime}{0}{default} como sua skin",
|
||||
|
||||
"None": "Nenhum"
|
||||
|
||||
@@ -1,22 +1,25 @@
|
||||
{
|
||||
"wp_prefix": "{lightblue}[WeaponPaints] {default}",
|
||||
"wp_info_website": "Visite {lime}{0}{default}, onde pode alterar skins",
|
||||
"wp_info_refresh": "Digite {lime}!wp{default} para sincronizar as skins selecionadas",
|
||||
"wp_info_website": "Visite {lime}{0}{default}, onde pode alterar as skins",
|
||||
"wp_info_refresh": "Digite {lime}!wp{default} para sincronizar as skins escolhidas",
|
||||
"wp_info_knife": "Digite {lime}!knife{default} para abrir o menu de facas",
|
||||
"wp_info_glove": "Digite {lime}!gloves{default} para abrir o menu de luvas",
|
||||
"wp_info_agent": "Digite {lime}!agents{default} para abrir o menu de agentes",
|
||||
"wp_command_cooldown": "{lightred}Você não pode atualizar as skins de arma agora",
|
||||
"wp_command_refresh_done": "{lime}Atualizando as skins de arma",
|
||||
"wp_knife_menu_select": "Você escolheu {lime}{0}{default} como sua faca",
|
||||
"wp_info_music": "Digite {lime}!music{default} para abrir o menu de música",
|
||||
"wp_command_cooldown": "{lightred}Não pode atualizar as skins de armas de momento",
|
||||
"wp_command_refresh_done": "{lime}Atualizando as skins de armas",
|
||||
"wp_knife_menu_select": "Escolheu {lime}{0}{default} como a sua faca",
|
||||
"wp_knife_menu_kill": "",
|
||||
"wp_knife_menu_title": "Menu de Facas",
|
||||
"wp_glove_menu_select": "Você escolheu {lime}{0}{default} como suas luvas",
|
||||
"wp_glove_menu_select": "Escolheu {lime}{0}{default} como a sua luva",
|
||||
"wp_glove_menu_title": "Menu de Luvas",
|
||||
"wp_agent_menu_select": "Escolheste {lime}{0}{default} como teu agente",
|
||||
"wp_agent_menu_select": "Escolheu {lime}{0}{default} como o seu agente",
|
||||
"wp_agent_menu_title": "Menu de Agentes",
|
||||
"wp_music_menu_title": "Menu de Música",
|
||||
"wp_music_menu_select": "Escolheu {lime}{0}{default} como o seu kit de música",
|
||||
"wp_skin_menu_weapon_title": "Menu de Armas",
|
||||
"wp_skin_menu_skin_title": "Selecione uma skin para {lime}{0}{default}",
|
||||
"wp_skin_menu_select": "Você escolheu {lime}{0}{default} como sua skin",
|
||||
"wp_skin_menu_skin_title": "Selecione a skin para {lime}{0}{default}",
|
||||
"wp_skin_menu_select": "Escolheu {lime}{0}{default} como a sua skin",
|
||||
|
||||
"None": "Nenhum"
|
||||
}
|
||||
11
lang/ru.json
@@ -5,15 +5,18 @@
|
||||
"wp_info_knife": "Введите {lime}!knife{default}, чтобы открыть меню ножей",
|
||||
"wp_info_glove": "Введите {lime}!gloves{default}, чтобы открыть меню перчаток",
|
||||
"wp_info_agent": "Введите {lime}!agents{default}, чтобы открыть меню агентов",
|
||||
"wp_command_cooldown": "{lightred}Вы не можете обновить скины оружия сейчас",
|
||||
"wp_command_refresh_done": "{lime}Обновление скинов оружия",
|
||||
"wp_info_music": "Введите {lime}!music{default}, чтобы открыть меню музыки",
|
||||
"wp_command_cooldown": "{lightred}Вы не можете обновить раскраску оружия сейчас",
|
||||
"wp_command_refresh_done": "{lime}Обновление раскраски оружия",
|
||||
"wp_knife_menu_select": "Вы выбрали {lime}{0}{default} в качестве вашего ножа",
|
||||
"wp_knife_menu_kill": "",
|
||||
"wp_knife_menu_title": "Меню Ножей",
|
||||
"wp_glove_menu_select": "Вы выбрали {lime}{0}{default} в качестве ваших перчаток",
|
||||
"wp_glove_menu_title": "Меню Перчаток",
|
||||
"wp_agent_menu_select": "Вы выбрали {lime}{0}{default} в качестве своего агента",
|
||||
"wp_agent_menu_title": "Меню агентов",
|
||||
"wp_agent_menu_select": "Вы выбрали {lime}{0}{default} в качестве вашего агента",
|
||||
"wp_agent_menu_title": "Меню Агентов",
|
||||
"wp_music_menu_title": "Меню Музыки",
|
||||
"wp_music_menu_select": "Вы выбрали {lime}{0}{default} в качестве вашего музыкального набора",
|
||||
"wp_skin_menu_weapon_title": "Меню Оружия",
|
||||
"wp_skin_menu_skin_title": "Выберите скин для {lime}{0}{default}",
|
||||
"wp_skin_menu_select": "Вы выбрали {lime}{0}{default} в качестве вашего скина",
|
||||
|
||||
23
lang/tr.json
@@ -1,22 +1,25 @@
|
||||
{
|
||||
"wp_prefix": "{lightblue}[WeaponPaints] {default}",
|
||||
"wp_info_website": "Ziyaret edin {lime}{0}{default}, burada skinleri değiştirebilirsiniz",
|
||||
"wp_info_refresh": "Senkronize edilen skinleri görmek için {lime}!wp{default} yazın",
|
||||
"wp_info_website": "Ziyaret edin {lime}{0}{default}, nerede derileri değiştirebilirsiniz",
|
||||
"wp_info_refresh": "Senkronize etmek için {lime}!wp{default} yazın seçilen deriler",
|
||||
"wp_info_knife": "Bıçak menüsünü açmak için {lime}!knife{default} yazın",
|
||||
"wp_info_glove": "Eldiven menüsünü açmak için {lime}!gloves{default} yazın",
|
||||
"wp_info_agent": "Ajanlar menüsünü açmak için {lime}!agents{default} yazın",
|
||||
"wp_command_cooldown": "{lightred}Şu anda silah skinlerini yenileyemezsiniz",
|
||||
"wp_command_refresh_done": "{lime}Silah skinleri yenileniyor",
|
||||
"wp_info_glove": "Handskar menüsünü açmak için {lime}!gloves{default} yazın",
|
||||
"wp_info_agent": "Ajan menüsünü açmak için {lime}!agents{default} yazın",
|
||||
"wp_info_music": "Müzik menüsünü açmak için {lime}!music{default} yazın",
|
||||
"wp_command_cooldown": "{lightred}Şu anda silah boyalarını yenileyemezsiniz",
|
||||
"wp_command_refresh_done": "{lime}Silah boyaları yenileniyor",
|
||||
"wp_knife_menu_select": "{lime}{0}{default} olarak bıçağınızı seçtiniz",
|
||||
"wp_knife_menu_kill": "",
|
||||
"wp_knife_menu_title": "Bıçak Menüsü",
|
||||
"wp_glove_menu_select": "{lime}{0}{default} olarak eldiveninizi seçtiniz",
|
||||
"wp_glove_menu_title": "Eldiven Menüsü",
|
||||
"wp_agent_menu_select": "Ajanınız olarak {lime}{0}{default} seçtiniz",
|
||||
"wp_agent_menu_title": "Ajan Menüsü",
|
||||
"wp_agent_menu_select": "{lime}{0}{default} olarak ajanınızı seçtiniz",
|
||||
"wp_agent_menu_title": "Ajanlar Menüsü",
|
||||
"wp_music_menu_title": "Müzik Menüsü",
|
||||
"wp_music_menu_select": "{lime}{0}{default} olarak müzik setinizi seçtiniz",
|
||||
"wp_skin_menu_weapon_title": "Silah Menüsü",
|
||||
"wp_skin_menu_skin_title": "{lime}{0}{default} için bir skin seçin",
|
||||
"wp_skin_menu_select": "{lime}{0}{default} olarak bir skin seçtiniz",
|
||||
"wp_skin_menu_skin_title": "{lime}{0}{default} için cilt seçin",
|
||||
"wp_skin_menu_select": "{lime}{0}{default} olarak cildinizi seçtiniz",
|
||||
|
||||
"None": "Hiçbiri"
|
||||
}
|
||||
19
lang/ua.json
@@ -4,19 +4,22 @@
|
||||
"wp_info_refresh": "Введіть {lime}!wp{default}, щоб синхронізувати обрані шкури",
|
||||
"wp_info_knife": "Введіть {lime}!knife{default}, щоб відкрити меню ножів",
|
||||
"wp_info_glove": "Введіть {lime}!gloves{default}, щоб відкрити меню рукавичок",
|
||||
"wp_info_agent": "Введіть {lime}!агенти{default}, щоб відкрити меню агентів",
|
||||
"wp_command_cooldown": "{lightred}Наразі ви не можете оновлювати шкіри зброї",
|
||||
"wp_command_refresh_done": "{lime}Оновлення шкірок зброї",
|
||||
"wp_knife_menu_select": "Ви вибрали {lime}{0}{default} як ваш ніж",
|
||||
"wp_info_agent": "Введіть {lime}!agents{default}, щоб відкрити меню агентів",
|
||||
"wp_info_music": "Введіть {lime}!music{default}, щоб відкрити меню музики",
|
||||
"wp_command_cooldown": "{lightred}Ви не можете оновити фарби зброї зараз",
|
||||
"wp_command_refresh_done": "{lime}Оновлення фарби зброї",
|
||||
"wp_knife_menu_select": "Ви обрали {lime}{0}{default} як свій ніж",
|
||||
"wp_knife_menu_kill": "",
|
||||
"wp_knife_menu_title": "Меню Ножів",
|
||||
"wp_glove_menu_select": "Ви вибрали {lime}{0}{default} як ваші рукавички",
|
||||
"wp_glove_menu_select": "Ви обрали {lime}{0}{default} як свої рукавички",
|
||||
"wp_glove_menu_title": "Меню Рукавичок",
|
||||
"wp_agent_menu_select": "Ви обрали {lime}{0}{default} як вашого агента",
|
||||
"wp_agent_menu_title": "Меню агентів",
|
||||
"wp_agent_menu_select": "Ви обрали {lime}{0}{default} як свого агента",
|
||||
"wp_agent_menu_title": "Меню Агентів",
|
||||
"wp_music_menu_title": "Меню Музики",
|
||||
"wp_music_menu_select": "Ви обрали {lime}{0}{default} як свій набір музики",
|
||||
"wp_skin_menu_weapon_title": "Меню Зброї",
|
||||
"wp_skin_menu_skin_title": "Виберіть шкіру для {lime}{0}{default}",
|
||||
"wp_skin_menu_select": "Ви вибрали {lime}{0}{default} як вашу шкіру",
|
||||
"wp_skin_menu_select": "Ви обрали {lime}{0}{default} як свою шкіру",
|
||||
|
||||
"None": "Немає"
|
||||
}
|
||||
@@ -1,22 +1,25 @@
|
||||
{
|
||||
"wp_prefix": "{lightblue}[WeaponPaints] {default}",
|
||||
"wp_info_website": "访问 {lime}{0}{default},您可以更改皮肤",
|
||||
"wp_info_refresh": "输入 {lime}!wp{default} 同步已选择的皮肤",
|
||||
"wp_info_refresh": "输入 {lime}!wp{default} 同步选择的皮肤",
|
||||
"wp_info_knife": "输入 {lime}!knife{default} 打开刀具菜单",
|
||||
"wp_info_glove": "输入 {lime}!gloves{default} 打开手套菜单",
|
||||
"wp_info_agent": "键入 {lime}!agents{default} 打开代理菜单",
|
||||
"wp_command_cooldown": "{lightred}您现在无法刷新武器皮肤",
|
||||
"wp_command_refresh_done": "{lime}刷新武器皮肤",
|
||||
"wp_knife_menu_select": "您已选择 {lime}{0}{default} 作为您的刀具",
|
||||
"wp_info_agent": "输入 {lime}!agents{default} 打开代理菜单",
|
||||
"wp_info_music": "输入 {lime}!music{default} 打开音乐菜单",
|
||||
"wp_command_cooldown": "{lightred}您现在无法刷新武器涂装",
|
||||
"wp_command_refresh_done": "{lime}正在刷新武器涂装",
|
||||
"wp_knife_menu_select": "您选择了 {lime}{0}{default} 作为您的刀具",
|
||||
"wp_knife_menu_kill": "",
|
||||
"wp_knife_menu_title": "刀具菜单",
|
||||
"wp_glove_menu_select": "您已选择 {lime}{0}{default} 作为您的手套",
|
||||
"wp_glove_menu_select": "您选择了 {lime}{0}{default} 作为您的手套",
|
||||
"wp_glove_menu_title": "手套菜单",
|
||||
"wp_agent_menu_select": "您选择了{lime}{0}{default}作为您的代理",
|
||||
"wp_agent_menu_select": "您选择了 {lime}{0}{default} 作为您的代理",
|
||||
"wp_agent_menu_title": "代理菜单",
|
||||
"wp_music_menu_title": "音乐菜单",
|
||||
"wp_music_menu_select": "您选择了 {lime}{0}{default} 作为您的音乐包",
|
||||
"wp_skin_menu_weapon_title": "武器菜单",
|
||||
"wp_skin_menu_skin_title": "为 {lime}{0}{default} 选择皮肤",
|
||||
"wp_skin_menu_select": "您已选择 {lime}{0}{default} 作为您的皮肤",
|
||||
"wp_skin_menu_skin_title": "选择 {lime}{0}{default} 的皮肤",
|
||||
"wp_skin_menu_select": "您选择了 {lime}{0}{default} 作为您的皮肤",
|
||||
|
||||
"None": "无"
|
||||
}
|
||||
@@ -1,29 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* Class DataBase
|
||||
*
|
||||
* This class handles database operations using PDO.
|
||||
*/
|
||||
class DataBase {
|
||||
|
||||
/**
|
||||
* @var PDO The PDO instance for database connection.
|
||||
*/
|
||||
private $PDO;
|
||||
|
||||
/**
|
||||
* Constructor method to initialize the database connection.
|
||||
*/
|
||||
public function __construct() {
|
||||
try {
|
||||
$this->PDO = new PDO("mysql:host=".DB_HOST."; port=".DB_PORT."; dbname=".DB_NAME, DB_USER, DB_PASS, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
|
||||
// Establish a connection to the database using PDO
|
||||
$this->PDO = new PDO(
|
||||
"mysql:host=".DB_HOST.";port=".DB_PORT.";dbname=".DB_NAME,
|
||||
DB_USER,
|
||||
DB_PASS
|
||||
);
|
||||
// Set the connection to use utf8 encoding
|
||||
$this->PDO->exec("SET NAMES utf8");
|
||||
}
|
||||
catch(PDOException $ex)
|
||||
{
|
||||
catch(PDOException $ex) {
|
||||
// Display error message if connection fails
|
||||
echo "<div style='display: flex; flex-direction: column;align-items: center;justify-content: center;text-align: center;'><h2>Problem with database!</h2>";
|
||||
die("<pre style='padding: 10px;text-wrap: balance; border: 2px solid #ed6bd3;background: #252525; color: #ed6bd3; width: 50%;'>" . $ex . "</pre>");
|
||||
}
|
||||
}
|
||||
public function select($query, $bindings = []) {
|
||||
|
||||
/**
|
||||
* Perform a SELECT query on the database.
|
||||
*
|
||||
* @param string $query The SQL query to execute.
|
||||
* @param array $bindings An associative array of parameters and their values.
|
||||
* @return array|false Returns an array of rows as associative arrays or false if no results are found.
|
||||
*/
|
||||
public function select($query, $bindings = array()) {
|
||||
// Prepare and execute the SQL query
|
||||
$STH = $this->PDO->prepare($query);
|
||||
$STH->execute($bindings);
|
||||
|
||||
// Fetch the results as associative arrays
|
||||
$result = $STH->fetchAll(PDO::FETCH_ASSOC);
|
||||
$result ??= false;
|
||||
return $result;
|
||||
if ($result === false) {
|
||||
$result = array(); // Set $result to an empty array if no results found
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function query($query, $bindings = []){
|
||||
/**
|
||||
* Perform a non-query SQL statement on the database.
|
||||
*
|
||||
* @param string $query The SQL query to execute.
|
||||
* @param array $bindings An associative array of parameters and their values.
|
||||
* @return bool Returns true on success or false on failure.
|
||||
*/
|
||||
public function query($query, $bindings = array()) {
|
||||
// Prepare and execute the SQL query
|
||||
$STH = $this->PDO->prepare($query);
|
||||
return $STH->execute($bindings);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
78
website/class/header.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
// Set security headers to enhance security
|
||||
// header("X-Frame-Options: SAMEORIGIN");
|
||||
// header("X-XSS-Protection: 1; mode=block");
|
||||
// header("X-Content-Type-Options: nosniff");
|
||||
// header("Referrer-Policy: no-referrer-when-downgrade");
|
||||
// header("Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net https://code.jquery.com; style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net; img-src 'self' data: https://cdn.jsdelivr.net https://steamcommunity-a.akamaihd.net https://raw.githubusercontent.com;");
|
||||
|
||||
|
||||
// Include necessary classes and files
|
||||
require 'class/config.php';
|
||||
require 'class/database.php';
|
||||
require 'steamauth/steamauth.php';
|
||||
require 'class/utils.php';
|
||||
|
||||
// Create a database instance
|
||||
$db = new DataBase();
|
||||
|
||||
// Check if the user is logged in
|
||||
if (isset($_SESSION['steamid'])) {
|
||||
// Insert or update user's Steam ID in the database
|
||||
$steamid = $_SESSION['steamid'];
|
||||
$db->query("INSERT INTO `wp_users` (`steamid`) VALUES ('{$steamid}') ON DUPLICATE KEY UPDATE `updated_at` = CURRENT_TIMESTAMP");
|
||||
|
||||
// Get user's database index
|
||||
$userInfoQuery = $db->select("SELECT `id` FROM `wp_users` WHERE `steamid` = :steamid", ["steamid" => $steamid]);
|
||||
$_SESSION['userDbIndex'] = $userDbIndex = (int)$userInfoQuery[0]['id'];
|
||||
|
||||
// Get weapons and skins information
|
||||
$weapons = UtilsClass::getWeaponsFromArray();
|
||||
$skins = UtilsClass::skinsFromJson();
|
||||
$gloves = UtilsClass::glovesFromJson();
|
||||
|
||||
// Retrieve user's selected skins and knife
|
||||
$querySelected = $db->select("SELECT `weapon`, `paint`, `wear`, `seed`, `nametag` FROM `wp_users_skins` WHERE `user_id` = :user_id", ["user_id" => $userDbIndex]);
|
||||
$selectedSkins = UtilsClass::getSelectedSkins($querySelected);
|
||||
$selectedKnifeResult = $db->select("SELECT `knife` FROM `wp_users_knives` WHERE `user_id` = :user_id", ["user_id" => $userDbIndex]);
|
||||
$selectedGlovesResult = $db->select("SELECT `weapon_defindex` FROM `wp_users_gloves` WHERE `user_id` = :user_id", ["user_id" => $userDbIndex]);
|
||||
$selectedGloves = !empty($selectedGlovesResult) ? $selectedGlovesResult[0] : $gloves[0][0];
|
||||
|
||||
// Determine user's selected knife or set default knife
|
||||
if (!empty($selectedKnifeResult)) {
|
||||
$selectedKnife = $selectedKnifeResult[0]['knife'];
|
||||
} else {
|
||||
$selectedKnife = "weapon_knife";
|
||||
}
|
||||
$knifes = UtilsClass::getKnifeTypes();
|
||||
|
||||
// Handle form submission
|
||||
if (isset($_POST['forma'])) {
|
||||
$ex = explode("-", $_POST['forma']);
|
||||
|
||||
// Handle knife selection
|
||||
if ($ex[0] == "knife") {
|
||||
$db->query("INSERT INTO `wp_users_knives` (`user_id`, `knife`) VALUES(:user_id, :knife) ON DUPLICATE KEY UPDATE `knife` = :knife", ["user_id" => $userDbIndex, "knife" => $knifes[$ex[1]]['weapon_name']]);
|
||||
} else {
|
||||
// Handle skin selection
|
||||
if (array_key_exists($ex[1], $skins[$ex[0]]) && isset($_POST['wear']) && $_POST['wear'] >= 0.00 && $_POST['wear'] <= 1.00 && isset($_POST['seed'])) {
|
||||
$wear = floatval($_POST['wear']); // wear
|
||||
$seed = intval($_POST['seed']); // seed
|
||||
|
||||
// Check if the skin is already selected and update or insert accordingly
|
||||
if (array_key_exists($ex[0], $selectedSkins)) {
|
||||
$db->query("UPDATE wp_users_skins SET paint = :weapon_paint_id, wear = :weapon_wear, seed = :weapon_seed WHERE user_id = :user_id AND weapon = :weapon_defindex", ["user_id" => $userDbIndex, "weapon_defindex" => $ex[0], "weapon_paint_id" => $ex[1], "weapon_wear" => $wear, "weapon_seed" => $seed]);
|
||||
} else {
|
||||
$db->query("INSERT INTO wp_users_skins (`user_id`, `weapon`, `paint`, `wear`, `seed`) VALUES (:user_id, :weapon_defindex, :weapon_paint_id, :weapon_wear, :weapon_seed)", ["user_id" => $userDbIndex, "weapon_defindex" => $ex[0], "weapon_paint_id" => $ex[1], "weapon_wear" => $wear, "weapon_seed" => $seed]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Redirect to the same page after form submission
|
||||
header("Location: {$_SERVER['PHP_SELF']}");
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,99 +1,158 @@
|
||||
<?php
|
||||
/**
|
||||
* Class UtilsClass
|
||||
*
|
||||
* Provides utility methods for handling skin and weapon data.
|
||||
*/
|
||||
class UtilsClass
|
||||
{
|
||||
public static function skinsFromJson(): array
|
||||
/**
|
||||
* Retrieve skins data from the JSON file.
|
||||
*
|
||||
* @return array An associative array containing skin data.
|
||||
*/
|
||||
public static function skinsFromJson()
|
||||
{
|
||||
$skins = [];
|
||||
$json = json_decode(file_get_contents(__DIR__ . "/../data/skins.json"), true);
|
||||
$skins = array();
|
||||
$jsonFilePath = __DIR__ . "/../data/skins.json";
|
||||
|
||||
foreach ($json as $skin) {
|
||||
$skins[(int) $skin['weapon_defindex']][(int) $skin['paint']] = [
|
||||
'weapon_name' => $skin['weapon_name'],
|
||||
'paint_name' => $skin['paint_name'],
|
||||
'image_url' => $skin['image'],
|
||||
];
|
||||
if (file_exists($jsonFilePath) && is_readable($jsonFilePath)) {
|
||||
$json = json_decode(file_get_contents($jsonFilePath), true);
|
||||
|
||||
foreach ($json as $skin) {
|
||||
$skins[(int) $skin['weapon_defindex']][(int) $skin['paint']] = array(
|
||||
'weapon_name' => $skin['weapon_name'],
|
||||
'paint_name' => $skin['paint_name'],
|
||||
'image_url' => $skin['image'],
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// Handle file not found or unreadable error
|
||||
// You can throw an exception or log an error message
|
||||
}
|
||||
|
||||
return $skins;
|
||||
}
|
||||
/**
|
||||
* Retrieve music data from the JSON file.
|
||||
*
|
||||
* @return array An associative array containing music data.
|
||||
*/
|
||||
public static function musicFromJson()
|
||||
{
|
||||
$music = array();
|
||||
$jsonFilePath = __DIR__ . "/../data/music.json";
|
||||
|
||||
if (file_exists($jsonFilePath) && is_readable($jsonFilePath)) {
|
||||
$json = json_decode(file_get_contents($jsonFilePath), true);
|
||||
|
||||
foreach ($json as $track) {
|
||||
$music[$track['id']] = array(
|
||||
'name' => $track['name'],
|
||||
'image' => $track['image'],
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// Handle file not found or unreadable error
|
||||
// You can throw an exception or log an error message
|
||||
}
|
||||
|
||||
return $music;
|
||||
}
|
||||
public static function glovesFromJson()
|
||||
{
|
||||
$gloves = array();
|
||||
$jsonFilePath = __DIR__ . "/../data/gloves.json";
|
||||
|
||||
if (file_exists($jsonFilePath) && is_readable($jsonFilePath)) {
|
||||
$json = json_decode(file_get_contents($jsonFilePath), true);
|
||||
|
||||
foreach ($json as $glove) {
|
||||
$gloves[$glove['weapon_defindex']][$glove['paint']] = array(
|
||||
'paint_name' => $glove['paint_name'],
|
||||
'image_url' => $glove['image'],
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// Handle file not found or unreadable error
|
||||
// You can throw an exception or log an error message
|
||||
}
|
||||
|
||||
return $gloves;
|
||||
}
|
||||
/**
|
||||
* Retrieve weapons data from the skin data array.
|
||||
*
|
||||
* @return array An associative array containing weapon data.
|
||||
*/
|
||||
public static function getWeaponsFromArray()
|
||||
{
|
||||
$weapons = [];
|
||||
$temp = self::skinsFromJson();
|
||||
$weapons = array();
|
||||
$skinsData = self::skinsFromJson();
|
||||
|
||||
foreach ($temp as $key => $value) {
|
||||
if (key_exists($key, $weapons))
|
||||
continue;
|
||||
|
||||
$weapons[$key] = [
|
||||
foreach ($skinsData as $key => $value) {
|
||||
$weapons[$key] = array(
|
||||
'weapon_name' => $value[0]['weapon_name'],
|
||||
'paint_name' => $value[0]['paint_name'],
|
||||
'image_url' => $value[0]['image_url'],
|
||||
];
|
||||
);
|
||||
}
|
||||
|
||||
return $weapons;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve knife types from the weapon data array.
|
||||
*
|
||||
* @return array An associative array containing knife types data.
|
||||
*/
|
||||
public static function getKnifeTypes()
|
||||
{
|
||||
$knifes = [];
|
||||
$temp = self::getWeaponsFromArray();
|
||||
$knifes = array();
|
||||
$weaponsData = self::getWeaponsFromArray();
|
||||
|
||||
foreach ($temp as $key => $weapon) {
|
||||
if (
|
||||
!in_array($key, [
|
||||
500,
|
||||
503,
|
||||
505,
|
||||
506,
|
||||
507,
|
||||
508,
|
||||
509,
|
||||
512,
|
||||
514,
|
||||
515,
|
||||
516,
|
||||
517,
|
||||
518,
|
||||
519,
|
||||
520,
|
||||
521,
|
||||
522,
|
||||
523,
|
||||
525,
|
||||
526
|
||||
])
|
||||
)
|
||||
continue;
|
||||
$allowedKnifeKeys = array(
|
||||
500, 503, 505, 506, 507, 508, 509, 512, 514, 515,
|
||||
516, 517, 518, 519, 520, 521, 522, 523, 525
|
||||
);
|
||||
|
||||
$knifes[$key] = [
|
||||
'weapon_name' => $weapon['weapon_name'],
|
||||
'paint_name' => rtrim(explode("|", $weapon['paint_name'])[0]),
|
||||
'image_url' => $weapon['image_url'],
|
||||
];
|
||||
$knifes[0] = [
|
||||
'weapon_name' => "weapon_knife",
|
||||
'paint_name' => "Default knife",
|
||||
'image_url' => "https://raw.githubusercontent.com/Nereziel/cs2-WeaponPaints/main/website/img/skins/weapon_knife.png",
|
||||
];
|
||||
foreach ($weaponsData as $key => $weapon) {
|
||||
if (in_array($key, $allowedKnifeKeys)) {
|
||||
$knifes[$key] = array(
|
||||
'weapon_name' => $weapon['weapon_name'],
|
||||
'paint_name' => rtrim(explode("|", $weapon['paint_name'])[0]),
|
||||
'image_url' => $weapon['image_url'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Add default knife
|
||||
$knifes[0] = array(
|
||||
'weapon_name' => "weapon_knife",
|
||||
'paint_name' => "Default knife",
|
||||
'image_url' => "https://raw.githubusercontent.com/Nereziel/cs2-WeaponPaints/main/website/img/skins/weapon_knife.png",
|
||||
);
|
||||
|
||||
ksort($knifes);
|
||||
return $knifes;
|
||||
}
|
||||
|
||||
public static function getSelectedSkins(array $temp)
|
||||
/**
|
||||
* Retrieve selected skins data from the database result.
|
||||
*
|
||||
* @param array $temp An array containing the selected skins data.
|
||||
* @return array An associative array containing selected skins data.
|
||||
*/
|
||||
public static function getSelectedSkins($temp)
|
||||
{
|
||||
$selected = [];
|
||||
$selected = array();
|
||||
|
||||
foreach ($temp as $weapon) {
|
||||
$selected[$weapon['weapon_defindex']] = [
|
||||
'weapon_paint_id' => $weapon['weapon_paint_id'],
|
||||
'weapon_seed' => $weapon['weapon_seed'],
|
||||
'weapon_wear' => $weapon['weapon_wear'],
|
||||
];
|
||||
$selected[$weapon['weapon']] = array(
|
||||
'weapon_paint_id' => $weapon['paint'],
|
||||
'weapon_seed' => $weapon['seed'],
|
||||
'weapon_wear' => $weapon['wear'],
|
||||
);
|
||||
}
|
||||
|
||||
return $selected;
|
||||
|
||||
367
website/data/music.json
Normal file
@@ -0,0 +1,367 @@
|
||||
[
|
||||
{
|
||||
"id": "3",
|
||||
"name": "Music Kit | Daniel Sadowski, Crimson Assault",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-3.png"
|
||||
},
|
||||
{
|
||||
"id": "4",
|
||||
"name": "Music Kit | Noisia, Sharpened",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-4.png"
|
||||
},
|
||||
{
|
||||
"id": "5",
|
||||
"name": "Music Kit | Robert Allaire, Insurgency",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-5.png"
|
||||
},
|
||||
{
|
||||
"id": "6",
|
||||
"name": "Music Kit | Sean Murray, A*D*8",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-6.png"
|
||||
},
|
||||
{
|
||||
"id": "7",
|
||||
"name": "Music Kit | Feed Me, High Noon",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-7.png"
|
||||
},
|
||||
{
|
||||
"id": "8",
|
||||
"name": "Music Kit | Dren, Death's Head Demolition",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-8.png"
|
||||
},
|
||||
{
|
||||
"id": "9",
|
||||
"name": "Music Kit | Austin Wintory, Desert Fire",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-9.png"
|
||||
},
|
||||
{
|
||||
"id": "10",
|
||||
"name": "Music Kit | Sasha, LNOE",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-10.png"
|
||||
},
|
||||
{
|
||||
"id": "11",
|
||||
"name": "Music Kit | Skog, Metal",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-11.png"
|
||||
},
|
||||
{
|
||||
"id": "12",
|
||||
"name": "Music Kit | Midnight Riders, All I Want for Christmas",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-12.png"
|
||||
},
|
||||
{
|
||||
"id": "13",
|
||||
"name": "Music Kit | Matt Lange, IsoRhythm",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-13.png"
|
||||
},
|
||||
{
|
||||
"id": "14",
|
||||
"name": "Music Kit | Mateo Messina, For No Mankind",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-14.png"
|
||||
},
|
||||
{
|
||||
"id": "15",
|
||||
"name": "Music Kit | Various Artists, Hotline Miami",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-15.png"
|
||||
},
|
||||
{
|
||||
"id": "16",
|
||||
"name": "Music Kit | Daniel Sadowski, Total Domination",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-16.png"
|
||||
},
|
||||
{
|
||||
"id": "17",
|
||||
"name": "Music Kit | Damjan Mravunac, The Talos Principle",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-17.png"
|
||||
},
|
||||
{
|
||||
"id": "18",
|
||||
"name": "Music Kit | Proxy, Battlepack",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-18.png"
|
||||
},
|
||||
{
|
||||
"id": "19",
|
||||
"name": "Music Kit | Ki:Theory, MOLOTOV",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-19.png"
|
||||
},
|
||||
{
|
||||
"id": "20",
|
||||
"name": "Music Kit | Troels Folmann, Uber Blasto Phone",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-20.png"
|
||||
},
|
||||
{
|
||||
"id": "21",
|
||||
"name": "Music Kit | Kelly Bailey, Hazardous Environments",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-21.png"
|
||||
},
|
||||
{
|
||||
"id": "22",
|
||||
"name": "Music Kit | Skog, II-Headshot",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-22.png"
|
||||
},
|
||||
{
|
||||
"id": "23",
|
||||
"name": "Music Kit | Daniel Sadowski, The 8-Bit Kit",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-23.png"
|
||||
},
|
||||
{
|
||||
"id": "24",
|
||||
"name": "Music Kit | AWOLNATION, I Am",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-24.png"
|
||||
},
|
||||
{
|
||||
"id": "25",
|
||||
"name": "Music Kit | Mord Fustang, Diamonds",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-25.png"
|
||||
},
|
||||
{
|
||||
"id": "26",
|
||||
"name": "Music Kit | Michael Bross, Invasion!",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-26.png"
|
||||
},
|
||||
{
|
||||
"id": "27",
|
||||
"name": "Music Kit | Ian Hultquist, Lion's Mouth",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-27.png"
|
||||
},
|
||||
{
|
||||
"id": "28",
|
||||
"name": "Music Kit | New Beat Fund, Sponge Fingerz",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-28.png"
|
||||
},
|
||||
{
|
||||
"id": "29",
|
||||
"name": "Music Kit | Beartooth, Disgusting",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-29.png"
|
||||
},
|
||||
{
|
||||
"id": "30",
|
||||
"name": "Music Kit | Lennie Moore, Java Havana Funkaloo",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-30.png"
|
||||
},
|
||||
{
|
||||
"id": "31",
|
||||
"name": "Music Kit | Darude, Moments CS:GO",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-31.png"
|
||||
},
|
||||
{
|
||||
"id": "32",
|
||||
"name": "Music Kit | Beartooth, Aggressive",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-32.png"
|
||||
},
|
||||
{
|
||||
"id": "33",
|
||||
"name": "Music Kit | Blitz Kids, The Good Youth",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-33.png"
|
||||
},
|
||||
{
|
||||
"id": "34",
|
||||
"name": "Music Kit | Hundredth, FREE",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-34.png"
|
||||
},
|
||||
{
|
||||
"id": "35",
|
||||
"name": "Music Kit | Neck Deep, Life's Not Out To Get You",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-35.png"
|
||||
},
|
||||
{
|
||||
"id": "36",
|
||||
"name": "Music Kit | Roam, Backbone",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-36.png"
|
||||
},
|
||||
{
|
||||
"id": "37",
|
||||
"name": "Music Kit | Twin Atlantic, GLA",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-37.png"
|
||||
},
|
||||
{
|
||||
"id": "38",
|
||||
"name": "Music Kit | Skog, III-Arena",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-38.png"
|
||||
},
|
||||
{
|
||||
"id": "39",
|
||||
"name": "Music Kit | The Verkkars, EZ4ENCE",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-39.png"
|
||||
},
|
||||
{
|
||||
"id": "40",
|
||||
"name": "Halo, The Master Chief Collection",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-40.png"
|
||||
},
|
||||
{
|
||||
"id": "41",
|
||||
"name": "Music Kit | Scarlxrd: King, Scar",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-41.png"
|
||||
},
|
||||
{
|
||||
"id": "42",
|
||||
"name": "Half-Life: Alyx, Anti-Citizen",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-42.png"
|
||||
},
|
||||
{
|
||||
"id": "43",
|
||||
"name": "Music Kit | Austin Wintory, Bachram",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-43.png"
|
||||
},
|
||||
{
|
||||
"id": "44",
|
||||
"name": "Music Kit | Dren, Gunman Taco Truck",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-44.png"
|
||||
},
|
||||
{
|
||||
"id": "45",
|
||||
"name": "Music Kit | Daniel Sadowski, Eye of the Dragon",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-45.png"
|
||||
},
|
||||
{
|
||||
"id": "46",
|
||||
"name": "Music Kit | Tree Adams and Ben Bromfield, M.U.D.D. FORCE",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-46.png"
|
||||
},
|
||||
{
|
||||
"id": "47",
|
||||
"name": "Music Kit | Tim Huling, Neo Noir",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-47.png"
|
||||
},
|
||||
{
|
||||
"id": "48",
|
||||
"name": "Music Kit | Sam Marshall, Bodacious",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-48.png"
|
||||
},
|
||||
{
|
||||
"id": "49",
|
||||
"name": "Music Kit | Matt Levine, Drifter",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-49.png"
|
||||
},
|
||||
{
|
||||
"id": "50",
|
||||
"name": "Music Kit | Amon Tobin, All for Dust",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-50.png"
|
||||
},
|
||||
{
|
||||
"id": "51",
|
||||
"name": "Darren Korb, Hades Music Kit",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-51.png"
|
||||
},
|
||||
{
|
||||
"id": "52",
|
||||
"name": "Music Kit | Neck Deep, The Lowlife Pack",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-52.png"
|
||||
},
|
||||
{
|
||||
"id": "53",
|
||||
"name": "Music Kit | Scarlxrd, CHAIN$AW.LXADXUT.",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-53.png"
|
||||
},
|
||||
{
|
||||
"id": "54",
|
||||
"name": "Music Kit | Austin Wintory, Mocha Petal",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-54.png"
|
||||
},
|
||||
{
|
||||
"id": "55",
|
||||
"name": "Music Kit | Chipzel, ~Yellow Magic~",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-55.png"
|
||||
},
|
||||
{
|
||||
"id": "56",
|
||||
"name": "Music Kit | Freaky DNA, Vici",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-56.png"
|
||||
},
|
||||
{
|
||||
"id": "57",
|
||||
"name": "Music Kit | Jesse Harlin, Astro Bellum",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-57.png"
|
||||
},
|
||||
{
|
||||
"id": "58",
|
||||
"name": "Music Kit | Laura Shigihara: Work Hard, Play Hard",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-58.png"
|
||||
},
|
||||
{
|
||||
"id": "59",
|
||||
"name": "Music Kit | Sarah Schachner, KOLIBRI",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-59.png"
|
||||
},
|
||||
{
|
||||
"id": "60",
|
||||
"name": "Music Kit | bbno$, u mad!",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-60.png"
|
||||
},
|
||||
{
|
||||
"id": "61",
|
||||
"name": "Music Kit | The Verkkars & n0thing, Flashbang Dance",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-61.png"
|
||||
},
|
||||
{
|
||||
"id": "62",
|
||||
"name": "Music Kit | 3kliksphilip, Heading for the Source",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-62.png"
|
||||
},
|
||||
{
|
||||
"id": "63",
|
||||
"name": "Music Kit | Humanity's Last Breath, Void",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-63.png"
|
||||
},
|
||||
{
|
||||
"id": "64",
|
||||
"name": "Music Kit | Juelz, Shooters",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-64.png"
|
||||
},
|
||||
{
|
||||
"id": "65",
|
||||
"name": "Music Kit | Knock2, dashstar*",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-65.png"
|
||||
},
|
||||
{
|
||||
"id": "66",
|
||||
"name": "Music Kit | Meechy Darko, Gothic Luxury",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-66.png"
|
||||
},
|
||||
{
|
||||
"id": "67",
|
||||
"name": "Music Kit | Sullivan King, Lock Me Up",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-67.png"
|
||||
},
|
||||
{
|
||||
"id": "68",
|
||||
"name": "Music Kit | Perfect World, 花脸 Hua Lian (Painted Face)",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-68.png"
|
||||
},
|
||||
{
|
||||
"id": "69",
|
||||
"name": "Music Kit | Denzel Curry, ULTIMATE",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-69.png"
|
||||
},
|
||||
{
|
||||
"id": "71",
|
||||
"name": "Music Kit | DRYDEN, Feel The Power",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-71.png"
|
||||
},
|
||||
{
|
||||
"id": "72",
|
||||
"name": "Music Kit | ISOxo, inhuman",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-72.png"
|
||||
},
|
||||
{
|
||||
"id": "73",
|
||||
"name": "Music Kit | KILL SCRIPT, All Night",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-73.png"
|
||||
},
|
||||
{
|
||||
"id": "74",
|
||||
"name": "Music Kit | Knock2, Make U SWEAT!",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-74.png"
|
||||
},
|
||||
{
|
||||
"id": "75",
|
||||
"name": "Music Kit | Rad Cat, Reason",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-75.png"
|
||||
},
|
||||
{
|
||||
"id": "76",
|
||||
"name": "Music Kit | TWERL, Ekko & Sidetrack, Under Bright Lights",
|
||||
"image": "https://raw.githubusercontent.com/daffyyyy/cs2-WeaponPaints/main/website/img/skins/music_kit-76.png"
|
||||
}
|
||||
]
|
||||
54
website/db-sqlite.sql
Normal file
@@ -0,0 +1,54 @@
|
||||
PRAGMA foreign_keys = ON;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `wp_players` (
|
||||
`user_id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`steamid` INTEGER NOT NULL,
|
||||
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE(`steamid`)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `wp_player_skins` (
|
||||
`user_id` INTEGER NOT NULL,
|
||||
`team` INTEGER NOT NULL,
|
||||
`weapon_defindex` INTEGER NOT NULL,
|
||||
`paint` INTEGER NOT NULL,
|
||||
`wear` REAL NOT NULL DEFAULT 0.001,
|
||||
`seed` INTEGER NOT NULL DEFAULT 0,
|
||||
`nametag` TEXT DEFAULT NULL,
|
||||
`stattrack` INTEGER NOT NULL DEFAULT 0,
|
||||
`stattrack_enabled` INTEGER NOT NULL DEFAULT 0,
|
||||
`quality` INTEGER NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`user_id`,`team`,`weapon_defindex`),
|
||||
FOREIGN KEY (`user_id`) REFERENCES `wp_players`(`user_id`) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `wp_players_knife` (
|
||||
`user_id` INTEGER NOT NULL,
|
||||
`knife` TEXT DEFAULT NULL,
|
||||
PRIMARY KEY (`user_id`),
|
||||
FOREIGN KEY (`user_id`) REFERENCES `wp_players`(`user_id`) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `wp_players_gloves` (
|
||||
`user_id` INTEGER NOT NULL,
|
||||
`weapon_defindex` INTEGER DEFAULT NULL,
|
||||
`team` INTEGER DEFAULT NULL,
|
||||
PRIMARY KEY (`user_id`,`team`),
|
||||
FOREIGN KEY (`user_id`) REFERENCES `wp_players`(`user_id`) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `wp_players_music` (
|
||||
`user_id` INTEGER NOT NULL,
|
||||
`music` INTEGER DEFAULT NULL,
|
||||
PRIMARY KEY (`user_id`),
|
||||
FOREIGN KEY (`user_id`) REFERENCES `wp_players`(`user_id`) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `wp_players_agents` (
|
||||
`user_id` INTEGER NOT NULL,
|
||||
`agent_ct` TEXT DEFAULT NULL,
|
||||
`agent_t` TEXT DEFAULT NULL,
|
||||
PRIMARY KEY (`user_id`),
|
||||
FOREIGN KEY (`user_id`) REFERENCES `wp_players`(`user_id`) ON DELETE CASCADE
|
||||
);
|
||||
53
website/db.sql
Normal file
@@ -0,0 +1,53 @@
|
||||
CREATE TABLE IF NOT EXISTS `wp_players` (
|
||||
`user_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`steamid` BIGINT UNSIGNED NOT NULL,
|
||||
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`user_id`),
|
||||
UNIQUE KEY `unique_steamid` (`steamid`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `wp_player_skins` (
|
||||
`user_id` INT UNSIGNED NOT NULL,
|
||||
`team` SMALLINT UNSIGNED NOT NULL,
|
||||
`weapon_defindex` SMALLINT UNSIGNED NOT NULL,
|
||||
`paint` SMALLINT UNSIGNED NOT NULL,
|
||||
`wear` FLOAT NOT NULL DEFAULT 0.001,
|
||||
`seed` SMALLINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`nametag` VARCHAR(20) DEFAULT NULL,
|
||||
`stattrack` INT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`stattrack_enabled` SMALLINT NOT NULL DEFAULT 0,
|
||||
`quality` SMALLINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`user_id`,`team`,`weapon_defindex`),
|
||||
FOREIGN KEY (`user_id`) REFERENCES `wp_players`(`user_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `wp_players_knife` (
|
||||
`user_id` INT UNSIGNED NOT NULL,
|
||||
`knife` VARCHAR(32) DEFAULT NULL,
|
||||
PRIMARY KEY (`user_id`),
|
||||
FOREIGN KEY (`user_id`) REFERENCES `wp_players`(`user_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `wp_players_gloves` (
|
||||
`user_id` INT UNSIGNED NOT NULL,
|
||||
`weapon_defindex` SMALLINT UNSIGNED DEFAULT NULL,
|
||||
`team` SMALLINT UNSIGNED DEFAULT NULL,
|
||||
PRIMARY KEY (`user_id`,`team`),
|
||||
FOREIGN KEY (`user_id`) REFERENCES `wp_players`(`user_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `wp_players_music` (
|
||||
`user_id` INT UNSIGNED NOT NULL,
|
||||
`music` SMALLINT UNSIGNED DEFAULT NULL,
|
||||
PRIMARY KEY (`user_id`),
|
||||
FOREIGN KEY (`user_id`) REFERENCES `wp_players`(`user_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `wp_players_agents` (
|
||||
`user_id` INT UNSIGNED NOT NULL,
|
||||
`agent_ct` varchar(64) DEFAULT NULL,
|
||||
`agent_t` varchar(64) DEFAULT NULL,
|
||||
PRIMARY KEY (`user_id`),
|
||||
FOREIGN KEY (`user_id`) REFERENCES `wp_players`(`user_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
@@ -8,7 +8,7 @@ $weapons = array (
|
||||
"weapon_aug" => 8,
|
||||
"weapon_awp" => 9,
|
||||
"weapon_famas" => 10,
|
||||
"weapon_g3sg1" => 11,
|
||||
"weapon_g3sg1" => 10,
|
||||
"weapon_galilar" => 13,
|
||||
"weapon_m249" => 14,
|
||||
"weapon_m4a1" => 16,
|
||||
@@ -53,14 +53,7 @@ $weapons = array (
|
||||
"weapon_knife_stiletto" => 522,
|
||||
"weapon_knife_widowmaker" => 523,
|
||||
"weapon_knife_skeleton" => 525);
|
||||
|
||||
|
||||
|
||||
$
|
||||
|
||||
$json = json_decode(file_get_contents('https://bymykel.github.io/CSGO-API/api/en/skins.json'));
|
||||
|
||||
die(var_dump($json));
|
||||
$json = json_decode(file_get_contents('skins.json'));
|
||||
echo "<pre>";
|
||||
foreach($json as $skin)
|
||||
{
|
||||
|
||||
BIN
website/img/skins/music_kit-10.png
Normal file
|
After Width: | Height: | Size: 57 KiB |
BIN
website/img/skins/music_kit-11.png
Normal file
|
After Width: | Height: | Size: 84 KiB |
BIN
website/img/skins/music_kit-12.png
Normal file
|
After Width: | Height: | Size: 62 KiB |
BIN
website/img/skins/music_kit-13.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
website/img/skins/music_kit-14.png
Normal file
|
After Width: | Height: | Size: 68 KiB |
BIN
website/img/skins/music_kit-15.png
Normal file
|
After Width: | Height: | Size: 87 KiB |
BIN
website/img/skins/music_kit-16.png
Normal file
|
After Width: | Height: | Size: 70 KiB |
BIN
website/img/skins/music_kit-17.png
Normal file
|
After Width: | Height: | Size: 54 KiB |
BIN
website/img/skins/music_kit-18.png
Normal file
|
After Width: | Height: | Size: 63 KiB |
BIN
website/img/skins/music_kit-19.png
Normal file
|
After Width: | Height: | Size: 72 KiB |
BIN
website/img/skins/music_kit-20.png
Normal file
|
After Width: | Height: | Size: 80 KiB |
BIN
website/img/skins/music_kit-21.png
Normal file
|
After Width: | Height: | Size: 76 KiB |
BIN
website/img/skins/music_kit-22.png
Normal file
|
After Width: | Height: | Size: 62 KiB |
BIN
website/img/skins/music_kit-23.png
Normal file
|
After Width: | Height: | Size: 45 KiB |
BIN
website/img/skins/music_kit-24.png
Normal file
|
After Width: | Height: | Size: 62 KiB |
BIN
website/img/skins/music_kit-25.png
Normal file
|
After Width: | Height: | Size: 61 KiB |
BIN
website/img/skins/music_kit-26.png
Normal file
|
After Width: | Height: | Size: 59 KiB |
BIN
website/img/skins/music_kit-27.png
Normal file
|
After Width: | Height: | Size: 77 KiB |
BIN
website/img/skins/music_kit-28.png
Normal file
|
After Width: | Height: | Size: 44 KiB |
BIN
website/img/skins/music_kit-29.png
Normal file
|
After Width: | Height: | Size: 69 KiB |
BIN
website/img/skins/music_kit-3.png
Normal file
|
After Width: | Height: | Size: 63 KiB |
BIN
website/img/skins/music_kit-30.png
Normal file
|
After Width: | Height: | Size: 75 KiB |
BIN
website/img/skins/music_kit-31.png
Normal file
|
After Width: | Height: | Size: 65 KiB |
BIN
website/img/skins/music_kit-32.png
Normal file
|
After Width: | Height: | Size: 77 KiB |
BIN
website/img/skins/music_kit-33.png
Normal file
|
After Width: | Height: | Size: 59 KiB |
BIN
website/img/skins/music_kit-34.png
Normal file
|
After Width: | Height: | Size: 54 KiB |
BIN
website/img/skins/music_kit-35.png
Normal file
|
After Width: | Height: | Size: 93 KiB |
BIN
website/img/skins/music_kit-36.png
Normal file
|
After Width: | Height: | Size: 76 KiB |
BIN
website/img/skins/music_kit-37.png
Normal file
|
After Width: | Height: | Size: 70 KiB |
BIN
website/img/skins/music_kit-38.png
Normal file
|
After Width: | Height: | Size: 77 KiB |
BIN
website/img/skins/music_kit-39.png
Normal file
|
After Width: | Height: | Size: 41 KiB |
BIN
website/img/skins/music_kit-4.png
Normal file
|
After Width: | Height: | Size: 54 KiB |
BIN
website/img/skins/music_kit-40.png
Normal file
|
After Width: | Height: | Size: 91 KiB |
BIN
website/img/skins/music_kit-41.png
Normal file
|
After Width: | Height: | Size: 72 KiB |
BIN
website/img/skins/music_kit-42.png
Normal file
|
After Width: | Height: | Size: 76 KiB |
BIN
website/img/skins/music_kit-43.png
Normal file
|
After Width: | Height: | Size: 96 KiB |
BIN
website/img/skins/music_kit-44.png
Normal file
|
After Width: | Height: | Size: 68 KiB |
BIN
website/img/skins/music_kit-45.png
Normal file
|
After Width: | Height: | Size: 86 KiB |
BIN
website/img/skins/music_kit-46.png
Normal file
|
After Width: | Height: | Size: 57 KiB |
BIN
website/img/skins/music_kit-47.png
Normal file
|
After Width: | Height: | Size: 89 KiB |
BIN
website/img/skins/music_kit-48.png
Normal file
|
After Width: | Height: | Size: 82 KiB |
BIN
website/img/skins/music_kit-49.png
Normal file
|
After Width: | Height: | Size: 42 KiB |
BIN
website/img/skins/music_kit-5.png
Normal file
|
After Width: | Height: | Size: 70 KiB |
BIN
website/img/skins/music_kit-50.png
Normal file
|
After Width: | Height: | Size: 68 KiB |
BIN
website/img/skins/music_kit-51.png
Normal file
|
After Width: | Height: | Size: 78 KiB |
BIN
website/img/skins/music_kit-52.png
Normal file
|
After Width: | Height: | Size: 66 KiB |
BIN
website/img/skins/music_kit-53.png
Normal file
|
After Width: | Height: | Size: 91 KiB |
BIN
website/img/skins/music_kit-54.png
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
website/img/skins/music_kit-55.png
Normal file
|
After Width: | Height: | Size: 52 KiB |
BIN
website/img/skins/music_kit-56.png
Normal file
|
After Width: | Height: | Size: 49 KiB |
BIN
website/img/skins/music_kit-57.png
Normal file
|
After Width: | Height: | Size: 35 KiB |
BIN
website/img/skins/music_kit-58.png
Normal file
|
After Width: | Height: | Size: 71 KiB |
BIN
website/img/skins/music_kit-59.png
Normal file
|
After Width: | Height: | Size: 29 KiB |
BIN
website/img/skins/music_kit-6.png
Normal file
|
After Width: | Height: | Size: 70 KiB |
BIN
website/img/skins/music_kit-60.png
Normal file
|
After Width: | Height: | Size: 27 KiB |
BIN
website/img/skins/music_kit-61.png
Normal file
|
After Width: | Height: | Size: 76 KiB |
BIN
website/img/skins/music_kit-62.png
Normal file
|
After Width: | Height: | Size: 76 KiB |
BIN
website/img/skins/music_kit-63.png
Normal file
|
After Width: | Height: | Size: 79 KiB |
BIN
website/img/skins/music_kit-64.png
Normal file
|
After Width: | Height: | Size: 49 KiB |
BIN
website/img/skins/music_kit-65.png
Normal file
|
After Width: | Height: | Size: 79 KiB |
BIN
website/img/skins/music_kit-66.png
Normal file
|
After Width: | Height: | Size: 60 KiB |
BIN
website/img/skins/music_kit-67.png
Normal file
|
After Width: | Height: | Size: 64 KiB |
BIN
website/img/skins/music_kit-68.png
Normal file
|
After Width: | Height: | Size: 73 KiB |
BIN
website/img/skins/music_kit-69.png
Normal file
|
After Width: | Height: | Size: 56 KiB |
BIN
website/img/skins/music_kit-7.png
Normal file
|
After Width: | Height: | Size: 34 KiB |
BIN
website/img/skins/music_kit-71.png
Normal file
|
After Width: | Height: | Size: 60 KiB |
BIN
website/img/skins/music_kit-72.png
Normal file
|
After Width: | Height: | Size: 66 KiB |
BIN
website/img/skins/music_kit-73.png
Normal file
|
After Width: | Height: | Size: 75 KiB |