Jump to content

Recommended Posts

Hello guys,any1 have functions of this ? If a player want buy somthing on the shop or quest,items drop down..i want some function to stop that and check if player have necesarry space in inventory/bag,i try on quest but now working,i need that in my source,thx.

Link to comment
https://metin2.dev/topic/15798-check-if-player-have-space-in-inventory/
Share on other sites

  • Honorable Member
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

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

  • Honorable Member
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

	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
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 ?

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

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • 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.