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

Solved [TFS 1.2] Movement (If player then..)

Caduceus

Unknown Member
Joined
May 10, 2010
Messages
321
Solutions
2
Reaction score
24
If a player is on playerPositions, then next player that tries to enter gets message & teleportTo(fromPosition).
As of right now, nobody can enter the room, even if playerPos is nil.

Code:
local playerPositions = Position(603, 975, 15)

function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return false
    end

            if playerPositions == nil then
            return false
        else
            player:sendTextMessage(MESSAGE_INFO_DESCR, "This table is full.")
            player:teleportTo(fromPosition, false)
            player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
            return true
            end
        end

solution:
Code:
local playerPositions = Position(1002, 935, 10)

function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return false
    end
        local specs, spec = Game.getSpectators(playerPositions, false, false, 1, 1, 1, 1)
        for i = 1, #specs do
            spec = specs[i]
            if spec:isPlayer() then
                player:teleportTo(fromPosition, false)
                player:sendTextMessage(MESSAGE_STATUS_SMALL, "You Shall Not Pass.")
                return true
            end
        end
    end
 
Last edited:
Code:
function onStepIn(creature, item, position, fromPosition)
local player = creature:getPlayer()
if not player then
return false
end
topCreature = Tile(position):getTopCreature()
if not Player(topCreature) or not Player(topCreature) or not topCreature:getPlayer() then
return true
else
player:sendTextMessage(MESSAGE_INFO_DESCR, "This table is full.")
fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
return false
end
end
try if this code works, getTopCreature() is a tile metamethod function, ferrari forgot to use Tile(pos) for it :p
this will simply not allow moving to the stepIn position (position in func arguments) if there is a player on there
 
Back
Top