Jump to content

Reward 2


Go to solution Solved by r00t,

Recommended Posts

  • Premium

quest metin5 begin
	state start begin
		when 8001.kill begin
				local lvlmin= 1
				local lvlmax= 10
				local reward1 = 50300
				local item_table = { 11202 , 11402 , 11602 , 11802 , 21002 }
				local Irandom = number(1,table.getn(item_table) )
				local reward2 = item_table[Irandom]
				if pc.level >=lvlmin and pc.level <=lvlmax then
					local r1=number(1, 5)
					if r1>=2 then
						game.drop_item_with_ownership(reward1, 1)
					end
					local r2=number(1, 3)
					if r2>=2 then
						game.drop_item_with_ownership(reward2, 1)
					end
				else
			end
		end
	end
end

I want to put the reward2 giving sometimes more than 1 item

 

I can giving more than 1 item but the item it's multiplied by the first reward2.

Help?  :rolleyes:

Link to comment
Share on other sites

  • Premium

I don't undestand what you mean... do you need to drop sometime another, different or not, item from item_table? Or just more item of reward2?

game.drop_item_with_ownership(reward2, 1)

reward2 is giving 1 item

I want: reward2 give sometimes more than 1 item from 

local item_table
Link to comment
Share on other sites

  • Premium

I dont like just solving the problem for somebody so he doesnt learn anything so ill just give you a little hint:

 

Look for the loop "for", you can iterate through the item_table

 

PS: you can get the loops end by table.getn(item_table)

I created this quest (I code myself)

I don't understand english very well

I'm a pro just to write.  :( //more 1 hint//

Link to comment
Share on other sites

  • Premium

Problem (i think :lol: ) is this... function "game.drop_item_with_ownership(X,Y)" drop Y quantity of X item... but if you put 200 as Y you will see on the floor always 1 item but it's stacked in 200. In your table you put items can't be stacked (armor) so you will drag always 1 item. Try to change your table with items such as potion red, blu etc... and you will see that it work :P

Link to comment
Share on other sites

  • Premium

Problem (i think :lol: ) is this... function "game.drop_item_with_ownership(X,Y)" drop Y quantity of X item... but if you put 200 as Y you will see on the floor always 1 item but it's stacked in 200. In your table you put items can't be stacked (armor) so you will drag always 1 item. Try to change your table with items such as potion red, blu etc... and you will see that it work :P

This works but not random, exit always 2 items = ex: 11202, 11202

quest metin5 begin
    state start begin
        when 8001.kill begin
                local lvlmin= 1
                local lvlmax= 10
                local reward1 = 50300
                local item_table = { 11202 , 11402 , 11602 , 11802 , 21002 }
                local Irandom = number(1,table.getn(item_table) )
                local reward2 = item_table[Irandom]
                if pc.level >=lvlmin and pc.level <=lvlmax then
                    local r1=number(1, 5)
                    if r1>=2 then
                        game.drop_item_with_ownership(reward1, 1)
                    end
                    local r2=number(1, 3)
                    if r2>=2 then
                        pc.give_item2(reward2, 1)
						pc.give_item2(reward2, 1)
                    end
                else
            end
        end
    end
end
Link to comment
Share on other sites

  • Premium

You don't understand... if item can't be stacked (set by anti-flag in item_proto) you will always drop or receive 1 item. Function pc.give_item2(X,Y) is same of game.drop_item_with_ownership(X,Y) because you will receive/drop item X stacked in Y pieces.

So if item are not stacked... in Y you can put any number you want but quantity received is 1.

Link to comment
Share on other sites

  • Premium

You don't understand... if item can't be stacked (set by anti-flag in item_proto) you will always drop or receive 1 item. Function pc.give_item2(X,Y) is same of game.drop_item_with_ownership(X,Y) because you will receive/drop item X stacked in Y pieces.

So if item are not stacked... in Y you can put any number you want but quantity received is 1.

I know but like @.InyaProduction

explained i can use the for-loop(lua)

 

for variable = 0, 10, 2 do
    print ( variable )
end

To do this (what I want)

This simple quest is so  :excl:

Link to comment
Share on other sites

