• 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 1.X+ How to show animated text when removing an object from a corpse

Mateus Robeerto

Legendary OT User
Joined
Jun 5, 2016
Messages
1,744
Solutions
92
Reaction score
1,256
Location
ლ(ಠ益ಠლ)
does anyone know this script? if yes, please convert to tfs 1.2
the script is simple, I like it
LUA:
function onRemoveItem(moveitem, tileitem, pos)
    if moveitem.itemid >= 1 and moveitem.itemid <= 30000 then
        doSendAnimatedText(pos,getItemName(moveitem.itemid), TEXTCOLOR_ORANGE)
    end
end



I put this area by accident, please can some adm or mods move it to another support area thanks
 
Last edited:
Solution
my font does have doSendAnimatedText ( I found "Game.sendAnimatedText" in data\lib\compat\compat.lua)

For me I liked this script yes... my ot is based on "lord of the rings" custom map xD. that I showed the video is very old ot version 7.92 by evolutions ( Xidaozu), I already changed to tfs 1.2 it's almost ready 90%.. I want to finish it soon before posting ot online
if there is no way, that I'm going to give up on this script, thank you very much for the help force!
Maybe something like this could work for you?

data/events/scripts/player.lua
LUA:
-- onMoveItem Event
if fromCylinder and fromCylinder:isItem() then
        if fromCylinder:getId() == 3065 then
            if toCylinder ~= fromCylinder then...
I did the RevScript here and tested it, it's working OK. Try it out in data/scripts.

LUA:
local allowedIds = {
    [30201] = true,
    [30200] = true,
    [30199] = true,
}

local ec = EventCallback

ec.onMoveItem = function(player, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if fromCylinder and fromCylinder:isItem() then
        local itemId = item:getId()
        if allowedIds[itemId] then
            if toCylinder ~= fromCylinder then
                local text = string.format("x%d %s", count, item:getName())
                local position = fromCylinder:getPosition()
                local color = 198 -- orange color code
              
                Game.sendAnimatedText(text, position, color)
            end
        end
    end

    return true
end

ec:register(-61)
hmm its not really working, (no errors in console)


if i may ask, what's the (-61)?

im assuming i was suposed to remove the function from the player.lua and implementing your script into data/scripts
 
hmm its not really working, (no errors in console)


if i may ask, what's the (-61)?

im assuming i was suposed to remove the function from the player.lua and implementing your script into data/scripts
You can just do the same type of thing inside the ec.onDropLoot(monster, corpse) callback on line 96 of the autoloot script.
Something like (untested):
LUA:
function ec.onDropLoot(monster, corpse)
    if not corpse:getType():isContainer() then
        return
    end

    local corpseOwner = Player(corpse:getCorpseOwner())
    local corpsePosition = corpse:getPosition()
    local items = corpse:getItems()
    local warningCapacity = false
    local lootedIds = {}
    for _, item in pairs(items) do
        local itemId = item:getId()
        if hasPlayerAutolootItem(corpseOwner, itemId) then
            if currencyItems[itemId] then
                local worth = item:getWorth()
                corpseOwner:setBankBalance(corpseOwner:getBankBalance() + worth)
                corpseOwner:sendTextMessage(MESSAGE_STATUS_SMALL, string.format("Your balance increases by %d gold coins.", worth))
                item:remove()
                Game.sendAnimatedText(string.format("x%d %s", item:getCount(), item:getName()), corpsePosition, 198)
            elseif item:moveTo(corpseOwner, 0) then
                Game.sendAnimatedText(string.format("x%d %s", item:getCount(), item:getName()), corpsePosition, 198)
            else
                warningCapacity = true
            end
        end
    end

    if warningCapacity then
        corpseOwner:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You no have capacity.")
    end
end

This will put a message for every item that has been autolooted.
Although, it might be a better idea to store all the id's, and just write one message after the loop has finished...
 
Last edited by a moderator:
You can just do the same type of thing inside the ec.onDropLoot(monster, corpse) callback on line 96 of the autoloot script.
Something like (untested):
LUA:
function ec.onDropLoot(monster, corpse)
    if not corpse:getType():isContainer() then
        return
    end

    local corpseOwner = Player(corpse:getCorpseOwner())
    local corpsePosition = corpse:getPosition()
    local items = corpse:getItems()
    local warningCapacity = false
    local lootedIds = {}
    for _, item in pairs(items) do
        local itemId = item:getId()
        if hasPlayerAutolootItem(corpseOwner, itemId) then
            if currencyItems[itemId] then
                local worth = item:getWorth()
                corpseOwner:setBankBalance(corpseOwner:getBankBalance() + worth)
                corpseOwner:sendTextMessage(MESSAGE_STATUS_SMALL, string.format("Your balance increases by %d gold coins.", worth))
                item:remove()
                Game.sendAnimatedText(string.format("x%d %s", item:getCount(), item:getName()), corpsePosition, 198) --not sure if this is really needed...
            elseif item:moveTo(corpseOwner, 0) then
                Game.sendAnimatedText(string.format("x%d %s", item:getCount(), item:getName()), corpsePosition, 198)
            else
                warningCapacity = true
            end
        end
    end

    if warningCapacity then
        corpseOwner:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You no have capacity.")
    end
end

This will put a message for every item that has been autolooted.
Although, it might be a better idea to store all the id's, and just write one message after the loop has finished...
My god you are an ANGEL!

tested and works very well, i was playing around with the autoloot to see if i could make it work, this saved me so much time!

really appreciate it thanks!

@Mateus Robeerto and thank you also for taking your time to try to help me!<3
 
Back
Top