Jump to content

[Quest]Conditional expression not always happening.


Recommended Posts

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.

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • Premium

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

 

More simple.

 

"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

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

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.