quest metin5 begin
    state start begin
        when 8001.kill begin
                local lvlmin= 1
                local lvlmax= 10
                local reward1 = 50300
                local item_table = { 11202 , 11402 , 11602 , 11802 , 21002 }
                local Irandom = number(1,table.getn(item_table) )
                local reward2 = item_table[Irandom]
                if pc.level >=lvlmin and pc.level <=lvlmax then
                    local r1=number(1, 5)
                    if r1>=2 then
                        game.drop_item_with_ownership(reward1, 1)
                    end
                    local r2=number(1, 3)
                    if r2>=2 then
						local r3=number(1, 5)
						if r3 == 1 then
							game.drop_item_with_ownership(reward2, 1)
						elseif r3 == 2 then
							game.drop_item_with_ownership(reward2, 1)
							game.drop_item_with_ownership(reward2, 1)
						elseif r3 == 3 then
							game.drop_item_with_ownership(reward2, 1)
							game.drop_item_with_ownership(reward2, 1)
							game.drop_item_with_ownership(reward2, 1)
						elseif r3 == 4 then
							game.drop_item_with_ownership(reward2, 1)
							game.drop_item_with_ownership(reward2, 1)
							game.drop_item_with_ownership(reward2, 1)
							game.drop_item_with_ownership(reward2, 1)
						elseif r3 == 5 then
							game.drop_item_with_ownership(reward2, 1)
							game.drop_item_with_ownership(reward2, 1)
							game.drop_item_with_ownership(reward2, 1)
							game.drop_item_with_ownership(reward2, 1)
							game.drop_item_with_ownership(reward2, 1)
						end
                    end
                end

        end
    end
end

LE: there was an extra 'end'

Edited by pbuzz
Link to comment
Share on other sites

  • Premium
quest metin5 begin
    state start begin
        when 8001.kill begin
            local lvlmin= 1
            local lvlmax= 10
            local reward1 = 50300
            local item_table = { 11202 , 11402 , 11602 , 11802 , 21002 }
            local Irandom = number(1,table.getn(item_table) )
            local reward2 = item_table[Irandom]
            if pc.level >=lvlmin and pc.level <=lvlmax then
                local r1=number(1, 5)
                if r1>=2 then
                    game.drop_item_with_ownership(reward1, 1)
                end
                local r2=number(1, 3)
                if r2>=2 then
                    local quantity = number(1,5) -- how many item of reward2 will dropped
                    local i
                    for i=1,quantity,1 do
                        game.drop_item_with_ownership(reward2, 1)
                    end    
                end
            else
                -- ? xD
            end
        end
    end
end
Link to comment
Share on other sites

  • Premium

quest metin5 begin
    state start begin
        when 8001.kill begin
                local lvlmin= 1
                local lvlmax= 10
                local reward1 = 50300
                local item_table = { 11202 , 11402 , 11602 , 11802 , 21002 }
                local Irandom = number(1,table.getn(item_table) )
                local reward2 = item_table[Irandom]
                if pc.level >=lvlmin and pc.level <=lvlmax then
                    local r1=number(1, 5)
                    if r1>=2 then
                        game.drop_item_with_ownership(reward1, 1)
                    end
                    local r2=number(1, 3)
                    if r2>=2 then
						local r3=number(1, 5)
						if r3 == 1 then
							game.drop_item_with_ownership(reward2, 1)
						elseif r3 == 2 then
							game.drop_item_with_ownership(reward2, 1)
							game.drop_item_with_ownership(reward2, 1)
						elseif r3 == 3 then
							game.drop_item_with_ownership(reward2, 1)
							game.drop_item_with_ownership(reward2, 1)
							game.drop_item_with_ownership(reward2, 1)
						elseif r3 == 4 then
							game.drop_item_with_ownership(reward2, 1)
							game.drop_item_with_ownership(reward2, 1)
							game.drop_item_with_ownership(reward2, 1)
							game.drop_item_with_ownership(reward2, 1)
						elseif r3 == 5 then
							game.drop_item_with_ownership(reward2, 1)
							game.drop_item_with_ownership(reward2, 1)
							game.drop_item_with_ownership(reward2, 1)
							game.drop_item_with_ownership(reward2, 1)
							game.drop_item_with_ownership(reward2, 1)
						end
                    end
                end

        end
    end
