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

Ignore if storage xx

xLosT

Member
Joined
Jan 11, 2010
Messages
1,022
Reaction score
13
Location
Brasil, Rio Grande do Sul
How do add not teleport a player with storage xx

i change this
Code:
  local pos, player = mapPositions[newTemple]
        player = players[i]
        player:teleportTo(pos)
to this
Code:
        local pos, player = mapPositions[newTemple], players[i]
     if player:getStorageValue(81262) == 1 then
            player:teleportTo(pos)
So do not teleport anyone

Code:
function onThink(interval, lastExecution)

    if string.lower(rotateMaps) ~= "yes" then
        return true
    end

    local players = Game.getPlayers()
    local currentTemple = Game.getStorageValue(currentMap)

    if #players == 0 then
        return true
    end

    if currentTemple == numberOfMaps then
        Game.setStorageValue(currentMap, 1)
        else
        Game.setStorageValue(currentMap, Game.getStorageValue(currentMap) + 1)
    end

    for i = 1, #players do
        local newTemple = Game.getStorageValue(currentMap)
        local pos, player = mapPositions[newTemple]
        player = players[i]
        player:teleportTo(pos)
        player:addHealth(player:getMaxHealth())
        player:addMana(player:getMaxMana())
        local tmp = {CONDITION_POISON, CONDITION_FIRE, CONDITION_ENERGY, CONDITION_BLEEDING, CONDITION_PARALYZE, CONDITION_INVISIBLE, CONDITION_MANASHIELD, CONDITION_INFIGHT, CONDITION_DRUNK, CONDITION_DROWN, CONDITION_ATTRIBUTES, CONDITION_FREEZING, CONDITION_DAZZLED, CONDITION_CURSED, CONDITION_PACIFIED, CONDITION_SPELLCOOLDOWN, CONDITION_SPELLGROUPCOOLDOWN}
        for i = 1, #tmp do
            player:removeCondition(tmp[i])
        end
        player:sendTextMessage(MESSAGE_STATUS_WARNING, mapChangeText)
    end

    return true
end
 
How do add not teleport a player with storage xx

Edited, compromise logic to make it work for tfs and few unique coded engines
Code:
if not player:getStorageValue(81262) ~= nil and not player:getStorageValue(81262) ~= -1 then
    player:teleportTo(pos)
end
 
Last edited:
all storages return -1 by default, not nil

Many engines before TFS, and even older TFS were using lua_pushnil (L);

That's why this is the best compromise option:
Code:
if player:getStorageValue(81262) ~= nil and player:getStorageValue(81262) ~= -1 then
    return false
else
    player:teleportTo(pos)
end

And right, 1.0 have -1
 
Last edited:
Many engines before TFS, and even older TFS were using lua_pushnil (L);

That's why this is the best compromise option:
Code:
if player:getStorageValue(81262) ~= nil and player:getStorageValue(81262) ~= -1 then
    return false
else
    player:teleportTo(pos)
end

And right, 1.0 have -1
older tfs engines don't use metamethods, and since this is for sure 1.x you can ignore
Code:
if player:getStorageValue(81262) ~= nil

Why? Well, when is a storagevalue going to become nil? If you can answer this question then I can agree with you. If not, it's just an unnecessary imperative.
 
Many engines before TFS, and even older TFS were using lua_pushnil (L);

That's why this is the best compromise option:
Code:
if player:getStorageValue(81262) ~= nil and player:getStorageValue(81262) ~= -1 then
    return false
else
    player:teleportTo(pos)
end

And right, 1.0 have -1
i used 0.3.6/0.4 for over a year till i moved to 1.x
not sure about older versions before 0.3.6 but it's always been -1
either way xLost is using 1.2
 
Last edited:
i used 0.3.6/0.4 for over a year till i moved to 1.x
not sure about older versions before 0.3.6 but it's always been -1
either way xLost is using 1.2
Then you started 6-7 years later. You have own scripting service, you should look around for old scripts and how ppl were using compromise logics there to make script working on few different distro
 
Then you started 6-7 years later. You have own scripting service, you should look around for old scripts and how ppl were using compromise logics there to make script working on few different distro
do you mean that you've been doing Lua scripts for that long? I don't really understand, sorry :p
 
Back
Top