Jump to content
  • 0
Sign in to follow this  
adi97ida

[Quest]Conditional expression not always happening.

Question

Hello,

Today, i made a quest that drops some items if you break a metin stone.

You get these items from the stone only if the differencte between player's level and metin's is no more than 15.

Here's the code :

quest drop_metine begin
state start begin
when kill begin
if npc.get_race() >= 8001 and npc.get_race() <= 8055 then
	local mob = npc.get_level() + 15
	local nivel = pc.get_level()
	local sex = pc.get_sex()
	local sansa2 = math.random(1,3)
	local sansa3 = math.random(1,2)
	chat("Nivelul metinului "..mob.."")
	if nivel >= mob then
	notice("Nivelul tau este prea mare pentru a primii rasplata...")
	else
		if sansa2 == 2 then
			if sex == 0 then
				game.drop_item_with_ownership("71159",1)
			else
				game.drop_item_with_ownership("71160",1)
			end
		game.drop_item_with_ownership("50130",1) -- cufar pietre
		game.drop_item_with_ownership("50130",1) -- cufar pietre
		game.drop_item_with_ownership("50130",1) -- cufar pietre
		game.drop_item_with_ownership("50513", sansa3) -- Drop SS-uri
		local aux = pc.getqf("metine_sparte") + 1
		pc.setqf("metine_sparte", aux)
		chat("Metine Sparte "..aux.."")
	notice("Ai fost rasplatit!")
		end
	end
end
end
end
end

The problem is that the "if nivel >= mob then" condition is not always happening...

For example:

My character is level 95, the level of the metin i kill is 90, after i break the stone, the "chat("Nivelul metinului "..mob.."")" message appears, but the condition is not evaluated anymore.

This also happens if the difference is bigger than 15 levels......

Sometimes the condition is evaluated, sometimes is not.

Can someone tell me what's wrong?

Thank you in advance.

 

Share this post


Link to post

8 answers to this question

Recommended Posts

  • 0

npc.get_level() function doesn't exists I think.

Share this post


Link to post
  • 0

it exists, i already specified that the evaluation is done with succes, but not always.....

Share this post


Link to post
  • 0

Why don't you write a table with metin stone's level?

 

e.g:

[8001] = 5,

[8002] = 10,

[8003] = 15,

etc

Share this post


Link to post
  • 0

If you have more than 1 "when kill begin" like quest, you have to priorize in locale_list. Server runs the first (and only one) possible "event/callback" only.

 

Sorry for my bad english, i hope you understand me :)

 

  • Love 1

Share this post


Link to post
  • 0

Try this, and comment if you kill a metin in the chat appears "test1"

quest drop_metine begin
quest drop_metine begin
state start begin
when kill begin
if npc.get_race() >= 8001 and npc.get_race() <= 8055 then
    local mob = npc.get_level() + 15
    local nivel = pc.get_level()
    local sex = pc.get_sex()
    local sansa2 = math.random(1,3)
    local sansa3 = math.random(1,2)
    chat("Nivelul metinului "..mob.."")
    if nivel >= mob then
    notice("Nivelul tau este prea mare pentru a primii rasplata...")
    else
chat("test1")
        if sansa2 == 2 then
            if sex == 0 then
                game.drop_item_with_ownership("71159",1)
            else
                game.drop_item_with_ownership("71160",1)
            end
        game.drop_item_with_ownership("50130",1) -- cufar pietre
        game.drop_item_with_ownership("50130",1) -- cufar pietre
        game.drop_item_with_ownership("50130",1) -- cufar pietre
        game.drop_item_with_ownership("50513", sansa3) -- Drop SS-uri
        local aux = pc.getqf("metine_sparte") + 1
        pc.setqf("metine_sparte", aux)
        chat("Metine Sparte "..aux.."")
    notice("Ai fost rasplatit!")
        end
    end
end
end
end
end
end

Share this post


Link to post
  • 0

Write a table in questlib.lua with an array which returns metinvnum ---> metinlevel, and read that table.

 

More simple.

Share this post


Link to post
  • 0

Why he shouldn't use the function noc.get_level() if he implemented it? He has - I think - 55 metin stones so to write the table he's just wasting time and if he adds a metin he always has to edit that.

Put some chats for testing into the quest to check if it runs and whats the result of the condition and try again.

Regards

Share this post


Link to post

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
Sign in to follow this  
  • Recently Browsing   0 members

    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.