• 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!

TFS 0.X Search help

395003

New Member
Joined
Aug 15, 2010
Messages
8
Reaction score
0
Hello, i try to solve that problem ->
64005a3cc554702c4038548a3a1ae724.png
and i can't do this, if i use item with id 8300 on alive monster/npc/player i have that error. Someone can help me?


Here is code:
Lua:
function onUse(cid, item, fromPos, item2, toPos)
    if (getItemAttribute(item2.uid, "M_Soul")) and (os.clock() - getItemAttribute(item2.uid, "M_Time") > L_Soul.soul_t) then
        doItemSetAttribute(item2.uid, "M_Soul", false)
    end

    local fromPos = (fromPos.x ~= 65535) and fromPos or getThingPos(cid)

    local lan = L_Soul.lang[L_Soul.language]


    if (getItemAttribute(item.uid, "Soul")) then
        if (toPos.x ~= 65535) and (getItemAttribute(item2.uid, "criaturaS")) then

            if (getItemAttribute(item2.uid, "M_Soul")) then
                return doPlayerSendCancel(cid, lan[14])
            end

            local soulT = L_Soul.creatures[getItemAttribute(item.uid, "Soul")].type

            local summ = L_Soul.creatures[getItemAttribute(item.uid, "Soul")].summ
            local tos = getMonsterInfo(getItemAttribute(item2.uid, "criaturaS"))
            if (tos.experience < getMonsterInfo(getItemAttribute(item.uid, "Soul")).experience) then
                doSendMagicEffect(fromPos, L_Soul.souls[soulT].effects.eff)
                doPlayerSendTextMessage(cid, 27, string.format(lan[13], getItemAttribute(item.uid, "Soul"), soulT))
                return doRemoveItem(item.uid, 1)
            elseif (getPlayerSoul(cid) < summ.needSoulPoints) then
                return doPlayerSendCancel(cid, string.format(lan[8], getItemAttribute(item.uid, "Soul"), summ.needSoulPoints))
            elseif (getCreatureMana(cid) < summ.needMana) then
                return doPlayerSendCancel(cid, string.format(lan[10], getItemAttribute(item.uid, "Soul"), summ.needMana))
            elseif (getCreatureHealth(cid) < summ.needHealth) then
                return doPlayerSendCancel(cid, string.format(lan[11], getItemAttribute(item.uid, "Soul"), summ.needHealth))
            elseif (getTopCreature(toPos).uid > 0) then
                return doPlayerSendCancel(cid, string.format(lan[9], getItemAttribute(item.uid, "Soul")))
            elseif (getTileInfo(toPos).protection) then
                return doPlayerSendCancel(cid, string.format(lan[9], getItemAttribute(item.uid, "Soul")))
            end

            doPlayerAddSoul(cid, -summ.needSoulPoints)
            doCreatureAddMana(cid, -summ.needMana)
            doCreatureAddHealth(cid, -summ.needHealth)

            local crea = doCreateMonster(getItemAttribute(item.uid, "Soul"), toPos)

                if (summ.needMana > 0) then doSendAnimatedText(getThingPos(cid), -summ.needMana, 120) end
                if (summ.needHealth > 0) then doSendAnimatedText(getThingPos(cid), -summ.needHealth, 180) end

                setCreatureMaxHealth(crea, summ.hp.maxb)
                doCreatureAddHealth(crea, summ.hp.maxb)
                doCreatureChangeOutfit(crea, tos.outfit)
                doCreatureAddHealth(crea, (-summ.hp.maxb + 1) + summ.hp.hpb - 1)
                doMonsterSetTarget(crea, cid)

                setPlayerStorageValue(crea, 7148, getItemAttribute(item2.uid, "criaturaS"))

            doSendMagicEffect(toPos, L_Soul.souls[soulT].effects.eff)
            doSendDistanceShoot(fromPos, toPos, L_Soul.souls[soulT].effects.distance)

            doPlayerSendTextMessage(cid, 27, string.format(lan[12], getItemAttribute(item.uid, "Soul"), soulT))
            doRemoveItem(item.uid, 1)
            doCreatureSay(crea, lan[#lan][math.random(#lan[#lan])], 19)
            return doRemoveItem(item2.uid, 1)
        elseif (toPos.x == 65535) then

            local enchant = L_Soul.creatures[getItemAttribute(item.uid, "Soul")].enchant

            if not (L_Soul.enchant.weapons[item2.itemid] or (L_Soul.enchant.weapons[item2.itemid] and not isInArray(L_Soul.enchant.weapons[item2.itemid], soulT:lower()))) then
                return doPlayerSendCancel(cid, lan[7])
            end

            if (getItemAttribute(item2.uid, "ES_Charges")) then
                return doPlayerSendCancel(cid, lan[18])
            end

            doItemSetAttribute(item2.uid, "description", string.format(lan[16], getItemAttribute(item.uid, "Soul"), enchant.charges, enchant.charges))
            doItemSetAttribute(item2.uid, "ES_Charges", enchant.charges)
            doItemSetAttribute(item2.uid, "ES_Type", getItemAttribute(item.uid, "Soul"))
            doPlayerSendTextMessage(cid, 27, string.format(lan[15], getItemAttribute(item.uid, "Soul")))
            doSendMagicEffect(toPos, L_Soul.souls[L_Soul.creatures[getItemAttribute(item.uid, "Soul")].type].effects.eff)
            return doRemoveItem(item.uid, 1)
        end
    end

    if not (isContainer(item2.uid)) or not (getItemAttribute(item2.uid, "M_Soul")) then
        return doPlayerSendCancel(cid, lan[3])
    end

    if (getItemAttribute(item.uid, "Soul")) then
        return doPlayerSendCancel(cid, string.format(lan[1], getItemAttribute(item.uid, "Soul"), L_Soul.creatures[getItemAttribute(item.uid, "Soul")].type))
    end

    if (getDistanceBetween(fromPos, toPos) > L_Soul.max_distance) then
        return doPlayerSendCancel(cid, lan[2])
    end

    if (isCreature(item2.uid)) then
        return true
    end

    local soul = L_Soul.creatures[getItemAttribute(item2.uid, "M_Soul")]

    if not (soul) then
        return true
    end

    if (math.random(100) + soul.chance < 100 + math.floor(soul.chance/2)) then
        doRemoveItem(item.uid, 1)
        doSendMagicEffect(toPos, L_Soul.souls[L_Soul.creatures[getItemAttribute(item2.uid, "M_Soul")].type].effects.eff)
        doPlayerSendTextMessage(cid, 27, string.format(lan[4], getItemAttribute(item2.uid, "M_Soul"), soul.type:formal()))
        doSendMagicEffect(fromPos, 2)
        return doItemSetAttribute(item2.uid, "M_Soul", false)
    end

    doSendDistanceShoot(toPos, fromPos, L_Soul.souls[soul.type].effects.distance)

    doPlayerSendTextMessage(cid, 27, string.format(lan[5], getItemAttribute(item2.uid, "M_Soul"), soul.type:formal()))
    doItemSetAttribute(item.uid, "Soul", getItemAttribute(item2.uid, "M_Soul"))

    doItemSetAttribute(item.uid, "description", string.format(lan[6], getItemAttribute(item2.uid, "M_Soul"), soul.type))

    doSendMagicEffect(fromPos, 28)
    doSendMagicEffect(fromPos, 29)
    doSendMagicEffect(fromPos, 30)

    return doItemSetAttribute(item2.uid, "M_Soul", false)
end
 
put this directly under the onUse function
Lua:
if isCreature(item2.uid) then
    return true
end
 
Solution
Back
Top