Skip to content

Commit

Permalink
- Fixed playerskin menu
Browse files Browse the repository at this point in the history
  • Loading branch information
schwarper authored Aug 4, 2024
1 parent 54a5530 commit e4a941e
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 28 deletions.
1 change: 0 additions & 1 deletion Store/src/database/database.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Admin;
using CounterStrikeSharp.API.Modules.Entities;
using Dapper;
using Microsoft.Extensions.Logging;
using MySqlConnector;
Expand Down
4 changes: 2 additions & 2 deletions Store/src/event/event.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ public static void OnTick()
{
Menu.OnTick();

var players = Utilities.GetPlayers().Where(p => p.PawnIsAlive).ToList();
List<CCSPlayerController> players = Utilities.GetPlayers().Where(p => p.PawnIsAlive).ToList();

foreach (var player in players)
foreach (CCSPlayerController? player in players)
{
Item_Bunnyhop.OnTick(player);
}
Expand Down
4 changes: 2 additions & 2 deletions Store/src/item/item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public static bool Equip(CCSPlayerController player, Dictionary<string, string>
return false;
}

var currentitems = Instance.GlobalStorePlayerEquipments.FindAll(p =>
List<Store_Equipment> currentitems = Instance.GlobalStorePlayerEquipments.FindAll(p =>
p.SteamID == player.SteamID &&
p.Type == item["type"] &&
(type.Type == "playerskin" && item["slot"] == "1" || p.Slot == 1) ||
Expand All @@ -94,7 +94,7 @@ public static bool Equip(CCSPlayerController player, Dictionary<string, string>

if (currentitems.Count > 0)
{
foreach (var currentitem in currentitems)
foreach (Store_Equipment? currentitem in currentitems)
{
Dictionary<string, string>? citem = GetItem(currentitem.Type, currentitem.UniqueId);

Expand Down
1 change: 0 additions & 1 deletion Store/src/item/items/bunnyhop.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using System.Globalization;
using static Store.Store;

namespace Store;
Expand Down
14 changes: 8 additions & 6 deletions Store/src/item/items/equipment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public static bool OnUnequip(CCSPlayerController player, Dictionary<string, stri
public static void Equip(CCSPlayerController player)
{
UnEquip(player);
Instance.AddTimer(0.1f, () => {
Instance.AddTimer(0.1f, () =>
{
Store_Equipment? playerItems = Instance.GlobalStorePlayerEquipments.FirstOrDefault(p => p.SteamID == player.SteamID && p.Type == "equipment");
if (playerItems == null) return;

Expand All @@ -56,7 +57,7 @@ public static void Equip(CCSPlayerController player)
}
public static void UnEquip(CCSPlayerController player)
{
if (Equipment.TryGetValue(player.SteamID, out var entity))
if (Equipment.TryGetValue(player.SteamID, out CBaseModelEntity? entity))
{
if (entity.IsValid) entity.Remove();
Equipment.Remove(player.SteamID);
Expand All @@ -65,9 +66,10 @@ public static void UnEquip(CCSPlayerController player)

public static void CreateItem(CCSPlayerController player, string itemName)
{
var entity = Utilities.CreateEntityByName<CBaseModelEntity>("prop_dynamic_override");
CBaseModelEntity? entity = Utilities.CreateEntityByName<CBaseModelEntity>("prop_dynamic_override");

Instance.AddTimer(0.1f, () => {
Instance.AddTimer(0.1f, () =>
{
entity!.Globalname = $"{player.SteamID}({itemName})#{RandomString(6)}";
entity.SetModel(itemName);
entity.DispatchSpawn();
Expand All @@ -85,8 +87,8 @@ public static HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo in
public static string RandomString(int length)
{
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var random = new Random();
var result = new char[length];
Random random = new();
char[] result = new char[length];
for (int i = 0; i < length; i++)
result[i] = chars[random.Next(chars.Length)];

Expand Down
1 change: 0 additions & 1 deletion Store/src/item/items/tag.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Capabilities;
using CounterStrikeSharp.API.Modules.Utils;
Expand Down
16 changes: 2 additions & 14 deletions Store/src/menu/menu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,8 @@ public static void DisplayItems(CCSPlayerController player, string key, Dictiona

foreach (int Slot in new[] { 1, 2, 3 })
{
if (Slot == 1 && !playerSkinItems.Any(p => p.Value.TryGetValue("slot", out string? slot) && slot == "1"))
{
continue;
}
if (Slot == 2 && !playerSkinItems.Any(p => p.Value.TryGetValue("slot", out string? slot) && slot == "2"))
{
continue;
}
if (Slot == 3 && !playerSkinItems.Any(p => p.Value.TryGetValue("slot", out string? slot) && slot == "3"))
{
continue;
}

if (inventory && !playerSkinItems.Any(item => Item.PlayerHas(player, item.Value["type"], item.Value["uniqueid"], false)))
if ((!playerSkinItems.Any(p => p.Value.TryGetValue("slot", out string? slot) && slot == Slot.ToString())) ||
(inventory && !playerSkinItems.Any(item => Item.PlayerHas(player, item.Value["type"], item.Value["uniqueid"], false))))
{
continue;
}
Expand Down
3 changes: 2 additions & 1 deletion Store/src/menu/oldmenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public static void DisplayItems(CCSPlayerController player, string key, Dictiona

foreach (int Slot in new[] { 1, 2, 3 })
{
if (inventory && !playerSkinItems.Any(item => Item.PlayerHas(player, item.Value["type"], item.Value["uniqueid"], false)))
if ((!playerSkinItems.Any(p => p.Value.TryGetValue("slot", out string? slot) && slot == Slot.ToString())) ||
(inventory && !playerSkinItems.Any(item => Item.PlayerHas(player, item.Value["type"], item.Value["uniqueid"], false))))
{
continue;
}
Expand Down

0 comments on commit e4a941e

Please sign in to comment.