• 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 1.x interval of display text

Szafi

www.rookwar.pl
Joined
Mar 2, 2009
Messages
165
Reaction score
10
Location
Poland
Hello. I need interval of display text OWN3D how to?

example:

Code:
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You are dead.')
    player:say('O', TALKTYPE_ORANGE_1)
    player:say('w', TALKTYPE_ORANGE_1)
    player:say('n', TALKTYPE_ORANGE_1)
    player:say('3', TALKTYPE_ORANGE_1)
    player:say('D', TALKTYPE_ORANGE_1)

efect
1.jpg


which use the functions?
 
3UmhPQk.gif

You can adjust the speed by changing the 250 ms, making it 100 would make it faster, making it 1000 would equal 1 letter per second.
(I didn't test with onDeath but the concept is there! :))

Code:
function sendOwnedText(player, text)
    local deadGuy = Player(player)
    if not deadGuy then
         return
    end
    deadGuy:say(text, TALKTYPE_MONSTER_SAY)
end

local text = {'O', 'w', 'n', '3', 'D'}
for i= 1,#text do
    addEvent(sendOwnedText, i * 250, player:getId(), text[i])
end
 
Last edited:
Where i can add your script? I no have many idea, my attempts do not work.

playerdeath.lua

Code:
local deathListEnabled = true
local maxDeathRecords = 5

function onDeath(player, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
    local playerId = player:getId()
    if nextUseStaminaTime[playerId] ~= nil then
        nextUseStaminaTime[playerId] = nil
    end

    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You are dead.')
    if player:getStorageValue(Storage.SvargrondArena.Pit) > 0 then
        player:setStorageValue(Storage.SvargrondArena.Pit, 0)
    end

    if not deathListEnabled then
        return
    end

    local byPlayer = 0
    local killerName
    if killer ~= nil then
        if killer:isPlayer() then
            byPlayer = 1
        else
            local master = killer:getMaster()
            if master and master ~= killer and master:isPlayer() then
                killer = master
                byPlayer = 1
            end
        end
        killerName = killer:isMonster() and killer:getType():getNameDescription() or killer:getName()
    else
        killerName = 'field item'
    end

    local byPlayerMostDamage = 0
    local mostDamageKillerName
    if mostDamageKiller ~= nil then
        if mostDamageKiller:isPlayer() then
            byPlayerMostDamage = 1
        else
            local master = mostDamageKiller:getMaster()
            if master and master ~= mostDamageKiller and master:isPlayer() then
                mostDamageKiller = master
                byPlayerMostDamage = 1
            end
        end
        mostDamageName = mostDamageKiller:isMonster() and mostDamageKiller:getType():getNameDescription() or mostDamageKiller:getName()
    else
        mostDamageName = 'field item'
    end

    local playerGuid = player:getGuid()
    db.query('INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `is_player`, `mostdamage_by`, `mostdamage_is_player`, `unjustified`, `mostdamage_unjustified`) VALUES (' .. playerGuid .. ', ' .. os.time() .. ', ' .. player:getLevel() .. ', ' .. db.escapeString(killerName) .. ', ' .. byPlayer .. ', ' .. db.escapeString(mostDamageName) .. ', ' .. byPlayerMostDamage .. ', ' .. (unjustified and 1 or 0) .. ', ' .. (mostDamageUnjustified and 1 or 0) .. ')')
    local resultId = db.storeQuery('SELECT `player_id` FROM `player_deaths` WHERE `player_id` = ' .. playerGuid)

    local deathRecords = 0
    local tmpResultId = resultId
    while tmpResultId ~= false do
        tmpResultId = result.next(resultId)
        deathRecords = deathRecords + 1
    end

    if resultId ~= false then
        result.free(resultId)
    end

    local limit = deathRecords - maxDeathRecords
    if limit > 0 then
        db.asyncQuery("DELETE FROM `player_deaths` WHERE `player_id` = " .. playerGuid .. " ORDER BY `time` LIMIT " .. limit)
    end

    if byPlayer == 1 then
        local targetGuild = player:getGuild()
        targetGuild = targetGuild and targetGuild:getId() or 0
        if targetGuild ~= 0 then
            local killerGuild = killer:getGuild()
            killerGuild = killerGuild and killerGuild:getId() or 0
            if killerGuild ~= 0 and targetGuild ~= killerGuild and isInWar(playerId, killer.uid) then
                local warId = false
                resultId = db.storeQuery('SELECT `id` FROM `guild_wars` WHERE `status` = 1 AND ((`guild1` = ' .. killerGuild .. ' AND `guild2` = ' .. targetGuild .. ') OR (`guild1` = ' .. targetGuild .. ' AND `guild2` = ' .. killerGuild .. '))')
                if resultId ~= false then
                    warId = result.getNumber(resultId, 'id')
                    result.free(resultId)
                end

                if warId ~= false then
                    db.asyncQuery('INSERT INTO `guildwar_kills` (`killer`, `target`, `killerguild`, `targetguild`, `time`, `warid`) VALUES (' .. db.escapeString(killerName) .. ', ' .. db.escapeString(player:getName()) .. ', ' .. killerGuild .. ', ' .. targetGuild .. ', ' .. os.time() .. ', ' .. warId .. ')')
                end
            end
        end
    end
end
 
3UmhPQk.gif

You can adjust the speed by changing the 250 ms, making it 100 would make it faster, making it 1000 would equal 1 letter per second.
(I didn't test with onDeath but the concept is there! :))

Code:
function sendOwnedText(player, text)
    local deadGuy = Player(player)
    deadGuy:say(text, TALKTYPE_MONSTER_SAY)
end

local text = {'O', 'w', 'n', '3', 'D'}
for i= 1,#text do
    addEvent(sendOwnedText, i * 250, player:getId(), text[i])
end
Player is a dangling pointer.
 
I actually had to change the function for onDeath:
Code:
function sendOwnedText(pos, text)
    local spectators = Game.getSpectators(pos, false, true, 7, 7, 5, 5)
    for _, pid in ipairs(spectators) do
        pid:say(text, TALKTYPE_MONSTER_SAY, false, pid, pos)
    end
end

Your script with the edits: [I added comments where I inserted new code.]
Code:
local deathListEnabled = true
local maxDeathRecords = 5
---------------------------------------------------------
--- HERE WE PUT OUR FUNCTION AND OUR TABLE OF LETTERS ---
---------------------------------------------------------
function sendOwnedText(pos, text)
    local spectators = Game.getSpectators(pos, false, true, 7, 7, 5, 5)
    for _, pid in ipairs(spectators) do
        pid:say(text, TALKTYPE_MONSTER_SAY, false, pid, pos)
    end
end
local text = {'O', 'w', 'n', '3', 'D'}
---------------------------------------------------------
---------------------------------------------------------
---------------------------------------------------------

function onDeath(player, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
    local playerId = player:getId()
    if nextUseStaminaTime[playerId] ~= nil then
        nextUseStaminaTime[playerId] = nil
    end

    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You are dead.')
    ---------------------------------------------------------------------
    --- here is the part where we need to use our function and table ---
    ---------------------------------------------------------------------
    for i= 1,#text do
            addEvent(sendOwnedText, i * 450, player:getPosition(), text[i])
    end   
    ---------------------------------------------------------
    ---------------------------------------------------------
    ---------------------------------------------------------   
    if player:getStorageValue(Storage.SvargrondArena.Pit) > 0 then
        player:setStorageValue(Storage.SvargrondArena.Pit, 0)
    end

    if not deathListEnabled then
        return
    end

    local byPlayer = 0
    local killerName
    if killer ~= nil then
        if killer:isPlayer() then
            byPlayer = 1
        else
            local master = killer:getMaster()
            if master and master ~= killer and master:isPlayer() then
                killer = master
                byPlayer = 1
            end
        end
        killerName = killer:isMonster() and killer:getType():getNameDescription() or killer:getName()
    else
        killerName = 'field item'
    end

    local byPlayerMostDamage = 0
    local mostDamageKillerName
    if mostDamageKiller ~= nil then
        if mostDamageKiller:isPlayer() then
            byPlayerMostDamage = 1
        else
            local master = mostDamageKiller:getMaster()
            if master and master ~= mostDamageKiller and master:isPlayer() then
                mostDamageKiller = master
                byPlayerMostDamage = 1
            end
        end
        mostDamageName = mostDamageKiller:isMonster() and mostDamageKiller:getType():getNameDescription() or mostDamageKiller:getName()
    else
        mostDamageName = 'field item'
    end

    local playerGuid = player:getGuid()
    db.query('INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `is_player`, `mostdamage_by`, `mostdamage_is_player`, `unjustified`, `mostdamage_unjustified`) VALUES (' .. playerGuid .. ', ' .. os.time() .. ', ' .. player:getLevel() .. ', ' .. db.escapeString(killerName) .. ', ' .. byPlayer .. ', ' .. db.escapeString(mostDamageName) .. ', ' .. byPlayerMostDamage .. ', ' .. (unjustified and 1 or 0) .. ', ' .. (mostDamageUnjustified and 1 or 0) .. ')')
    local resultId = db.storeQuery('SELECT `player_id` FROM `player_deaths` WHERE `player_id` = ' .. playerGuid)

    local deathRecords = 0
    local tmpResultId = resultId
    while tmpResultId ~= false do
        tmpResultId = result.next(resultId)
        deathRecords = deathRecords + 1
    end

    if resultId ~= false then
        result.free(resultId)
    end

    local limit = deathRecords - maxDeathRecords
    if limit > 0 then
        db.asyncQuery("DELETE FROM `player_deaths` WHERE `player_id` = " .. playerGuid .. " ORDER BY `time` LIMIT " .. limit)
    end

    if byPlayer == 1 then
        local targetGuild = player:getGuild()
        targetGuild = targetGuild and targetGuild:getId() or 0
        if targetGuild ~= 0 then
            local killerGuild = killer:getGuild()
            killerGuild = killerGuild and killerGuild:getId() or 0
            if killerGuild ~= 0 and targetGuild ~= killerGuild and isInWar(playerId, killer.uid) then
                local warId = false
                resultId = db.storeQuery('SELECT `id` FROM `guild_wars` WHERE `status` = 1 AND ((`guild1` = ' .. killerGuild .. ' AND `guild2` = ' .. targetGuild .. ') OR (`guild1` = ' .. targetGuild .. ' AND `guild2` = ' .. killerGuild .. '))')
                if resultId ~= false then
                    warId = result.getNumber(resultId, 'id')
                    result.free(resultId)
                end

                if warId ~= false then
                    db.asyncQuery('INSERT INTO `guildwar_kills` (`killer`, `target`, `killerguild`, `targetguild`, `time`, `warid`) VALUES (' .. db.escapeString(killerName) .. ', ' .. db.escapeString(player:getName()) .. ', ' .. killerGuild .. ', ' .. targetGuild .. ', ' .. os.time() .. ', ' .. warId .. ')')
                end
            end
        end
    end
end
 
Back
Top