Jump to content

Recommended Posts

  • Former Staff

quest exchange begin
	state start begin
		when 20093.take begin
			if item.get_vnum() == 10 then
				say("Ok... i will exchange it for a claw")
				item.remove()
				pc.give_item2(27987)
			end
		end
	end
end

Is it possible to make like this?

			if item.get_vnum() == 10 or 20 or 30 or 40 then

Link to comment
https://metin2.dev/topic/5647-exchange/#findComment-35710
Share on other sites

  • Premium

 

quest exchange begin
	state start begin
		when 20093.take begin
			if item.get_vnum() == 10 then
				say("Ok... i will exchange it for a claw")
				item.remove()
				pc.give_item2(27987)
			end
		end
	end
end

Is it possible to make like this?

			if item.get_vnum() == 10 or 20 or 30 or 40 then

 

Of course... just add "item.get_vnum() == xx"... for example

if item.get_vnum() == 10 or item.get_vnum() == 20 or item.get_vnum() == 30 or item.get_vnum() == 40 or  item.get_vnum() == 40 or then

But as you see, code will be too long if you need to add many items. So, in this way can be this:

quest exchange begin
    state start begin
		when 20093.take begin
			local items = {10, 20, 30, 40, 50} -- put here all items you want exchange
				local i
				for i = 1, table.getn(items), 1 do
					if items[i] == item.get_vnum() then
						say("Ok... i will exchange it for a claw")
						item.remove()
						pc.give_item2(27987)
						return
					end
				end
			say ("This item can't be exchanged")
		end
	end
end
  • Love 2
Link to comment
https://metin2.dev/topic/5647-exchange/#findComment-35722
Share on other sites

  • Premium

 

Shisui: no.

when 20017.take with tonumber(string.sub(item.vnum, -1)) == 0  -- gets the last number   
    and item.get_type() == 1 begin -- checks if weapon
   -- your code goes here
end

For who don't understand this code: every upgradable item start with vnum xx0 (xx is initial vnum) for item +0 and end with xx9 for item +9

The above code extract the last number of vnum and compare this with 0 so... only item +0 can return true.

  • Love 2
Link to comment
https://metin2.dev/topic/5647-exchange/#findComment-35726
Share on other sites

I will try it in the evening and let you guys know, i tried it the way @r00t shown here but it accepted all items, not just ones from the table :) will definately try @metin2team way because it looks the best to me :)

@ edit @metin2team way works as charm :) thank you guys for help , if any1 wants to do different items for for example bow then just add ...and item.get_sub_type() == 3 then , but chceck in navicat subtype table in item proto for the number

Link to comment
https://metin2.dev/topic/5647-exchange/#findComment-35752
Share on other sites

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.