• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Solved looking for a function.

Caduceus

Unknown Member
Joined
May 10, 2010
Messages
321
Solutions
2
Reaction score
24
I am looking for the correct function to use in this statement. to check player's house id. I have searched through this, but cannot seem to locate anything that resembles what I am looking for. I'm sure I've overlooked it somewhere.

player:teleportTo(player:getHouseByPlayerGUID(player:getGuid()))
 
I am looking for the correct function to use in this statement. to check player's house id. I have searched through this, but cannot seem to locate anything that resembles what I am looking for. I'm sure I've overlooked it somewhere.

Dude when you use player:getHouseByPlayerGUID it will probably return a table or the house ID . To teleport there you need a position!! player:teleportTo(position)
 
Something like this? with the current statement as is, I am getting "attempt to index global 'house' (a nil value)"

player:teleportTo(player:getHouse(house:getExitPosition()))

tried both

player:teleportTo(house:getExitPosition(player:getHouse()))

Ok, I figured out the nil value. Solution below. Thank you for the help.
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT) then
        player:say('You cant teleport whilst in battle!', TALKTYPE_MONSTER_SAY)
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
    return true
    end
 
    local house = player:getHouse()
    if house == nil then
        player:sendCancelMessage("You do not own a house.")
        return true
    end

        player:teleportTo(house:getExitPosition())
        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    return true
end
 
Last edited:

Similar threads

Back
Top