• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Similar Obsidian Knife

massuco

Brazilian, sorry for my bad english XD
Joined
Feb 17, 2013
Messages
199
Solutions
8
Reaction score
22
Location
Brasil
Hi there, i was trying to create one script for TFS 0.4
The player will use the knife (id 2556) on corpses.
If the player use a knife on minotaur corpses player will have a chance of win one item.
If the player use a knife on orc corpses player will have a chance of win one item.
THE PROBLEM IS, only the minotaur script works, the second part (orcs) make my distro close imediately.
Anyone can help me?

This is my script:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)

-- Minotaur, Minotaur Archer, Minotaur Guard, Minotaur Mage
if (itemEx.itemid == 2830) or (itemEx.itemid == 2871) or (itemEx.itemid == 2876) or (itemEx.itemid == 2866)then
    if(math.random(1,2) == 1) then
        doPlayerAddItem(cid, 2571)
        doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
        doTransformItem(itemEx.uid, itemEx.itemid + 1)
    else
        doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
        doTransformItem(itemEx.uid, itemEx.itemid + 1)
    end

-- Orc, Orc Spearman, Orc Warrior, Orc Shaman, Orc Berserker, Orc Leader, Orc Warlord
elseif (itemEx.itemid == 2820) or (itemEx.itemid == 2920) or (itemEx.itemid == 2862) or (itemEx.itemid == 2860) or (itemEx.itemid == 2864) or (itemEx.itemid == 2938) or (itemEx.itemid == 2967) then
    if(math.random(1,2) == 1) then
        doPlayerAddItem(cid, 2572)
        doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
        doTransformItem(itemEx.uid, itemEx.itemid + 1)
    else
        doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
        doTransformItem(itemEx.uid, itemEx.itemid + 1)
    end
end


return true
end
 
Last edited:
Solution
I HAVE SOLVED MY PROBLEM!
The problem only happens with the monsters ORCS, i will check why.
Ive tried other monsters and worked perfectly, only orcs dont work. i think that is something with the corpse ids on items.xml.
I HAVE SOLVED MY PROBLEM!
The problem only happens with the monsters ORCS, i will check why.
Ive tried other monsters and worked perfectly, only orcs dont work. i think that is something with the corpse ids on items.xml.
 
Solution
Back
Top