• 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+ Add a log to an action

primate

Member
Joined
Apr 14, 2009
Messages
68
Solutions
1
Reaction score
5
Location
Colombia, Medellín.
How can I add a log in a SQL table when executing any scripts in actions.

Additional Information:

IDNAME PLAYERDate and Time

Lua:
local playerPosition = {
    {x = 247, y = 659, z = 13},
    {x = 247, y = 660, z = 13},
    {x = 247, y = 661, z = 13},
    {x = 247, y = 662, z = 13}
}
local newPosition = {
    {x = 189, y = 650, z = 13},
    {x = 189, y = 651, z = 13},
    {x = 189, y = 652, z = 13},
    {x = 189, y = 653, z = 13}
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 1945 then
        local players = {}
        for _, position in ipairs(playerPosition) do
            local topPlayer = Tile(position):getTopCreature()
            if not topPlayer or not topPlayer:isPlayer() or topPlayer:getLevel() < 100 or topPlayer:getStorageValue(PlayerStorageKeys.annihilatorReward) ~= -1 then
                player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
                return false
            end
            players[#players + 1] = topPlayer
        end

        for i, targetPlayer in ipairs(players) do
            Position(playerPosition[i]):sendMagicEffect(CONST_ME_POFF)
            targetPlayer:teleportTo(newPosition[i], false)
            targetPlayer:getPosition():sendMagicEffect(CONST_ME_ENERGYAREA)
        end
        item:transform(1946)
    elseif item.itemid == 1946 then
        player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
    end
    return true

Thanks for your time.
 
Last edited:
How can I add a log in a SQL table when executing any scripts in actions.

Additional Information:

IDNAME PLAYERDate and Time

Lua:
local playerPosition = {
    {x = 247, y = 659, z = 13},
    {x = 247, y = 660, z = 13},
    {x = 247, y = 661, z = 13},
    {x = 247, y = 662, z = 13}
}
local newPosition = {
    {x = 189, y = 650, z = 13},
    {x = 189, y = 651, z = 13},
    {x = 189, y = 652, z = 13},
    {x = 189, y = 653, z = 13}
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 1945 then
        local players = {}
        for _, position in ipairs(playerPosition) do
            local topPlayer = Tile(position):getTopCreature()
            if not topPlayer or not topPlayer:isPlayer() or topPlayer:getLevel() < 100 or topPlayer:getStorageValue(PlayerStorageKeys.annihilatorReward) ~= -1 then
                player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
                return false
            end
            players[#players + 1] = topPlayer
        end

        for i, targetPlayer in ipairs(players) do
            Position(playerPosition[i]):sendMagicEffect(CONST_ME_POFF)
            targetPlayer:teleportTo(newPosition[i], false)
            targetPlayer:getPosition():sendMagicEffect(CONST_ME_ENERGYAREA)
        end
        item:transform(1946)
    elseif item.itemid == 1946 then
        player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
    end
    return true

Thanks for your time.

Do you want to record events from all quest levers or just from this one?
 
Back
Top