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

Solved Ring of ending //

silveralol

Advanced OT User
Joined
Mar 16, 2010
Messages
1,480
Solutions
9
Reaction score
211
hi, i'm making the scripts of broken ring of ending
Code:
function text1(player)
    local ringItem = player:getSlotItem(CONST_SLOT_RING)
    if not ringItem then
        return true
    end
    if not player then
        return true
    end
    if player then
        if ringItem then
            player:getPosition():sendMagicEffect(12)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'msg1.')
            addEvent(text2, 10 * 1000, player)
        end
    end
end
function text2(player)
    local ringItem = player:getSlotItem(CONST_SLOT_RING)
    if not ringItem then
        return true
    end
    if not player then
        return true
    end
    if player then
        if ringItem then
            player:getPosition():sendMagicEffect(38)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'msg2')
            addEvent(text3, 10 * 1000, player)
        end
    end
end
function text3(player)
    local ringItem = player:getSlotItem(CONST_SLOT_RING)
    if not ringItem then
        return true
    end
    if not player then
        return true
    end
    if player then
        if ringItem then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'msg3')
            addEvent(text4, 10 * 1000, player)
        end
    end
end
function text4(player)
    local ringItem = player:getSlotItem(CONST_SLOT_RING)
    if not ringItem then
        return true
    end
    if not player then
        return true
    end
    if player then
        if ringItem then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'msg4.')
            addEvent(text5, 10 * 1000, player)
        end
    end
end
function text5(player)
    local ringItem = player:getSlotItem(CONST_SLOT_RING)
    if not ringItem then
        return true
    end
    if not player then
        return true
    end
    if player then
        if ringItem then
            local chance = math.random(2)
            if chance == 1 then
                player:getPosition():sendMagicEffect(18)
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'msg5')
                addEvent(text6, 10 * 1000, player)
            else
                doTargetCombatHealth(0, player, COMBAT_DEATHDAMAGE, -300000, -300000, CONST_ME_MORTAREA)
            end
        end
    end
end

function text6(player)
    local ringItem = player:getSlotItem(CONST_SLOT_RING)
    if not ringItem then
        return true
    end
    if not player then
        return true
    end
    if player then
        if ringItem then
            ringItem:transform(22516)
            player:getPosition():sendMagicEffect(38)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'msg6')
        end
    end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local ringItem = player:getSlotItem(CONST_SLOT_RING)
    if not ringItem then
        return false
    end
    if player then
        addEvent(text1, 10 * 1000, player)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'msgOnUse')
        player:getPosition():sendMagicEffect(1)
    end
    return true
end
I need to check in all events if the player is "online" and the ring is in the correct slot to do the functions, also, if I logout and back, sometimes got crash, and the "effects" stay sending ? wtf ... I'll explain better, I use the ring, then logout, and then back again, the effects stay send in the last position before I logout
any question, please feel free to ask :D
thank you
 
You should probably check the equipped ring's item id as well, unless you want players to have their crystal rings (or other rings) transformed into a ring of ending.
yes, you take a point, I'll make some changes to check it.
Keep editing it until you have it how you like it, all I did was take your first script and try to show you how it can be improved. It was not my intention to write a script for the Broken Ring of Ending/Ring of Ending but instead an attempt to teach someone a new trick. :)

So please compare your original and then my re-write and try to learn from it. If we faltered, surely someone will come along and teach us more ways to improve.
yes, I compare, I saw how you use the parameters in a better way... so much thanks, a last thing, I try make the "string of mending" script
Code:
local config = {
    [1] = {msg = 'The ring feels even heavier. You feel slightly stronger, however.', magicEffect = CONST_ME_MAGIC_GREEN, transformRing = false},
    [2] = {msg = 'The ring feels quite heavy now. Nothing else happens.', magicEffect = CONST_ME_ENERGYAREA, transformRing = false},
    [3] = {msg = 'You feel better, more energetic than ever before. The ring seems to wrap itself tighter around your finger.', magicEffect = CONST_ME_MAGIC_BLUE, transformRing = true} -- transformRing is true here because if it makes it to step 6 then we will transform the ring
}

function sendTextToPlayer(player, message, transform, magicEffect, item, target)
    local player = Player(player)
    if not player then
        return true
    end
    if transform then
        target:transform(22543)
        item:remove()
    end
    addEvent(sendTextToPlayer, 10 * 1000, player, config[3].msg, config[3].transformRing, config[3].magicEffect, item, target)
    player:getPosition():sendMagicEffect(magicEffect)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, message)
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if target.itemid ~= 13877 then
        return false
    end
    if player then
        for i= 1, 2 do 
            addEvent(sendTextToPlayer, i * 10 * 1000, player:getId(), config[i].msg, config[i].transformRing, config[i].magicEffect, item, target)
        end
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'The smooth string of mending coils around your whole arm as if it was to devour it.')
        player:getPosition():sendMagicEffect(CONST_ME_SMALLCLOUDS)
    end
    return true
end
but in the second event I got debug in client, don't know why, have an error with names of the magic effects? not appear it D:
 
Back
Top