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

Teleport to house door?

Forsaken13126

Scripter
Joined
Feb 4, 2010
Messages
224
Reaction score
3
Location
New York
Was curious if anyone had a script to teleport the player to the doorway of their house? For example: Right click an item and it finds their house and the location of the tile outside the door and teleports them to it? Or maybe even make it so they can rightclick a tile in the server and set that as the teleport spot for that item?

Im using: The Forgotten Server 8.60 V2
 
Would there be anyway to make this find an account house? instead of player? like account ID 6 so you could use said item for the entire account or do u think that wouldnt work?

I think it might work, BUT because you can own multiple houses on same account, It would probably bug if a player had more then 1 house
 
You can do it like this.
https://otland.net/threads/house-system.147387/page-3#post-1420375
But then instead of checking if the account owns a house, teleport to the house like in the other script.

Do you think if maybe i just add this:
Code:
function getPlayersByAccount(id)
local f = db.getResult("SELECT `id` FROM `players` WHERE `account_id` = "..id..";")
local players = {}
if f:getID() ~= -1 then
repeat
table.insert(players, f:getDataInt("id"))
until not f:next()
f:free()
end
return players
end
and then change all the players to account it will allow that to work? or would i need to edit more of the script.
 
Last edited:
You are using TFS 0.3.6 right? That script is for TFS 1.0.

Yeah i fixed that part xD i used the wrong script :) just working on making it search by account now :)

I think it might work, BUT because you can own multiple houses on same account, It would probably bug if a player had more then 1 house
ALso i made it so only 1 house per account :) so i wont have that issue
 
Last edited by a moderator:
You can use a loop, for example like this.
Code:
local players = getPlayersByAccount(getPlayerAccountId(cid))
for x = 1, #players do
     if getHouseByPlayerGUID(players[x]) then
It will be basicly the same except that you add a loop to get the player with the house and use players[x] then instead of getPlayerGUID(cid) to get the player id.
 
You can use a loop, for example like this.
Code:
local players = getPlayersByAccount(getPlayerAccountId(cid))
for x = 1, #players do
     if getHouseByPlayerGUID(players[x]) then
It will be basicly the same except that you add a loop to get the player with the house and use players[x] then instead of getPlayerGUID(cid) to get the player id.
Code:
function onUse(cid, item, frompos, item2, topos)
local storage = 2313
local players = getPlayersByAccount(getPlayerAccountId(cid))
for x = 1, #players do
     if getHouseByPlayerGUID(players[x]) then
local playerPos = getCreaturePosition(cid)
if exhaustion.check(cid, storage) ~= false then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, 'You must wait ' .. exhaustion.get(cid, storage) .. ' seconds')
end
if getHouseByPlayerGUID(players[x]) then
doTeleportThing(cid, getHouseInfo(getHouseByPlayerGUID(players[x])).entry)
doSendMagicEffect(playerPos, CONST_ME_TELEPORT)
doSendAnimatedText(playerPos, 'Bye!', TEXTCOLOR_GREEN)
exhaustion.set(cid, storage, 10)
return true
end

if isPlayerPzLocked(cid) or getCreatureCondition(cid, CONDITION_INFIGHT) then
doSendAnimatedText(playerPos, 'PZ Locked!', TEXTCOLOR_RED)
exhaustion.set(cid, storage, 10)
end

if getHouseByPlayerGUID(players[x]) ~= nil then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You dont own a house!")
end
return true
end
i tried using that, and i get this error
Code:
[04/08/2015 22:05:37] [Error - LuaScriptInterface::loadFile] data/actions/scripts/Housetp.lua:27: 'end' expected (to close 'for' at line 4) near '<eof>'
[04/08/2015 22:05:37] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/Housetp.lua)
[04/08/2015 22:05:37] data/actions/scripts/Housetp.lua:27: 'end' expected (to close 'for' at line 4) near '<eof>'

if i add the end then i get this error:
Code:
[04/08/2015 22:16:01] [Error - LuaScriptInterface::loadFile] data/actions/scripts/Housetp.lua:29: 'end' expected (to close 'function' at line 1) near '<eof>'
[04/08/2015 22:16:01] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/Housetp.lua)
[04/08/2015 22:16:01] data/actions/scripts/Housetp.lua:29: 'end' expected (to close 'function' at line 1) near '<eof>'
 
Last edited:
Code:
local storage = 2313

local function getPlayersByAccount(id)
     local f = db.getResult("SELECT `id` FROM `players` WHERE `account_id` = "..id..";")
     local players = {}
     if f:getID() ~= -1 then
         repeat
             table.insert(players, f:getDataInt("id"))
         until not f:next()
         f:free()
     end
     return players
end

function onUse(cid, item, fromPosition, itemEx, toPosition)

     local playerPos = getCreaturePosition(cid)
     if exhaustion.check(cid, storage) then
         return doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, 'You must wait ' .. exhaustion.get(cid, storage) .. ' seconds.')
     end
     if getCreatureCondition(cid, CONDITION_INFIGHT) then
         return doSendAnimatedText(playerPos, 'In Fight!', TEXTCOLOR_RED)
     end
     local players = getPlayersByAccount(getPlayerAccountId(cid))
     for x = 1, #players do
         if getHouseByPlayerGUID(players[x]) then
             doTeleportThing(cid, getHouseInfo(getHouseByPlayerGUID(players[x])).entry)
             doSendMagicEffect(playerPos, CONST_ME_TELEPORT)
             doSendAnimatedText(playerPos, 'Bye!', TEXTCOLOR_GREEN)
             exhaustion.set(cid, storage, 10)
             return true
         end
     end
     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You don't own a house!")
     return true
end
 
Code:
local storage = 2313

local function getPlayersByAccount(id)
     local f = db.getResult("SELECT `id` FROM `players` WHERE `account_id` = "..id..";")
     local players = {}
     if f:getID() ~= -1 then
         repeat
             table.insert(players, f:getDataInt("id"))
         until not f:next()
         f:free()
     end
     return players
end

function onUse(cid, item, fromPosition, itemEx, toPosition)

     local playerPos = getCreaturePosition(cid)
     if exhaustion.check(cid, storage) then
         return doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, 'You must wait ' .. exhaustion.get(cid, storage) .. ' seconds.')
     end
     if getCreatureCondition(cid, CONDITION_INFIGHT) then
         return doSendAnimatedText(playerPos, 'In Fight!', TEXTCOLOR_RED)
     end
     local players = getPlayersByAccount(getPlayerAccountId(cid))
     for x = 1, #players do
         if getHouseByPlayerGUID(players[x]) then
             doTeleportThing(cid, getHouseInfo(getHouseByPlayerGUID(players[x])).entry)
             doSendMagicEffect(playerPos, CONST_ME_TELEPORT)
             doSendAnimatedText(playerPos, 'Bye!', TEXTCOLOR_GREEN)
             exhaustion.set(cid, storage, 10)
             return true
         end
     end
     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You don't own a house!")
     return true
end
Thanks :) it works, i had jsut come up with that.. but i forgot to remove the beginning function so it wasnt erroring, just not working :) working 100% now by account :D thanks alot for your help
 
Back
Top