end
LE: there was an extra 'end'

 

No way.

Will lag the server.

That quest will be used in all metins / mobs

Link to comment
Share on other sites

  • Premium
quest metin5 begin
    state start begin
        when 8001.kill begin
            local lvlmin= 1
            local lvlmax= 10
            local reward1 = 50300
            local item_table = { 11202 , 11402 , 11602 , 11802 , 21002 }
            local Irandom = number(1,table.getn(item_table) )
            local reward2 = item_table[Irandom]
            if pc.level >=lvlmin and pc.level <=lvlmax then
                local r1=number(1, 5)
                if r1>=2 then
                    game.drop_item_with_ownership(reward1, 1)
                end
                local r2=number(1, 3)
                if r2>=2 then
                    local quantity = number(1,5) -- how many item of reward2 will dropped
                    local i
                    for i=1,quantity,1 do
                        game.drop_item_with_ownership(reward2, 1)
                    end    
                end
            else
                -- ? xD
            end
        end
    end
end

It's working but I get all reward2 same items.

 

7K9xf.gif

 

(slow random?) 

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
Share on other sites

  • Premium
  • Solution
quest metin5 begin
	state start begin
		when 8001.kill begin
			local lvlmin= 1
			local lvlmax= 10
			local reward1 = 50300
			local item_table = { 11202 , 11402 , 11602 , 11802 , 21002 }
			local Irandom = number(1,table.getn(item_table) )
			local reward2 = item_table[Irandom]
			if pc.level >=lvlmin and pc.level <=lvlmax then
				local r1=number(1, 5)
				if r1>=2 then
					game.drop_item_with_ownership(reward1, 1)
				end
				local r2=number(1, 3)
				if r2>=2 then
					local quantity = number(1,5)
					local i
					for i=1,quantity,1 do
						Irandom = number(1,table.getn(item_table) )
						game.drop_item_with_ownership(item_table[Irandom], 1)
					end	
				end
			end
		end
	end
end

Try this... now you will drop different item ;)

  • Love 3
Link to comment
Share on other sites

  • Premium
quest metin5 begin
	state start begin
		when 8001.kill begin
			local lvlmin= 1
			local lvlmax= 10
			local reward1 = 50300
			local item_table = { 11202 , 11402 , 11602 , 11802 , 21002 }
			local Irandom = number(1,table.getn(item_table) )
			local reward2 = item_table[Irandom]
			if pc.level >=lvlmin and pc.level <=lvlmax then
				local r1=number(1, 5)
				if r1>=2 then
					game.drop_item_with_ownership(reward1, 1)
				end
				local r2=number(1, 3)
				if r2>=2 then
					local quantity = number(1,5)
					local i
					for i=1,quantity,1 do
						Irandom = number(1,table.getn(item_table) )
						game.drop_item_with_ownership(item_table[Irandom], 1)
					end	
				end
			end
		end
	end
end

Try this... now you will drop different item ;)

 

Mark solved. Thank you!  :wub:

  • Love 2
Link to comment
Share on other sites

  • 1 year later...
On 11/2/2015 at 1:53 PM, iRETEMAG said:
On 11/2/2015 at 0:28 PM, r00t said:


quest metin5 begin
	state start begin
		when 8001.kill begin
			local lvlmin= 1
			local lvlmax= 10
			local reward1 = 50300
			local item_table = { 11202 , 11402 , 11602 , 11802 , 21002 }
			local Irandom = number(1,table.getn(item_table) )
			local reward2 = item_table[Irandom]
			if pc.level >=lvlmin and pc.level <=lvlmax then
				local r1=number(1, 5)
				if r1>=2 then
					game.drop_item_with_ownership(reward1, 1)
				end
				local r2=number(1, 3)
				if r2>=2 then
					local quantity = number(1,5)
					local i
					for i=1,quantity,1 do
						Irandom = number(1,table.getn(item_table) )
						game.drop_item_with_ownership(item_table[Irandom], 1)
					end	
				end
			end
		end
	end
end

Try this... now you will drop different item ;)

thanks i also need this . lua master level ;)

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.