mirror of
https://github.com/Nereziel/cs2-WeaponPaints.git
synced 2026-02-17 18:39:07 +00:00
1.7a
- Fixed hotreloading - Minor changes
This commit is contained in:
16
Commands.cs
16
Commands.cs
@@ -207,6 +207,7 @@ namespace WeaponPaints
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
string selectedSkin = opt.Text;
|
||||
string selectedPaintID = selectedSkin.Split('(')[1].Trim(')').Trim();
|
||||
|
||||
@@ -216,7 +217,19 @@ namespace WeaponPaints
|
||||
int.TryParse(weaponDefIndexObj.ToString(), out var weaponDefIndex) &&
|
||||
int.TryParse(selectedPaintID, out var paintID))
|
||||
{
|
||||
p!.Print(Localizer["wp_skin_menu_select", selectedSkin]);
|
||||
if (Config.Additional.ShowSkinImage && skinsList != null)
|
||||
{
|
||||
var foundSkin = skinsList.FirstOrDefault(skin =>
|
||||
((int?)skin?["weapon_defindex"] ?? 0) == weaponDefIndex &&
|
||||
((int?)skin?["paint"] ?? 0) == paintID &&
|
||||
skin?["image"] != null
|
||||
);
|
||||
string image = foundSkin?["image"]?.ToString() ?? "";
|
||||
PlayerWeaponImage[p.Slot] = image;
|
||||
AddTimer(2.0f, () => PlayerWeaponImage.Remove(p.Slot));
|
||||
}
|
||||
|
||||
p.Print(Localizer["wp_skin_menu_select", selectedSkin]);
|
||||
|
||||
if (!gPlayerWeaponsInfo[playerIndex].ContainsKey(weaponDefIndex))
|
||||
{
|
||||
@@ -288,7 +301,6 @@ namespace WeaponPaints
|
||||
{
|
||||
commandsCooldown[(int)player.UserId] = DateTime.UtcNow.AddSeconds(Config.CmdRefreshCooldownSeconds);
|
||||
MenuManager.OpenChatMenu(player, weaponSelectionMenu);
|
||||
weaponSelectionMenu.PostSelectAction = PostSelectAction.Close;
|
||||
return;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(Localizer["wp_command_cooldown"]))
|
||||
|
||||
@@ -43,6 +43,9 @@ namespace WeaponPaints
|
||||
|
||||
[JsonPropertyName("GiveKnifeAfterRemove")]
|
||||
public bool GiveKnifeAfterRemove { get; set; } = false;
|
||||
|
||||
[JsonPropertyName("ShowSkinImage")]
|
||||
public bool ShowSkinImage { get; set; } = true;
|
||||
}
|
||||
|
||||
public class WeaponPaintsConfig : BasePluginConfig
|
||||
|
||||
158
Events.cs
158
Events.cs
@@ -88,47 +88,6 @@ namespace WeaponPaints
|
||||
});
|
||||
}
|
||||
|
||||
private HookResult OnEventItemPurchasePost(EventItemPurchase @event, GameEventInfo info)
|
||||
{
|
||||
CCSPlayerController? player = @event.Userid;
|
||||
|
||||
if (player == null || !player.IsValid) return HookResult.Continue;
|
||||
|
||||
/*
|
||||
if (Config.Additional.SkinVisibilityFix)
|
||||
AddTimer(0.2f, () => RefreshSkins(player));
|
||||
*/
|
||||
|
||||
return HookResult.Continue;
|
||||
}
|
||||
|
||||
/*
|
||||
private HookResult OnItemPickup(EventItemPickup @event, GameEventInfo info)
|
||||
{
|
||||
if (@event.Defindex == 42 || @event.Defindex == 59)
|
||||
{
|
||||
CCSPlayerController? player = @event.Userid;
|
||||
if (player == null || !player.IsValid || !g_knifePickupCount.ContainsKey((int)player.Index) || player.IsBot || !g_playersKnife.ContainsKey((int)player.Index))
|
||||
return HookResult.Continue;
|
||||
|
||||
if (g_knifePickupCount[(int)player.Index] >= 2) return HookResult.Continue;
|
||||
|
||||
if (g_playersKnife.ContainsKey((int)player.Index)
|
||||
&&
|
||||
g_playersKnife[(int)player.Index] != "weapon_knife")
|
||||
{
|
||||
g_knifePickupCount[(int)player.Index]++;
|
||||
|
||||
RemovePlayerKnife(player, true);
|
||||
|
||||
if (!PlayerHasKnife(player) && Config.Additional.GiveKnifeAfterRemove)
|
||||
AddTimer(0.3f, () => GiveKnifeToPlayer(player));
|
||||
}
|
||||
}
|
||||
return HookResult.Continue;
|
||||
}
|
||||
*/
|
||||
|
||||
public HookResult OnPickup(CEntityIOOutput output, string name, CEntityInstance activator, CEntityInstance caller, CVariant value, float delay)
|
||||
{
|
||||
CCSPlayerController? player = Utilities.GetEntityFromIndex<CCSPlayerPawn>((int)activator.Index).OriginalController.Value;
|
||||
@@ -156,10 +115,14 @@ namespace WeaponPaints
|
||||
{
|
||||
pickupCount++;
|
||||
g_knifePickupCount[(int)player.Index] = pickupCount;
|
||||
player.RemoveItemByDesignerName(weapon.DesignerName);
|
||||
|
||||
if (Config.Additional.GiveKnifeAfterRemove)
|
||||
{
|
||||
AddTimer(0.2f, () => GiveKnifeToPlayer(player));
|
||||
AddTimer(0.37f, () =>
|
||||
{
|
||||
player.RemoveItemByDesignerName(weapon.DesignerName, true);
|
||||
GiveKnifeToPlayer(player);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,72 +147,14 @@ namespace WeaponPaints
|
||||
if (Config.GlobalShare)
|
||||
GlobalShareConnect();
|
||||
});
|
||||
|
||||
/*
|
||||
g_hTimerCheckSkinsData = AddTimer(10.0f, () =>
|
||||
{
|
||||
List<CCSPlayerController> players = Utilities.GetPlayers();
|
||||
|
||||
foreach (CCSPlayerController player in players)
|
||||
{
|
||||
if (player.IsBot || player.IsHLTV || player.SteamID.ToString() == "") continue;
|
||||
if (gPlayerWeaponsInfo.ContainsKey((int)player.Index)) 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 (Config.Additional.SkinEnabled && weaponSync != null)
|
||||
_ = weaponSync.GetWeaponPaintsFromDatabase(playerInfo);
|
||||
if (Config.Additional.KnifeEnabled && weaponSync != null)
|
||||
_ = weaponSync.GetKnifeFromDatabase(playerInfo);
|
||||
}
|
||||
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE | CounterStrikeSharp.API.Modules.Timers.TimerFlags.REPEAT);
|
||||
*/
|
||||
}
|
||||
|
||||
private HookResult OnPlayerConnectFull(EventPlayerConnectFull @event, GameEventInfo info)
|
||||
{
|
||||
CCSPlayerController? player = @event.Userid;
|
||||
|
||||
if (player == null || !player.IsValid || player.IsBot || player.IsHLTV || weaponSync == null) return HookResult.Continue;
|
||||
|
||||
PlayerInfo playerInfo = new PlayerInfo
|
||||
{
|
||||
UserId = player.UserId,
|
||||
Index = (int)player.Index,
|
||||
SteamId = player?.SteamID.ToString(),
|
||||
Name = player?.PlayerName,
|
||||
IpAddress = player?.IpAddress?.Split(":")[0]
|
||||
};
|
||||
|
||||
if (!gPlayerWeaponsInfo.ContainsKey((int)player!.Index))
|
||||
{
|
||||
Console.WriteLine($"[WeaponPaints] Retrying to retrieve player {player.PlayerName} skins");
|
||||
Task.Run(async () =>
|
||||
{
|
||||
if (Config.Additional.SkinEnabled)
|
||||
await weaponSync.GetWeaponPaintsFromDatabase(playerInfo);
|
||||
if (Config.Additional.KnifeEnabled)
|
||||
await weaponSync.GetKnifeFromDatabase(playerInfo);
|
||||
});
|
||||
}
|
||||
|
||||
return HookResult.Continue;
|
||||
}
|
||||
|
||||
private HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
|
||||
{
|
||||
CCSPlayerController? player = @event.Userid;
|
||||
if (player == null || !player.IsValid || !Config.Additional.KnifeEnabled || PlayerHasKnife(player))
|
||||
{
|
||||
|
||||
if (player is null || !player.IsValid || !Config.Additional.KnifeEnabled)
|
||||
return HookResult.Continue;
|
||||
}
|
||||
|
||||
g_knifePickupCount[(int)player.Index] = 0;
|
||||
GiveKnifeToPlayer(player);
|
||||
@@ -280,7 +185,16 @@ namespace WeaponPaints
|
||||
{
|
||||
try
|
||||
{
|
||||
if (player is null || !player.IsValid || !player.PawnIsAlive || player.IsBot || player.IsHLTV || player.Connected != PlayerConnectedState.PlayerConnected)
|
||||
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]))
|
||||
{
|
||||
player.PrintToCenterHtml("<img src='{PATH}'</img>".Replace("{PATH}", PlayerWeaponImage[player.Slot]));
|
||||
}
|
||||
|
||||
if (player.PlayerPawn?.IsValid != true || player.PlayerPawn?.Value?.IsValid != true)
|
||||
continue;
|
||||
|
||||
var viewModels = GetPlayerViewModels(player);
|
||||
@@ -292,7 +206,7 @@ namespace WeaponPaints
|
||||
continue;
|
||||
|
||||
var weapon = viewModel.Value.Weapon.Value;
|
||||
if (weapon == null || !weapon.IsValid)
|
||||
if (weapon == null || !weapon.IsValid || weapon.FallbackPaintKit == 0)
|
||||
continue;
|
||||
|
||||
if (viewModel.Value.VMName.Contains("knife"))
|
||||
@@ -306,8 +220,8 @@ namespace WeaponPaints
|
||||
if (skeleton == null)
|
||||
continue;
|
||||
|
||||
int[] knifePaintKits = { 1171, 1170, 1169, 1164, 1162, 1161, 1159, 1175, 1174, 1167, 1165, 1168, 1163, 1160, 1166, 1173 };
|
||||
if (knifePaintKits.Contains(weapon.FallbackPaintKit))
|
||||
int[] newPaints = { 1171, 1170, 1169, 1164, 1162, 1161, 1159, 1175, 1174, 1167, 1165, 1168, 1163, 1160, 1166, 1173 };
|
||||
if (newPaints.Contains(weapon.FallbackPaintKit))
|
||||
{
|
||||
skeleton.ModelState.MeshGroupMask = 1;
|
||||
}
|
||||
@@ -323,7 +237,6 @@ namespace WeaponPaints
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Handle exceptions silently
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -336,36 +249,13 @@ namespace WeaponPaints
|
||||
RegisterListener<Listeners.OnMapStart>(OnMapStart);
|
||||
RegisterListener<Listeners.OnTick>(OnTick);
|
||||
|
||||
//RegisterEventHandler<EventPlayerConnectFull>(OnPlayerConnectFull);
|
||||
RegisterEventHandler<EventPlayerSpawn>(OnPlayerSpawn);
|
||||
RegisterEventHandler<EventRoundStart>(OnRoundStart, HookMode.Pre);
|
||||
RegisterEventHandler<EventRoundEnd>(OnRoundEnd);
|
||||
//RegisterEventHandler<EventItemPurchase>(OnEventItemPurchasePost);
|
||||
|
||||
//RegisterEventHandler<EventItemPickup>(OnItemPickup);
|
||||
HookEntityOutput("weapon_knife", "OnPlayerPickup", OnPickup, HookMode.Pre);
|
||||
}
|
||||
|
||||
/* WORKAROUND FOR CLIENTS WITHOUT STEAMID ON AUTHORIZATION */
|
||||
/*private HookResult OnPlayerConnectFull(EventPlayerConnectFull @event, GameEventInfo info)
|
||||
{
|
||||
CCSPlayerController? player = @event.Userid;
|
||||
|
||||
if (player == null || !player.IsValid || !player.EntityIndex.HasValue || player.IsHLTV) return HookResult.Continue;
|
||||
|
||||
int playerIndex = (int)player.EntityIndex.Value.Value;
|
||||
if (Config.Additional.SkinEnabled && weaponSync != null)
|
||||
_ = weaponSync.GetWeaponPaintsFromDatabase(playerIndex);
|
||||
if (Config.Additional.KnifeEnabled && weaponSync != null)
|
||||
_ = weaponSync.GetKnifeFromDatabase(playerIndex);
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
if (Config.Additional.SkinEnabled && weaponSync != null)
|
||||
if (Config.Additional.KnifeEnabled && weaponSync != null)
|
||||
});
|
||||
|
||||
return HookResult.Continue;
|
||||
}
|
||||
*/
|
||||
HookEntityOutput("weapon_knife", "OnPlayerPickup", OnPickup);
|
||||
}
|
||||
}
|
||||
}
|
||||
24
SchemaString.cs
Normal file
24
SchemaString.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Modules.Memory;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
|
||||
namespace WeaponPaints;
|
||||
|
||||
public class SchemaString<TSchemaClass> : NativeObject where TSchemaClass : NativeObject
|
||||
{
|
||||
internal SchemaString(TSchemaClass instance, string member) : base(Schema.GetSchemaValue<nint>(instance.Handle, typeof(TSchemaClass).Name!, member))
|
||||
{ }
|
||||
|
||||
internal unsafe void Set(string str)
|
||||
{
|
||||
var bytes = Encoding.UTF8.GetBytes(str);
|
||||
|
||||
for (var i = 0; i < bytes.Length; i++)
|
||||
{
|
||||
Unsafe.Write((void*)(Handle.ToInt64() + i), bytes[i]);
|
||||
}
|
||||
|
||||
Unsafe.Write((void*)(Handle.ToInt64() + bytes.Length), 0);
|
||||
}
|
||||
}
|
||||
144
WeaponAction.cs
144
WeaponAction.cs
@@ -26,6 +26,8 @@ namespace WeaponPaints
|
||||
weapon.AttributeManager.Item.EntityQuality = 3;
|
||||
}
|
||||
|
||||
int fallbackPaintKit = weapon.FallbackPaintKit;
|
||||
|
||||
if (_config.Additional.GiveRandomSkin &&
|
||||
!gPlayerWeaponsInfo[playerIndex].ContainsKey(weaponDefIndex))
|
||||
{
|
||||
@@ -36,13 +38,29 @@ namespace WeaponPaints
|
||||
weapon.FallbackPaintKit = GetRandomPaint(weaponDefIndex);
|
||||
weapon.FallbackSeed = 0;
|
||||
weapon.FallbackWear = 0.000001f;
|
||||
|
||||
fallbackPaintKit = weapon.FallbackPaintKit;
|
||||
|
||||
if (fallbackPaintKit == 0)
|
||||
return;
|
||||
|
||||
var foundSkin = skinsList.FirstOrDefault(skin =>
|
||||
((int?)skin?["weapon_defindex"] ?? 0) == weaponDefIndex &&
|
||||
((int?)skin?["paint"] ?? 0) == fallbackPaintKit &&
|
||||
skin?["paint_name"] != null
|
||||
);
|
||||
|
||||
string skinName = foundSkin?["paint_name"]?.ToString() ?? "";
|
||||
if (!string.IsNullOrEmpty(skinName))
|
||||
new SchemaString<CEconItemView>(weapon.AttributeManager.Item, "m_szCustomName").Set(skinName);
|
||||
|
||||
if (!isKnife && weapon.CBodyComponent != null && weapon.CBodyComponent.SceneNode != null)
|
||||
{
|
||||
var skeleton = GetSkeletonInstance(weapon.CBodyComponent.SceneNode);
|
||||
|
||||
int[] array = { 1171, 1170, 1169, 1164, 1162, 1161, 1159, 1175, 1174, 1167, 1165, 1168, 1163, 1160, 1166, 1173 };
|
||||
int fallbackPaintKit = weapon.FallbackPaintKit;
|
||||
if (array.Contains(fallbackPaintKit))
|
||||
int[] newPaints = { 1171, 1170, 1169, 1164, 1162, 1161, 1159, 1175, 1174, 1167, 1165, 1168, 1163, 1160, 1166, 1173 };
|
||||
|
||||
if (newPaints.Contains(fallbackPaintKit))
|
||||
{
|
||||
skeleton.ModelState.MeshGroupMask = 1;
|
||||
}
|
||||
@@ -54,6 +72,17 @@ namespace WeaponPaints
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var viewModels = GetPlayerViewModels(player);
|
||||
if (viewModels == null || viewModels.Length == 0)
|
||||
return;
|
||||
|
||||
var viewModel = viewModels[0];
|
||||
if (viewModel == null || viewModel.Value == null || viewModel.Value.Weapon == null || viewModel.Value.Weapon.Value == null)
|
||||
return;
|
||||
|
||||
Utilities.SetStateChanged(viewModel.Value, "CBaseEntity", "m_CBodyComponent");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -67,12 +96,26 @@ namespace WeaponPaints
|
||||
weapon.FallbackSeed = weaponInfo.Seed;
|
||||
weapon.FallbackWear = weaponInfo.Wear;
|
||||
|
||||
fallbackPaintKit = weapon.FallbackPaintKit;
|
||||
|
||||
if (fallbackPaintKit == 0)
|
||||
return;
|
||||
|
||||
var foundSkin1 = skinsList.FirstOrDefault(skin =>
|
||||
((int?)skin?["weapon_defindex"] ?? 0) == weaponDefIndex &&
|
||||
((int?)skin?["paint"] ?? 0) == fallbackPaintKit &&
|
||||
skin?["paint_name"] != null
|
||||
);
|
||||
|
||||
var skinName1 = foundSkin1?["paint_name"]?.ToString() ?? "";
|
||||
if (!string.IsNullOrEmpty(skinName1))
|
||||
new SchemaString<CEconItemView>(weapon.AttributeManager.Item, "m_szCustomName").Set(skinName1);
|
||||
|
||||
if (!isKnife && weapon.CBodyComponent != null && weapon.CBodyComponent.SceneNode != null)
|
||||
{
|
||||
var skeleton = GetSkeletonInstance(weapon.CBodyComponent.SceneNode);
|
||||
int[] array = { 1171, 1170, 1169, 1164, 1162, 1161, 1159, 1175, 1174, 1167, 1165, 1168, 1163, 1160, 1166, 1173 };
|
||||
int fallbackPaintKit = weapon.FallbackPaintKit;
|
||||
if (array.Contains(fallbackPaintKit))
|
||||
int[] newPaints = { 1171, 1170, 1169, 1164, 1162, 1161, 1159, 1175, 1174, 1167, 1165, 1168, 1163, 1160, 1166, 1173 };
|
||||
if (newPaints.Contains(fallbackPaintKit))
|
||||
{
|
||||
skeleton.ModelState.MeshGroupMask = 1;
|
||||
}
|
||||
@@ -84,6 +127,16 @@ namespace WeaponPaints
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var viewModels1 = GetPlayerViewModels(player);
|
||||
if (viewModels1 == null || viewModels1.Length == 0)
|
||||
return;
|
||||
|
||||
var viewModel1 = viewModels1[0];
|
||||
if (viewModel1 == null || viewModel1.Value == null || viewModel1.Value.Weapon == null || viewModel1.Value.Weapon.Value == null)
|
||||
return;
|
||||
|
||||
Utilities.SetStateChanged(viewModel1.Value, "CBaseEntity", "m_CBodyComponent");
|
||||
}
|
||||
|
||||
internal static void GiveKnifeToPlayer(CCSPlayerController? player)
|
||||
@@ -144,79 +197,6 @@ namespace WeaponPaints
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
internal void RefreshPlayerKnife(CCSPlayerController? player)
|
||||
{
|
||||
return;
|
||||
if (player == null || !player.IsValid || player.PlayerPawn.Value == null || !player.PawnIsAlive) return;
|
||||
if (player.PlayerPawn.Value.WeaponServices == null || player.PlayerPawn.Value.ItemServices == null) return;
|
||||
|
||||
var weapons = player.PlayerPawn.Value.WeaponServices.MyWeapons;
|
||||
if (weapons != null && weapons.Count > 0)
|
||||
{
|
||||
CCSPlayer_ItemServices service = new(player.PlayerPawn.Value.ItemServices.Handle);
|
||||
//var dropWeapon = VirtualFunction.CreateVoid<nint, nint>(service.Handle, GameData.GetOffset("CCSPlayer_ItemServices_DropActivePlayerWeapon"));
|
||||
|
||||
foreach (var weapon in weapons)
|
||||
{
|
||||
if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid)
|
||||
{
|
||||
//if (weapon.Value.AttributeManager.Item.ItemDefinitionIndex == 42 || weapon.Value.AttributeManager.Item.ItemDefinitionIndex == 59)
|
||||
if (weapon.Value.DesignerName.Contains("knife") || weapon.Value.DesignerName.Contains("bayonet"))
|
||||
{
|
||||
if (weapon.Index <= 0) return;
|
||||
int weaponEntityIndex = (int)weapon.Index;
|
||||
NativeAPI.IssueClientCommand((int)player.Index - 1, "slot3");
|
||||
AddTimer(0.22f, () =>
|
||||
{
|
||||
if (player.PlayerPawn.Value.WeaponServices.ActiveWeapon.Value!.DesignerName.Contains("knife")
|
||||
||
|
||||
player.PlayerPawn.Value.WeaponServices.ActiveWeapon.Value!.DesignerName.Contains("bayonet")
|
||||
)
|
||||
{
|
||||
if (player.PawnIsAlive)
|
||||
{
|
||||
NativeAPI.IssueClientCommand((int)player.Index - 1, "slot3");
|
||||
service.DropActivePlayerWeapon(weapon.Value);
|
||||
GiveKnifeToPlayer(player);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Task.Delay(TimeSpan.FromSeconds(3.5)).ContinueWith(_ =>
|
||||
{
|
||||
try
|
||||
{
|
||||
CEntityInstance? knife = Utilities.GetEntityFromIndex<CEntityInstance>(weaponEntityIndex);
|
||||
|
||||
if (knife != null && knife.IsValid && knife.Handle != -1 && knife.Index > 0)
|
||||
{
|
||||
knife.Remove();
|
||||
}
|
||||
}
|
||||
catch (Exception) { }
|
||||
});
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
internal void RefreshSkins(CCSPlayerController? player)
|
||||
{
|
||||
return;
|
||||
if (!Utility.IsPlayerValid(player) || !player!.PawnIsAlive) return;
|
||||
|
||||
AddTimer(0.18f, () => NativeAPI.IssueClientCommand((int)player.Index - 1, "slot3"));
|
||||
AddTimer(0.25f, () => NativeAPI.IssueClientCommand((int)player.Index - 1, "slot2"));
|
||||
AddTimer(0.38f, () => NativeAPI.IssueClientCommand((int)player.Index - 1, "slot1"));
|
||||
}
|
||||
*/
|
||||
|
||||
internal void RefreshWeapons(CCSPlayerController? player)
|
||||
{
|
||||
if (player == null || !player.IsValid || player.PlayerPawn?.Value == null || (LifeState_t)player.LifeState != LifeState_t.LIFE_ALIVE)
|
||||
@@ -229,9 +209,6 @@ namespace WeaponPaints
|
||||
if (weapons == null || weapons.Count == 0)
|
||||
return;
|
||||
|
||||
// Dictionary to store weapons and their ammo
|
||||
|
||||
|
||||
if (weapons != null && weapons.Count > 0)
|
||||
{
|
||||
//Dictionary<string, (int, int)> weaponsWithAmmo = new Dictionary<string, (int, int)>();
|
||||
@@ -270,7 +247,7 @@ namespace WeaponPaints
|
||||
}
|
||||
}
|
||||
|
||||
if (!weapon.Value.DesignerName.Contains("knife") && weaponDefindex.TryGetValue(weapon.Value.AttributeManager.Item.ItemDefinitionIndex, out weaponByDefindex) && weaponByDefindex != null)
|
||||
if (!weapon.Value.DesignerName.Contains("knife") && WeaponDefindex.TryGetValue(weapon.Value.AttributeManager.Item.ItemDefinitionIndex, out weaponByDefindex) && weaponByDefindex != null)
|
||||
{
|
||||
int clip1 = weapon.Value.Clip1;
|
||||
int reservedAmmo = weapon.Value.ReserveAmmo[0];
|
||||
@@ -418,6 +395,5 @@ namespace WeaponPaints
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -81,6 +81,7 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
||||
internal static List<JObject> skinsList = new List<JObject>();
|
||||
internal static WeaponSynchronization? weaponSync;
|
||||
internal bool g_bCommandsAllowed = true;
|
||||
internal Dictionary<int, string> PlayerWeaponImage = new();
|
||||
|
||||
internal Uri GlobalShareApi = new("https://weaponpaints.fun/api.php");
|
||||
internal int GlobalShareServerId = 0;
|
||||
@@ -88,7 +89,7 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
||||
internal static Database? _database;
|
||||
|
||||
//private CounterStrikeSharp.API.Modules.Timers.Timer? g_hTimerCheckSkinsData = null;
|
||||
public static Dictionary<int, string> weaponDefindex { get; } = new Dictionary<int, string>
|
||||
public static Dictionary<int, string> WeaponDefindex { get; } = new Dictionary<int, string>
|
||||
{
|
||||
{ 1, "weapon_deagle" },
|
||||
{ 2, "weapon_elite" },
|
||||
@@ -151,7 +152,7 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
||||
public override string ModuleAuthor => "Nereziel & daffyy";
|
||||
public override string ModuleDescription => "Skin and knife selector, standalone and web-based";
|
||||
public override string ModuleName => "WeaponPaints";
|
||||
public override string ModuleVersion => "1.6c";
|
||||
public override string ModuleVersion => "1.7a";
|
||||
|
||||
public static WeaponPaintsConfig GetWeaponPaintsConfig()
|
||||
{
|
||||
@@ -160,7 +161,7 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
||||
|
||||
public override void Load(bool hotReload)
|
||||
{
|
||||
if (hotReload && weaponSync != null)
|
||||
if (hotReload)
|
||||
{
|
||||
OnMapStart(string.Empty);
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.163" />
|
||||
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.167" />
|
||||
<PackageReference Include="Dapper" Version="2.1.28" />
|
||||
<PackageReference Include="MySqlConnector" Version="2.3.5" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
|
||||
12078
website/data/skins.json
12078
website/data/skins.json
File diff suppressed because one or more lines are too long
@@ -8,7 +8,7 @@ $weapons = array (
|
||||
"weapon_aug" => 8,
|
||||
"weapon_awp" => 9,
|
||||
"weapon_famas" => 10,
|
||||
"weapon_g3sg1" => 10,
|
||||
"weapon_g3sg1" => 11,
|
||||
"weapon_galilar" => 13,
|
||||
"weapon_m249" => 14,
|
||||
"weapon_m4a1" => 16,
|
||||
@@ -53,7 +53,14 @@ $weapons = array (
|
||||
"weapon_knife_stiletto" => 522,
|
||||
"weapon_knife_widowmaker" => 523,
|
||||
"weapon_knife_skeleton" => 525);
|
||||
$json = json_decode(file_get_contents('skins.json'));
|
||||
|
||||
|
||||
|
||||
$
|
||||
|
||||
$json = json_decode(file_get_contents('https://bymykel.github.io/CSGO-API/api/en/skins.json'));
|
||||
|
||||
die(var_dump($json));
|
||||
echo "<pre>";
|
||||
foreach($json as $skin)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user