Jump to content

Check if player have space in inventory


Recommended Posts

  • Premium
quest give_item_with_check begin
	state start begin
		when 9001.chat."Give me the item" begin
			local item_vnum = 27001;
			
			say_title(string.format("%s:[ENTER]", mob_name(npc.get_race())))
			if (pc.enough_inventory(item_vnum)) then
				pc.give_item2(item_vnum);
				say(string.format("You have received %s.[ENTER]", item_name(item_vnum)))
			else
				say_reward(string.format("You don't have enough space for %s.[ENTER]", item_name(item_vnum)))
			end -- if/else
			
			say_item_vnum(item_vnum);
		end -- when
	end -- state
end -- quest

 

  • Love 1

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

Acum 11 ore, Syreldar a spus:

quest give_item_with_check begin
	state start begin
		when 9001.chat."Give me the item" begin
			local item_vnum = 27001;
			
			say_title(string.format("%s:[ENTER]", mob_name(npc.get_race())))
			if (pc.enough_inventory(item_vnum)) then
				pc.give_item2(item_vnum);
				say(string.format("You have received %s.[ENTER]", item_name(item_vnum)))
			else
				say_reward(string.format("You don't have enough space for %s.[ENTER]", item_name(item_vnum)))
			end -- if/else
			
			say_item_vnum(item_vnum);
		end -- when
	end -- state
end -- quest

 

Yeah mate,but this function 

if (pc.enough_inventory(item_vnum))

i need in my source too right ?

And for shop? If i buy from npc items and i have full bag,items drop down,have solution for this ? Thanx

Link to comment
Share on other sites

  • Premium
8 hours ago, emanuel said:

Yeah mate,but this function 


if (pc.enough_inventory(item_vnum))

i need in my source too right ?

And for shop? If i buy from npc items and i have full bag,items drop down,have solution for this ? Thanx

The shop automatically handles inventory space, if it doesn't you should really consider fixing it, and no, you don't need to add pc.enough_inventory(vnum) in source, it already exists.

  • Love 1

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

	int pc_get_empty_inventory_size(lua_State* L)
	{
		LPCHARACTER pChar = CQuestManager::instance().GetCurrentCharacterPtr();

		if (lua_isnumber(L, 1) == false){
			lua_pushboolean(L, false);
			return 1;
		}

		int size = (int)lua_tonumber(L, 1);
		
		if (pChar != NULL)
		{
			int iEmptyCell = pChar->GetEmptyInventory(size);

			if (-1 == iEmptyCell)
			{
				lua_pushboolean(L, false);
				return 1;
			}
		
			lua_pushboolean(L, true);
		}
		else
		{
			lua_pushboolean(L, false);
		}

		return 1;
	}

 

credits: DragonSlayer

  • Love 1
Link to comment
Share on other sites

Acum 24 minute, kimameixede a spus:

	int pc_get_empty_inventory_size(lua_State* L)
	{
		LPCHARACTER pChar = CQuestManager::instance().GetCurrentCharacterPtr();

		if (lua_isnumber(L, 1) == false){
			lua_pushboolean(L, false);
			return 1;
		}

		int size = (int)lua_tonumber(L, 1);
		
		if (pChar != NULL)
		{
			int iEmptyCell = pChar->GetEmptyInventory(size);

			if (-1 == iEmptyCell)
			{
				lua_pushboolean(L, false);
				return 1;
			}
		
			lua_pushboolean(L, true);
		}
		else
		{
			lua_pushboolean(L, false);
		}

		return 1;
	}

 

credits: DragonSlayer

hello mate,where to add this function ? It's for npc shop to check inventory space when buying ?

Link to comment
Share on other sites

1 oră în urmă, Syreldar a spus:

The shop automatically handles inventory space, if it doesn't you should really consider fixing it, and no, you don't need to add pc.enough_inventory(vnum) in source, it already exists.

Can you give me function for this fix bro? And if you can say me where to put it ? Function for check inventory space when buying from npc shop,thank you!

  • Not Good 1
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.