Bgrade no found.

Error while compiling BGrade: 'PlayerInventory' does not contain a definition for 'AllItems' and no accessible extension method 'AllItems' accepting a first argument of type 'PlayerInventory' could be found (are you missing a using directive or an assembly reference?) | Line: 800, Pos: 51

public static bool HasItemAmount(this BasePlayer player, int itemId, int itemAmount)
{
var count = 0;
foreach (var item in player.inventory.AllItems())
{
if (item.info.itemid == itemId)
{
count += item.amount;
}
}

return count >= itemAmount;
}

public static bool HasItemAmount(this BasePlayer player, int itemId, int itemAmount, out int amountGot)
{
var count = 0;
foreach (var item in player.inventory.AllItems())
{
if (item.info.itemid == itemId)
{
count += item.amount;
}
}

amountGot = count;
return count >= itemAmount;
}

 

//////

 

change to 

 

public static bool HasItemAmount(this BasePlayer player, int itemId, int itemAmount)
{
var items = new List<Item>();
player.inventory.GetAllItems(items);
var count = items.Where(item => item.info.itemid == itemId).Sum(item => item.amount);

return count >= itemAmount;
}

public static bool HasItemAmount(this BasePlayer player, int itemId, int itemAmount, out int amountGot)
{
var items = new List<Item>();
player.inventory.GetAllItems(items);
var count = items.Where(item => item.info.itemid == itemId).Sum(item => item.amount);

amountGot = count;
return count >= itemAmount;
}

 

////////

797-824

Works a treat, thanks!

Thnx works like a charm!!

Thank you very much! Works great. 🙂

Alternatively:

var count = player.inventory.GetAmount(itemId) + player.inventory.GetBackpackWithInventory()?.contents.GetAmount(itemId, true) ?? 0;
​

can someone please send the cs file with this change completed please

How lazy can you get 🤣

Now don't tear me apart. This is my first server. lol. Where and how do I make these changes. I'm not seeing a similar file anywhere.

beast1818642

Now don't tear me apart. This is my first server. lol. Where and how do I make these changes. I'm not seeing a similar file anywhere.

Add me on discord and ill send ya the file mate

htmlSh3wbejUsbb.png JimDeadlock

How lazy can you get 🤣

Its not called being lazy, dickbag. I dont have the skills and or knowhow to code let alone changing it (Which i did it myself in the end regardless). Have a "lovely day" 

It's just replacing some text with other text, it's not rocket science

terrabash

public static bool HasItemAmount(this BasePlayer player, int itemId, int itemAmount)
{
var count = 0;
foreach (var item in player.inventory.AllItems())
{
if (item.info.itemid == itemId)
{
count += item.amount;
}
}

return count >= itemAmount;
}

public static bool HasItemAmount(this BasePlayer player, int itemId, int itemAmount, out int amountGot)
{
var count = 0;
foreach (var item in player.inventory.AllItems())
{
if (item.info.itemid == itemId)
{
count += item.amount;
}
}

amountGot = count;
return count >= itemAmount;
}

 

//////

 

change to 

 

public static bool HasItemAmount(this BasePlayer player, int itemId, int itemAmount)
{
var items = new List<Item>();
player.inventory.GetAllItems(items);
var count = items.Where(item => item.info.itemid == itemId).Sum(item => item.amount);

return count >= itemAmount;
}

public static bool HasItemAmount(this BasePlayer player, int itemId, int itemAmount, out int amountGot)
{
var items = new List<Item>();
player.inventory.GetAllItems(items);
var count = items.Where(item => item.info.itemid == itemId).Sum(item => item.amount);

amountGot = count;
return count >= itemAmount;
}

 

////////

797-824

Error while compiling BGrade: 'Pool' does not contain a definition for 'GetList' | Line: 575, Pos: 52