mirror of
https://github.com/Nereziel/cs2-WeaponPaints.git
synced 2026-03-02 06:10:45 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
959123344f | ||
|
|
14b0b8153f | ||
|
|
fa48245b34 | ||
|
|
5d5e0f2bd1 | ||
|
|
726e67865c | ||
|
|
868e6c8746 | ||
|
|
a1285bef26 | ||
|
|
b1920f312c |
40
Commands.cs
40
Commands.cs
@@ -35,18 +35,19 @@ namespace WeaponPaints
|
|||||||
commandsCooldown[(int)player.UserId] = DateTime.UtcNow.AddSeconds(Config.CmdRefreshCooldownSeconds);
|
commandsCooldown[(int)player.UserId] = DateTime.UtcNow.AddSeconds(Config.CmdRefreshCooldownSeconds);
|
||||||
|
|
||||||
if (weaponSync != null)
|
if (weaponSync != null)
|
||||||
|
{
|
||||||
Task.Run(async () => await weaponSync.GetWeaponPaintsFromDatabase(playerInfo));
|
Task.Run(async () => await weaponSync.GetWeaponPaintsFromDatabase(playerInfo));
|
||||||
|
|
||||||
if (Config.Additional.GloveEnabled && weaponSync != null)
|
if (Config.Additional.GloveEnabled)
|
||||||
Task.Run(async () => await weaponSync.GetGloveFromDatabase(playerInfo));
|
Task.Run(async () => await weaponSync.GetGloveFromDatabase(playerInfo));
|
||||||
|
|
||||||
if (Config.Additional.KnifeEnabled)
|
if (Config.Additional.KnifeEnabled)
|
||||||
{
|
|
||||||
if (weaponSync != null)
|
|
||||||
Task.Run(async () => await weaponSync.GetKnifeFromDatabase(playerInfo));
|
Task.Run(async () => await weaponSync.GetKnifeFromDatabase(playerInfo));
|
||||||
|
|
||||||
RefreshWeapons(player);
|
RefreshWeapons(player);
|
||||||
|
RefreshGloves(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(Localizer["wp_command_refresh_done"]))
|
if (!string.IsNullOrEmpty(Localizer["wp_command_refresh_done"]))
|
||||||
{
|
{
|
||||||
player!.Print(Localizer["wp_command_refresh_done"]);
|
player!.Print(Localizer["wp_command_refresh_done"]);
|
||||||
@@ -149,11 +150,12 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
g_playersKnife[(int)player!.Index] = knifeKey;
|
g_playersKnife[(int)player!.Index] = knifeKey;
|
||||||
|
|
||||||
if (g_bCommandsAllowed && (LifeState_t)player.LifeState == LifeState_t.LIFE_ALIVE)
|
|
||||||
AddTimer(0.1f, () => RefreshWeapons(player), CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
|
||||||
|
|
||||||
if (weaponSync != null)
|
if (weaponSync != null)
|
||||||
Task.Run(async () => await weaponSync.SyncKnifeToDatabase(playerInfo, knifeKey));
|
Task.Run(async () => await weaponSync.SyncKnifeToDatabase(playerInfo, knifeKey));
|
||||||
|
|
||||||
|
if (g_bCommandsAllowed && (LifeState_t)player.LifeState == LifeState_t.LIFE_ALIVE)
|
||||||
|
AddTimer(0.2f, () => RefreshWeapons(player), CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
foreach (var knifePair in knivesOnly)
|
foreach (var knifePair in knivesOnly)
|
||||||
@@ -265,14 +267,7 @@ namespace WeaponPaints
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (g_bCommandsAllowed && (LifeState_t)p.LifeState == LifeState_t.LIFE_ALIVE)
|
if (g_bCommandsAllowed && (LifeState_t)p.LifeState == LifeState_t.LIFE_ALIVE)
|
||||||
AddTimer(0.15f, () => RefreshWeapons(p), CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
AddTimer(0.2f, () => RefreshWeapons(p), CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||||
|
|
||||||
|
|
||||||
if (!Config.GlobalShare)
|
|
||||||
{
|
|
||||||
if (weaponSync != null)
|
|
||||||
Task.Run(async () => await weaponSync.SyncWeaponPaintsToDatabase(playerInfo));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -366,9 +361,20 @@ namespace WeaponPaints
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (paint != 0)
|
if (paint != 0)
|
||||||
g_playersGlove[playerIndex] = ((ushort)weaponDefindex, paint);
|
{
|
||||||
|
g_playersGlove[playerIndex] = (ushort)weaponDefindex;
|
||||||
|
|
||||||
|
if (!gPlayerWeaponsInfo[(int)playerIndex].ContainsKey(weaponDefindex))
|
||||||
|
{
|
||||||
|
WeaponInfo weaponInfo = new();
|
||||||
|
weaponInfo.Paint = paint;
|
||||||
|
gPlayerWeaponsInfo[(int)playerIndex][weaponDefindex] = weaponInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
g_playersGlove.TryRemove(playerIndex, out _);
|
g_playersGlove.TryRemove(playerIndex, out _);
|
||||||
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(Localizer["wp_glove_menu_select"]))
|
if (!string.IsNullOrEmpty(Localizer["wp_glove_menu_select"]))
|
||||||
{
|
{
|
||||||
@@ -382,7 +388,7 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
if (weaponSync != null)
|
if (weaponSync != null)
|
||||||
{
|
{
|
||||||
Task.Run(async () => await weaponSync.SyncGloveToDatabase(playerInfo, (ushort)weaponDefindex, paint));
|
Task.Run(async () => await weaponSync.SyncGloveToDatabase(playerInfo, (ushort)weaponDefindex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
23
Events.cs
23
Events.cs
@@ -46,6 +46,17 @@ namespace WeaponPaints
|
|||||||
if (player is null || !player.IsValid || !player.UserId.HasValue || player.IsBot ||
|
if (player is null || !player.IsValid || !player.UserId.HasValue || player.IsBot ||
|
||||||
player.IsHLTV || player.SteamID.ToString().Length != 17) return HookResult.Continue;
|
player.IsHLTV || player.SteamID.ToString().Length != 17) return HookResult.Continue;
|
||||||
|
|
||||||
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
|
{
|
||||||
|
UserId = player.UserId,
|
||||||
|
Index = (int)player.Index,
|
||||||
|
SteamId = player.SteamID.ToString(),
|
||||||
|
Name = player.PlayerName,
|
||||||
|
IpAddress = player.IpAddress?.Split(":")[0]
|
||||||
|
};
|
||||||
|
|
||||||
|
if (weaponSync != null)
|
||||||
|
Task.Run(async () => await weaponSync.SyncWeaponPaintsToDatabase(playerInfo));
|
||||||
|
|
||||||
if (Config.Additional.SkinEnabled)
|
if (Config.Additional.SkinEnabled)
|
||||||
gPlayerWeaponsInfo.TryRemove((int)player.Index, out _);
|
gPlayerWeaponsInfo.TryRemove((int)player.Index, out _);
|
||||||
@@ -191,17 +202,17 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnTick()
|
private void OnTick()
|
||||||
{
|
{
|
||||||
foreach (var player in Utilities.GetPlayers())
|
foreach (var player in Utilities.GetPlayers().Where(p =>
|
||||||
|
p is not null && p.IsValid &&
|
||||||
|
(LifeState_t)p.LifeState == LifeState_t.LIFE_ALIVE && p.SteamID.ToString().Length == 17
|
||||||
|
&& !p.IsBot && !p.IsHLTV && p.Connected == PlayerConnectedState.PlayerConnected && p.Team != CounterStrikeSharp.API.Modules.Utils.CsTeam.None
|
||||||
|
)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (player is null || !player.IsValid || !player.PawnIsAlive || player.SteamID.ToString().Length != 17
|
|
||||||
|| player.IsBot || player.IsHLTV || player.Connected != PlayerConnectedState.PlayerConnected)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (Config.Additional.ShowSkinImage && PlayerWeaponImage.ContainsKey(player.Slot) && !string.IsNullOrEmpty(PlayerWeaponImage[player.Slot]))
|
if (Config.Additional.ShowSkinImage && PlayerWeaponImage.ContainsKey(player.Slot) && !string.IsNullOrEmpty(PlayerWeaponImage[player.Slot]))
|
||||||
{
|
{
|
||||||
player.PrintToCenterHtml("<img src='{PATH}'</img>".Replace("{PATH}", PlayerWeaponImage[player.Slot]));
|
player.PrintToCenterHtml("<img src='{PATH}'</img>".Replace("{PATH}", PlayerWeaponImage[player.Slot]));
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ namespace WeaponPaints
|
|||||||
@"CREATE TABLE IF NOT EXISTS `wp_player_gloves` (
|
@"CREATE TABLE IF NOT EXISTS `wp_player_gloves` (
|
||||||
`steamid` varchar(64) NOT NULL,
|
`steamid` varchar(64) NOT NULL,
|
||||||
`weapon_defindex` int(11) NOT NULL,
|
`weapon_defindex` int(11) NOT NULL,
|
||||||
`paint` int(11) NOT NULL,
|
|
||||||
UNIQUE (`steamid`)
|
UNIQUE (`steamid`)
|
||||||
) ENGINE=InnoDB"
|
) ENGINE=InnoDB"
|
||||||
};
|
};
|
||||||
|
|||||||
179
WeaponAction.cs
179
WeaponAction.cs
@@ -202,117 +202,122 @@ namespace WeaponPaints
|
|||||||
{
|
{
|
||||||
if (player == null || !player.IsValid || player.PlayerPawn?.Value == null || (LifeState_t)player.LifeState != LifeState_t.LIFE_ALIVE)
|
if (player == null || !player.IsValid || player.PlayerPawn?.Value == null || (LifeState_t)player.LifeState != LifeState_t.LIFE_ALIVE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (player.PlayerPawn.Value.WeaponServices == null || player.PlayerPawn.Value.ItemServices == null)
|
if (player.PlayerPawn.Value.WeaponServices == null || player.PlayerPawn.Value.ItemServices == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var weapons = player.PlayerPawn.Value.WeaponServices.MyWeapons;
|
var weapons = player.PlayerPawn.Value.WeaponServices.MyWeapons;
|
||||||
|
|
||||||
if (weapons == null || weapons.Count == 0)
|
if (weapons == null || weapons.Count == 0)
|
||||||
return;
|
return;
|
||||||
|
if (player.Team == CsTeam.None || player.Team == CsTeam.Spectator)
|
||||||
|
return;
|
||||||
|
|
||||||
if (weapons != null && weapons.Count > 0)
|
//Dictionary<string, (int, int)> weaponsWithAmmo = new Dictionary<string, (int, int)>();
|
||||||
|
Dictionary<string, List<(int, int)>> weaponsWithAmmo = new Dictionary<string, List<(int, int)>>();
|
||||||
|
bool bomb = false;
|
||||||
|
bool defuser = player.PawnHasDefuser;
|
||||||
|
bool healthshot = false;
|
||||||
|
|
||||||
|
// Iterate through each weapon
|
||||||
|
foreach (var weapon in weapons)
|
||||||
{
|
{
|
||||||
//Dictionary<string, (int, int)> weaponsWithAmmo = new Dictionary<string, (int, int)>();
|
if (weapon == null || !weapon.IsValid || weapon.Value == null ||
|
||||||
Dictionary<string, List<(int, int)>> weaponsWithAmmo = new Dictionary<string, List<(int, int)>>();
|
!weapon.Value.IsValid || !weapon.Value.DesignerName.Contains("weapon_"))
|
||||||
bool bomb = false;
|
continue;
|
||||||
bool defuser = player.PawnHasDefuser;
|
|
||||||
bool healthshot = false;
|
|
||||||
|
|
||||||
// Iterate through each weapon
|
try
|
||||||
foreach (var weapon in weapons)
|
|
||||||
{
|
{
|
||||||
if (weapon == null || !weapon.IsValid || weapon.Value == null ||
|
string? weaponByDefindex = null;
|
||||||
!weapon.Value.IsValid || !weapon.Value.DesignerName.Contains("weapon_"))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
try
|
CCSWeaponBaseVData? weaponData = weapon.Value.As<CCSWeaponBase>().VData;
|
||||||
|
|
||||||
|
if (weaponData != null)
|
||||||
{
|
{
|
||||||
string? weaponByDefindex = null;
|
if (weaponData.GearSlot == gear_slot_t.GEAR_SLOT_C4)
|
||||||
|
bomb = true;
|
||||||
|
|
||||||
CCSWeaponBaseVData? weaponData = weapon.Value.As<CCSWeaponBase>().VData;
|
if (weaponData.Name.Equals("weapon_healtshot"))
|
||||||
|
healthshot = true;
|
||||||
|
|
||||||
if (weaponData != null)
|
if (weaponData.GearSlot == gear_slot_t.GEAR_SLOT_GRENADES || weaponData.GearSlot == gear_slot_t.GEAR_SLOT_UTILITY || weaponData.GearSlot == gear_slot_t.GEAR_SLOT_BOOSTS)
|
||||||
{
|
|
||||||
if (weaponData.GearSlot == gear_slot_t.GEAR_SLOT_C4)
|
|
||||||
bomb = true;
|
|
||||||
|
|
||||||
if (weaponData.Name.Equals("weapon_healtshot"))
|
|
||||||
healthshot = true;
|
|
||||||
|
|
||||||
if (weaponData.GearSlot == gear_slot_t.GEAR_SLOT_GRENADES || weaponData.GearSlot == gear_slot_t.GEAR_SLOT_UTILITY || weaponData.GearSlot == gear_slot_t.GEAR_SLOT_BOOSTS)
|
|
||||||
{
|
|
||||||
int clip1 = weapon.Value.Clip1;
|
|
||||||
int reservedAmmo = weapon.Value.ReserveAmmo[0];
|
|
||||||
|
|
||||||
weaponsWithAmmo.Add(weapon.Value.DesignerName, new List<(int, int)>() { (clip1, reservedAmmo) });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!weapon.Value.DesignerName.Contains("knife") && WeaponDefindex.TryGetValue(weapon.Value.AttributeManager.Item.ItemDefinitionIndex, out weaponByDefindex) && weaponByDefindex != null)
|
|
||||||
{
|
{
|
||||||
int clip1 = weapon.Value.Clip1;
|
int clip1 = weapon.Value.Clip1;
|
||||||
int reservedAmmo = weapon.Value.ReserveAmmo[0];
|
int reservedAmmo = weapon.Value.ReserveAmmo[0];
|
||||||
|
|
||||||
if (!weaponsWithAmmo.ContainsKey(weaponByDefindex))
|
weaponsWithAmmo.Add(weapon.Value.DesignerName, new List<(int, int)>() { (clip1, reservedAmmo) });
|
||||||
{
|
|
||||||
weaponsWithAmmo.Add(weaponByDefindex, new List<(int, int)>());
|
|
||||||
}
|
|
||||||
|
|
||||||
weaponsWithAmmo[weaponByDefindex].Add((clip1, reservedAmmo));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
|
if (!weapon.Value.DesignerName.Contains("knife")
|
||||||
|
&&
|
||||||
|
!weapon.Value.DesignerName.Contains("bayonet")
|
||||||
|
&&
|
||||||
|
!weapon.Value.DesignerName.Contains("kukri")
|
||||||
|
&&
|
||||||
|
WeaponDefindex.TryGetValue(weapon.Value.AttributeManager.Item.ItemDefinitionIndex, out weaponByDefindex) && weaponByDefindex != null)
|
||||||
{
|
{
|
||||||
Logger.LogWarning(ex.Message);
|
int clip1 = weapon.Value.Clip1;
|
||||||
continue;
|
int reservedAmmo = weapon.Value.ReserveAmmo[0];
|
||||||
|
|
||||||
|
if (!weaponsWithAmmo.ContainsKey(weaponByDefindex))
|
||||||
|
{
|
||||||
|
weaponsWithAmmo.Add(weaponByDefindex, new List<(int, int)>());
|
||||||
|
}
|
||||||
|
|
||||||
|
weaponsWithAmmo[weaponByDefindex].Add((clip1, reservedAmmo));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.LogWarning(ex.Message);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
player.RemoveWeapons();
|
||||||
|
AddTimer(0.3f, () =>
|
||||||
|
{
|
||||||
|
GiveKnifeToPlayer(player);
|
||||||
|
|
||||||
|
if (bomb)
|
||||||
|
player.GiveNamedItem("weapon_c4");
|
||||||
|
|
||||||
|
if (defuser)
|
||||||
|
{
|
||||||
|
var itemServ = player.PlayerPawn?.Value?.ItemServices;
|
||||||
|
if (itemServ != null)
|
||||||
|
{
|
||||||
|
var items = new CCSPlayer_ItemServices(itemServ.Handle);
|
||||||
|
items.HasDefuser = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
player.RemoveWeapons();
|
if (healthshot)
|
||||||
AddTimer(0.1f, () =>
|
player.GiveNamedItem("weapon_healtshot");
|
||||||
|
|
||||||
|
foreach (var entry in weaponsWithAmmo)
|
||||||
{
|
{
|
||||||
GiveKnifeToPlayer(player);
|
foreach (var ammo in entry.Value)
|
||||||
|
|
||||||
if (bomb)
|
|
||||||
player.GiveNamedItem("weapon_c4");
|
|
||||||
|
|
||||||
if (defuser)
|
|
||||||
{
|
{
|
||||||
var itemServ = player.PlayerPawn?.Value?.ItemServices;
|
var newWeapon = new CBasePlayerWeapon(player.GiveNamedItem(entry.Key));
|
||||||
if (itemServ != null)
|
Server.NextFrame(() =>
|
||||||
{
|
{
|
||||||
var items = new CCSPlayer_ItemServices(itemServ.Handle);
|
try
|
||||||
items.HasDefuser = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (healthshot)
|
|
||||||
player.GiveNamedItem("weapon_healtshot");
|
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
if (newWeapon != null)
|
newWeapon.Clip1 = ammo.Item1;
|
||||||
{
|
newWeapon.ReserveAmmo[0] = ammo.Item2;
|
||||||
newWeapon.Clip1 = ammo.Item1;
|
|
||||||
newWeapon.ReserveAmmo[0] = ammo.Item2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
}
|
||||||
{
|
catch (Exception ex)
|
||||||
Logger.LogWarning("Error setting weapon properties: " + ex.Message);
|
{
|
||||||
}
|
Logger.LogWarning("Error setting weapon properties: " + ex.Message);
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
}
|
||||||
}
|
}, TimerFlags.STOP_ON_MAPCHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void RefreshKnife(CCSPlayerController? player)
|
internal void RefreshKnife(CCSPlayerController? player)
|
||||||
@@ -351,6 +356,8 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
private static void RefreshGloves(CCSPlayerController player)
|
private static void RefreshGloves(CCSPlayerController player)
|
||||||
{
|
{
|
||||||
|
if (!Utility.IsPlayerValid(player) || (LifeState_t)player.LifeState != LifeState_t.LIFE_ALIVE) return;
|
||||||
|
|
||||||
CCSPlayerPawn? pawn = player.PlayerPawn.Value;
|
CCSPlayerPawn? pawn = player.PlayerPawn.Value;
|
||||||
if (pawn == null || !pawn.IsValid || pawn.LifeState != (byte)LifeState_t.LIFE_ALIVE)
|
if (pawn == null || !pawn.IsValid || pawn.LifeState != (byte)LifeState_t.LIFE_ALIVE)
|
||||||
return;
|
return;
|
||||||
@@ -369,20 +376,22 @@ namespace WeaponPaints
|
|||||||
if (!player.IsValid)
|
if (!player.IsValid)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (g_playersGlove.TryGetValue(player.Index, out var gloveInfo) && gloveInfo.Paint != 0)
|
if (g_playersGlove.TryGetValue(player.Index, out var gloveInfo) && gloveInfo != 0)
|
||||||
{
|
{
|
||||||
CCSPlayerPawn? pawn = player.PlayerPawn.Value;
|
CCSPlayerPawn? pawn = player.PlayerPawn.Value;
|
||||||
if (pawn == null || !pawn.IsValid || pawn.LifeState != (byte)LifeState_t.LIFE_ALIVE)
|
if (pawn == null || !pawn.IsValid || pawn.LifeState != (byte)LifeState_t.LIFE_ALIVE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
WeaponInfo weaponInfo = gPlayerWeaponsInfo[(int)player.Index][gloveInfo];
|
||||||
|
|
||||||
CEconItemView item = pawn.EconGloves;
|
CEconItemView item = pawn.EconGloves;
|
||||||
item.ItemDefinitionIndex = gloveInfo.Definition;
|
item.ItemDefinitionIndex = gloveInfo;
|
||||||
item.ItemIDLow = 16384 & 0xFFFFFFFF;
|
item.ItemIDLow = 16384 & 0xFFFFFFFF;
|
||||||
item.ItemIDHigh = 16384;
|
item.ItemIDHigh = 16384;
|
||||||
|
|
||||||
CAttributeList_SetOrAddAttributeValueByName.Invoke(item.NetworkedDynamicAttributes.Handle, "set item texture prefab", gloveInfo.Paint);
|
CAttributeList_SetOrAddAttributeValueByName.Invoke(item.NetworkedDynamicAttributes.Handle, "set item texture prefab", weaponInfo.Paint);
|
||||||
CAttributeList_SetOrAddAttributeValueByName.Invoke(item.NetworkedDynamicAttributes.Handle, "set item texture seed", 0);
|
CAttributeList_SetOrAddAttributeValueByName.Invoke(item.NetworkedDynamicAttributes.Handle, "set item texture seed", weaponInfo.Seed);
|
||||||
CAttributeList_SetOrAddAttributeValueByName.Invoke(item.NetworkedDynamicAttributes.Handle, "set item texture wear", 0.00f);
|
CAttributeList_SetOrAddAttributeValueByName.Invoke(item.NetworkedDynamicAttributes.Handle, "set item texture wear", weaponInfo.Wear);
|
||||||
|
|
||||||
item.Initialized = true;
|
item.Initialized = true;
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
public class WeaponInfo
|
public class WeaponInfo
|
||||||
{
|
{
|
||||||
public int Paint { get; set; }
|
public int Paint { get; set; }
|
||||||
public int Seed { get; set; }
|
public int Seed { get; set; } = 0;
|
||||||
public float Wear { get; set; }
|
public float Wear { get; set; } = 0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,7 +79,7 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
|||||||
internal static IStringLocalizer? _localizer;
|
internal static IStringLocalizer? _localizer;
|
||||||
internal static Dictionary<int, int> g_knifePickupCount = new Dictionary<int, int>();
|
internal static Dictionary<int, int> g_knifePickupCount = new Dictionary<int, int>();
|
||||||
internal static ConcurrentDictionary<int, string> g_playersKnife = new ConcurrentDictionary<int, string>();
|
internal static ConcurrentDictionary<int, string> g_playersKnife = new ConcurrentDictionary<int, string>();
|
||||||
internal static ConcurrentDictionary<uint, (ushort Definition, int Paint)> g_playersGlove = new ConcurrentDictionary<uint, (ushort Definition, int Paint)>();
|
internal static ConcurrentDictionary<uint, ushort> g_playersGlove = new ConcurrentDictionary<uint, ushort>();
|
||||||
internal static ConcurrentDictionary<int, ConcurrentDictionary<int, WeaponInfo>> gPlayerWeaponsInfo = new ConcurrentDictionary<int, ConcurrentDictionary<int, WeaponInfo>>();
|
internal static ConcurrentDictionary<int, ConcurrentDictionary<int, WeaponInfo>> gPlayerWeaponsInfo = new ConcurrentDictionary<int, ConcurrentDictionary<int, WeaponInfo>>();
|
||||||
internal static List<JObject> skinsList = new List<JObject>();
|
internal static List<JObject> skinsList = new List<JObject>();
|
||||||
internal static List<JObject> glovesList = new List<JObject>();
|
internal static List<JObject> glovesList = new List<JObject>();
|
||||||
@@ -158,7 +158,7 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
|||||||
public override string ModuleAuthor => "Nereziel & daffyy";
|
public override string ModuleAuthor => "Nereziel & daffyy";
|
||||||
public override string ModuleDescription => "Skin, gloves and knife selector, standalone and web-based";
|
public override string ModuleDescription => "Skin, gloves and knife selector, standalone and web-based";
|
||||||
public override string ModuleName => "WeaponPaints";
|
public override string ModuleName => "WeaponPaints";
|
||||||
public override string ModuleVersion => "1.8b";
|
public override string ModuleVersion => "1.8d";
|
||||||
|
|
||||||
public static WeaponPaintsConfig GetWeaponPaintsConfig()
|
public static WeaponPaintsConfig GetWeaponPaintsConfig()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -88,16 +88,16 @@ namespace WeaponPaints
|
|||||||
await using var connection = await _database.GetConnectionAsync();
|
await using var connection = await _database.GetConnectionAsync();
|
||||||
|
|
||||||
// Construct the SQL query with specific columns for better performance
|
// Construct the SQL query with specific columns for better performance
|
||||||
string query = "SELECT `weapon_defindex`, `paint` FROM `wp_player_gloves` WHERE `steamid` = @steamid";
|
string query = "SELECT `weapon_defindex` FROM `wp_player_gloves` WHERE `steamid` = @steamid";
|
||||||
|
|
||||||
// Execute the query and retrieve glove data
|
// Execute the query and retrieve glove data
|
||||||
var gloveData = await connection.QueryFirstOrDefaultAsync<(ushort Definition, int Paint)>(query, new { steamid = player.SteamId });
|
ushort? gloveData = await connection.QueryFirstOrDefaultAsync<ushort?>(query, new { steamid = player.SteamId });
|
||||||
|
|
||||||
// Check if glove data is retrieved successfully
|
// Check if glove data is retrieved successfully
|
||||||
if (gloveData != default)
|
if (gloveData != null)
|
||||||
{
|
{
|
||||||
// Update g_playersGlove dictionary with glove data
|
// Update g_playersGlove dictionary with glove data
|
||||||
WeaponPaints.g_playersGlove[(uint)player.Index] = gloveData;
|
WeaponPaints.g_playersGlove[(uint)player.Index] = gloveData.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -212,15 +212,15 @@ namespace WeaponPaints
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task SyncGloveToDatabase(PlayerInfo player, ushort defindex, int paint)
|
internal async Task SyncGloveToDatabase(PlayerInfo player, ushort defindex)
|
||||||
{
|
{
|
||||||
if (!_config.Additional.GloveEnabled) return;
|
if (!_config.Additional.GloveEnabled) return;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await using var connection = await _database.GetConnectionAsync();
|
await using var connection = await _database.GetConnectionAsync();
|
||||||
string query = "INSERT INTO `wp_player_gloves` (`steamid`, `weapon_defindex`, `paint`) VALUES(@steamid, @weapon_defindex, @paint) ON DUPLICATE KEY UPDATE `weapon_defindex` = @weapon_defindex, `paint` = @paint";
|
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, paint });
|
await connection.ExecuteAsync(query, new { steamid = player.SteamId, weapon_defindex = defindex });
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user