• 0

# [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?

• Created

## Recommended Posts

• 0

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

when you return 0 and server doesn't boot:

• 0

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

• 0

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

e.g:

[8001] = 5,

[8002] = 10,

[8003] = 15,

etc

when you return 0 and server doesn't boot:

• 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

• 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

• 0

ATAG, can you please give me an example??

• 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
```
• 0
• Developer

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

More simple.

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

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

Syreldar

• 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

## Create an account

Register a new account

1. 61

2. 0

3. 4

4. 4

5. 4

6. 5

7. 5

8. 5

9. 5

• ### Recently Browsing

×

• Marketplace

• #### Tools

×
• Create New...