how to use GetFreeSlots function?

Hi everybody i have a question about of the slot of the bags.

how to check what the player have free slot?

find in the documentation, the function GetFreeSlots

http://docs.trinitycore.info/classBag.html

how to used in the code?

what class has reference?

sorry i am newbie.

thanks.

Alright you want help, how about explaining what your trying to achieve? whats the end result ?

I want to deliver items to players through a gossip npc with c++ (CreateureScript), I need to validate that have space bag.

Alright i understand do you currently have anything to show ? Now before you awnser i’m just going to quote the rules of Custom Code Section of the forums,

You must post the full patch when requesting help for a custom patch. If you are converting a custom patch from other core to Trinitycode, you must post your conversion code.

Any help request without full patch will be closed.

So if you have any work please show us so we can properly help ya. Thanks!

rev: TrinityCore-TrinityCore-a05e78b

the code:

http://www.trinitycore.org/f/topic/7021-telenpcc-hot-features/

line code specific:

if(player->getClass() == CLASS_SHAMAN && player->getLevel() == 80)
{
if(!player->HasItemCount(5175 ,1 , true))
player->AddItem(5175, 1);
if(!player->HasItemCount(5176 ,1 , true))
player->AddItem(5176, 1);
if(!player->HasItemCount(5177 ,1 , true))
player->AddItem(5177, 1);
if(!player->HasItemCount(5178 ,1 , true))
player->AddItem(5178, 1);
player->CLOSE_GOSSIP_MENU();

need checked what the player have slot free in the bags.

PD: More data are needed?

thanks for you support.

I’ll ask around, but the more the community knows the better it is for you /emoticons/default_smile.png this way the community won’t have to guess and can help you to the best of our ability /emoticons/default_biggrin.png

Just trying to help you get the help you need /emoticons/default_smile.png

https://github.com/TrinityCore/TrinityCore/blob/master/src/server/game/Entities/Player/Player.cpp#L10726 - Look at how it’s handled in core. Can’t get much easier.

Or, if you want to make it funnier and learn something, create your own HasFreeBagSpace/GetFreeBagSpace functions. Pro-tip: iterate from INVENTORY_SLOT_BAG_START to INVENTORY_SLOT_BAG_END, find the bag for that specific slot, iterate from 0 to space that specific bagspot has and validate there are no items inside the slots.