• 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.0 | attempt to call method `getTopCreature` <a nihil value> error

dhrsantan

A.K.A Lbakiller
Joined
Nov 27, 2014
Messages
94
Reaction score
10
Location
The netherlands
I'm using TFS 1.0
Trying to do a teleport if the player is standing on a certain title. and pulls the lever.
Code:
local roomCenter = {x = 541, y = 672, z = 6} -- the center of the boss room

local RangeX = 3 -- te range from the center to the edge of the bossroom on the x axis.
local RangeY = 3 -- te range from the center to the edge of the bossroom on the y axis.

local player1NewPos = {x = 547, y = 671, z = 6} -- where player one should be teleported to

local player1OldPos = {x = 555, y = 673, z = 6} -- the place where player one should stand

function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
    local spectators = Game.getSpectators(roomCenter, false, true, 0, RangeX, 0, RangeY)

    for i = 1, #spectators do
        local spectator = spectators[i]

        if spectator:isPlayer() then
            print('test')
            Player(cid):sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_NOTPOSSIBLE))
            return false
        end
    end

    local player1 = player1OldPos:getTopCreature()

    if player1:isPlayer() then
        print('player 1 found')
        --player1:teleportTo(player1NewPos, false)
    end
end
 

Similar threads

Back
Top