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

Lua TFS 0.3.6 8.60 /ATK CREATURE WITH ITEM ID 5902 I DON'T WANT THIS STATUS IDK

samuel157

/root
Joined
Mar 19, 2010
Messages
518
Solutions
3
Reaction score
71
Location
São Paulo, Brazil
GitHub
Samuel10M
TFS 0.3. 6 8.60 I HAVE A PROBLEM WITH THIS CODE IT ONLY HITS THE CREATURE OR PLAYER OR MONSTER WHEN I USE ITEM 5902 ALONG WITH ATK BUT I JUST WANT TO USE THE PERCENTAGE TO IMPROVE THE ITEM PLEASE HELP ME I WANT IT TO ATTACK THE CREATURE AND NOT THE ID OF ITEM 5902 ALONG WITH ATK...


LUA:
local UPGRADE_ITEM_ID = 5902 -- The upgrade item, in this case, the "scary blue eye"
local LIFE_LEECH_INCREMENT = 1 -- Percentage to be added to Life Leech
local MANA_LEECH_INCREMENT = 1 -- Percentage to be added to Mana Leech
local MAX_LEECH_PERCENT = 100 -- Maximum limit for Life Leech and Mana Leech

function onUse(cid, item, fromPosition, itemEx, toPosition)
    -- Check if the player is valid
    if not isPlayer(cid) then
        return false
    end

    -- Get the weapon the player is holding (left or right hand)
    local weapon = getPlayerSlotItem(cid, CONST_SLOT_LEFT)
    if weapon.itemid == 0 then
        weapon = getPlayerSlotItem(cid, CONST_SLOT_RIGHT)
    end

    -- Check if the player is holding a weapon
    if weapon.itemid == 0 then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, "You need to be holding a weapon to upgrade it.")
        return false
    end

    -- Get the current Life Leech and Mana Leech values (if they exist)
    local currentLifeLeech = tonumber(getItemAttribute(weapon.uid, "lifeLeech")) or 0
    local currentManaLeech = tonumber(getItemAttribute(weapon.uid, "manaLeech")) or 0

    -- Accumulate new leech values, limited by the maximum
    local newLifeLeech = math.min(currentLifeLeech + LIFE_LEECH_INCREMENT, MAX_LEECH_PERCENT)
    local newManaLeech = math.min(currentManaLeech + MANA_LEECH_INCREMENT, MAX_LEECH_PERCENT)

    -- Apply the new Life Leech and Mana Leech values to the weapon
    doItemSetAttribute(weapon.uid, "lifeLeech", newLifeLeech)
    doItemSetAttribute(weapon.uid, "manaLeech", newManaLeech)

    -- Modify the weapon description to display the new leech values
    local description = getItemAttribute(weapon.uid, "description") or ""
    description = "This weapon now has " .. newLifeLeech .. "% Life Leech and " .. newManaLeech .. "% Mana Leech. The maximum is 100%."
    doItemSetAttribute(weapon.uid, "description", description)

    -- Send a message to the player informing them about the upgrade
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your weapon has been upgraded! It now has " .. newLifeLeech .. "% Life Leech and " .. newManaLeech .. "% Mana Leech. The maximum is 100%.")

    -- Display animated text "+Leech!!!" in green (color 35)
    local position = getCreaturePosition(cid)
    doSendAnimatedText(position, "+Leech!!!", 35)

    -- Remove the upgrade item (scary blue eye)
    doRemoveItem(item.uid, 1)

    -- Combat logic: damage with the weapon
    local target = getCreatureTarget(cid)
    if isCreature(target) then
        -- Check if the weapon has Life Leech or Mana Leech
        if newLifeLeech > 0 or newManaLeech > 0 then
            local damage = 100000000000 -- Fixed damage defined for the weapon

            -- Apply the damage to the target
            doTargetCombatHealth(cid, target, COMBAT_UNDEFINEDDAMAGE, -damage, -damage, CONST_ME_HITAREA)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You dealt " .. damage .. " damage with your weapon!")
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your weapon does not have Life Leech or Mana Leech, it cannot deal damage.")
        end
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, "You do not have a valid target to attack.")
    end

    return true
end
 
Back
Top