Jump to content
  • 0

[Quest]Conditional expression not always happening.


adi97ida

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.

 

Link to comment

8 answers to this question

Recommended Posts

  • 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

$ uptime
1:26AM  up 732 days,  8:29, 1 user, load averages: 0.38, 0.31, 0.22

$ uname -srp
FreeBSD 9.1-RELEASE amd64

Link to comment
  • 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
Link to comment
  • 0
  • Developer

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

 

More simple.

👑 Premium International Lua Developer 👑

 My service topic: https://bit.ly/2UPly54

 

Ignorant people have the obligation to compensate their ignorance by paying whoever helps them.

Syreldar

Link to comment
  • 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

Link to comment

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


×
×
  • 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.