• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

TFS 1.X+ storages teleport style private cave

old

Premium User
Premium User
Joined
Aug 19, 2018
Messages
10
Reaction score
1
help i got this script it works almost everything except teleports based on storages
I suspect that the error is in this part
Lua:
 local superUpVariavel = SUPERUP.areas[item.actionid]

        if not superUpVariavel then

            player:teleportTo(fromPosition, true)

            player:getPosition():sendMagicEffect(CONST_ME_POFF)

            return true

        end
but I already tried many things and I could not solve it if someone could help me please

this is the complete code of movements
Lua:
function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return false
    end
        
    local tempo = SUPERUP.setTime * 60 * 60

        local superUpVariavel = SUPERUP.areas[item.actionid]
        if not superUpVariavel then
            player:teleportTo(fromPosition, true)
            player:getPosition():sendMagicEffect(CONST_ME_POFF)
            return true
        end

        if player:getStorageValue(STORAGEVALUE_SUPERUP_INDEX) == item.actionid then
            return true
        end

        local value = SUPERUP:getCave(item.actionid)
        if not value then
            return false
        end

        local playerName = db.storeQuery(string.format("SELECT name FROM players WHERE id = %d", value.dono))
        local nome = result.getDataString(playerName, "name")

        if value.dono > 0 and value.tempo > 0 then
            player:sendCancelMessage(string.format(SUPERUP.msg.naoDisponivel, nome, os.date("%c", value.tempo)))
            player:teleportTo(fromPosition, true)
            player:getPosition():sendMagicEffect(CONST_ME_POFF)
        elseif player:getStorageValue(STORAGEVALUE_SUPERUP_INDEX) >= 1 then
            player:sendCancelMessage(SUPERUP.msg.possuiCave)
            player:teleportTo(fromPosition, true)
            player:getPosition():sendMagicEffect(CONST_ME_POFF)
        else
            if player:removeItem(SUPERUP.itemID, 1) then
                player:sendCancelMessage(string.format(SUPERUP.msg.disponivel, SUPERUP.setTime, SUPERUP.setTime > 1 and "horas" or "hora"))
                player:getPosition():sendMagicEffect(31)
                player:setStorageValue(STORAGEVALUE_SUPERUP_TEMPO, (os.time() + tempo))
                player:setStorageValue(STORAGEVALUE_SUPERUP_INDEX, item.actionid)
                local guid = player:getGuid()
                db.query(string.format("UPDATE exclusive_hunts SET `guid_player` = %d, `time` = %s, `to_time` = %s WHERE `hunt_id` = %d", guid, os.time(), (os.time() + tempo), item.actionid))
            else
                player:sendCancelMessage(string.format(SUPERUP.msg.naoItem, ItemType(SUPERUP.itemID):getName()))
                player:teleportTo(fromPosition, true)
                player:getPosition():sendMagicEffect(CONST_ME_POFF)
            end
        end
        return true
end
 
Solution
really? Since I'm learning from this, I don't know enough to interpret it. I understand that the code to make a storage work is
Lua:
Player:teleportTo(position)
Or
Lua:
local area = x,y,z

Player:teleportTo(area)

According to what I have read in the src
first you have to see if the character has the storage, then if he has, determine where he will be teleported

Like this:
Lua:
if player:getStorageValue(STORAGE) == 1 then
player:teleportTo(POSITION)
end
OP
OP
O

old

Premium User
Premium User
Joined
Aug 19, 2018
Messages
10
Reaction score
1
really? Since I'm learning from this, I don't know enough to interpret it. I understand that the code to make a storage work is
Lua:
Player:teleportTo(position)
Or
Lua:
local area = x,y,z

Player:teleportTo(area)

According to what I have read in the src
 

mano368

Well-Known Member
Joined
Sep 2, 2011
Messages
210
Solutions
25
Reaction score
84
Location
Brazil
really? Since I'm learning from this, I don't know enough to interpret it. I understand that the code to make a storage work is
Lua:
Player:teleportTo(position)
Or
Lua:
local area = x,y,z

Player:teleportTo(area)

According to what I have read in the src
first you have to see if the character has the storage, then if he has, determine where he will be teleported

Like this:
Lua:
if player:getStorageValue(STORAGE) == 1 then
player:teleportTo(POSITION)
end
 
Solution
OP
OP
O

old

Premium User
Premium User
Joined
Aug 19, 2018
Messages
10
Reaction score
1
first you have to see if the character has the storage, then if he has, determine where he will be teleported

Like this:
Lua:
if player:getStorageValue(STORAGE) == 1 then
player:teleportTo(POSITION)
end
thanks for this solution i need use different variable but is good example
 
Top