Jump to content
For maintenance and updates, the community will be offline on 31 December 2022 ×
  • 0

Quest to check if item exist in inventory?


covfefe

Question

Hello I need help writing a quest that would detect if an item exists in inventory, but it has to be without login trigger

It only works when I do it like this:

quest item_detect begin
    state start begin
    when login or enter begin
        if pc.count_item(50709)==1 then
        chat("You have x item in your inventory.")
end
end
end
end

My intended result is to make the quest spontaneously spit this chat whenever player receives said item in inventory, whether through exchange, drop, or other means, without waiting for login to trigger it.

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0
  • Nitro Booster

If the item you are checking is quest type, then you can only check whether you have picked the item from the ground using the “pick” trigger which is called like this:

quest detect_item begin
	state start begin
		when 50709.pick begin
			chat("You have x item in your inventory.")
		end
	end
end

Quests are limited, you can't check every action you so this isn't possible unless you add a new trigger to your quest manager source file.

The only solution if you want to do this via quest without modifying the source is to use a timer to keep checking for the item but I strongly don’t recommend this.
Regardless, this is how you would do it:

quest detect_item begin
	state start begin
		function get(vnum, count)
			if pc.count_item(vnum) >= count then
				return true
			end
			return false
		end

		when login begin
			timer("item_detector_1", 3)
		end

		when item_detector_1.timer begin
			if detect_item.check(50709, 1) then
				chat("You have x item in your inventory.")
			end
			timer("item_detector_2", 3)
		end

		when item_detector_2.timer begin
			if detect_item.check(50709, 1) then
				chat("You have x item in your inventory.")
			end
			timer("item_detector_1", 3)
		end
	end
end

 

Edited by Owsap
  • Metin2 Dev 1
Link to comment
Share on other sites

  • 0
  • Premium
3 hours ago, covfefe said:

that's gonna eat all of my CPU usage..

?

Sir, I don't think you have any idea how timers work. Also...

Quote

make the quest spontaneously spit this chat whenever player receives said item in inventory, whether through exchange, drop, or other means, without waiting for login to trigger it.

The green part is doable in lua, via the method @Owsap explained, the .pick trigger.

The red part is not doable in lua, since there's no trigger for exchange.

 

Timers would be useless here, but they don't "EAT YOUR CPU".

 

Quote

WoM2 did it so there must be a way.

It's easy to make a new trigger for that, but you have to make changes to the sourcecode, you can't do that with what the default Metin2 triggers.

Edited by Syreldar

 

"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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Activity

    1. 0

      Need Help With Char_Item.cpp

    2. 0

      ULTERIUS2.COM

    3. 7

      Killua - Unholy God Set

    4. 2

      Visual studio 2022 compiling issue

    5. 991

      [40250] Reference Serverfile + Client + Src [15 Available Languages]

  • Recently Browsing

    • No registered users viewing this page.
×
×
  • 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.