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

TalkAction Teleport to your house command!

Cornex

Web Developer
Staff member
Global Moderator
Joined
Jun 15, 2008
Messages
3,444
Solutions
5
Reaction score
1,166
Location
Sweden
Hello, i want to release an small scripts that allows you to tp to your own house.
This version got exhaustion time (10sec)..

I want also thanks Znote for some support <3

Make an new file in talkactions/script name it tphouse.lua and paste this into it:

Lua:
function onSay(cid, words, param, channel)
        local playerPos = getCreaturePosition(cid)

        if exhaustion.check(cid, 7612) == false then
                if getHouseByPlayerGUID(getPlayerGUID(cid)) and getCreatureCondition(cid, CONDITION_INFIGHT) == false then
                        doTeleportThing(cid, getHouseEntry(getHouseByPlayerGUID(getPlayerGUID(cid))))
                        doSendMagicEffect(playerPos, CONST_ME_TELEPORT)
                        doSendAnimatedText(playerPos, 'Bye!', TEXTCOLOR_GREEN)
                        exhaustion.set(cid, 7612, 10)
                elseif  getCreatureCondition(cid, CONDITION_INFIGHT) == true then
                        doSendAnimatedText(playerPos, 'PZ Locked!', TEXTCOLOR_RED)
                        exhaustion.set(cid, 7612, 10)
                elseif getHouseByPlayerGUID(getPlayerGUID(cid)) == nil then
                	    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You dont own a house!")
                end
        else
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are exhausted!")
        end
        return true
end


And open talkactions.xml and put this line

Lua:
  <talkaction words="!gohouse" event="script" value="tphouse.lua"/>

rkr51c.gif
 
Last edited:
Lua:
function onSay(cid, words, param, channel)
local storage = 2313
local playerPos = getCreaturePosition(cid)
	if exhaustion.check(cid, storage) ~= false then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, 'You must ' .. exhaustion.get(cid, storage) .. ' seconds')
	end
        if getHouseByPlayerGUID(getPlayerGUID(cid)) then
            doTeleportThing(cid, getHouseInfo(getHouseByPlayerGUID(getPlayerGUID(cid))).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(getPlayerGUID(cid)) ~= nil then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You dont own a house!")
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are exhausted!")
        end
    return true
end

:D
 
Lua:
function onSay(cid, words, param, channel)
local storage = 2313
local playerPos = getCreaturePosition(cid)
	if exhaustion.check(cid, storage) ~= false then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, 'You must ' .. exhaustion.get(cid, storage) .. ' seconds')
	end
        if getHouseByPlayerGUID(getPlayerGUID(cid)) then
            doTeleportThing(cid, getHouseInfo(getHouseByPlayerGUID(getPlayerGUID(cid))).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(getPlayerGUID(cid)) ~= nil then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You dont own a house!")
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are exhausted!")
        end
    return true
end

:D

Was good with that countdowner, but you forgot to remove:

Lua:
else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are exhausted!")

So it should be:

Lua:
function onSay(cid, words, param, channel)
local storage = 2313
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(getPlayerGUID(cid)) then
            doTeleportThing(cid, getHouseInfo(getHouseByPlayerGUID(getPlayerGUID(cid))).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(getPlayerGUID(cid)) ~= nil then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You dont own a house!")
        end
    return true
end
 
This doesn't work for 0.3.6

It just teleports the player to the same tile they're currently standing in says "BYE"??

Have any idea why?
 
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/tphouse.lua:eek:nSay
data/talkactions/scripts/tphouse.lua:4: attempt to index global 'exhaustion' (a nil value)
stack traceback:
[C]: in function '__index'
data/talkactions/scripts/tphouse.lua:4: in function <data/talkactions/scripts/tphouse.lua:1>

can anybody help me out?
 
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/tphouse.lua:eek:nSay
data/talkactions/scripts/tphouse.lua:4: attempt to index global 'exhaustion' (a nil value)
stack traceback:
[C]: in function '__index'
data/talkactions/scripts/tphouse.lua:4: in function <data/talkactions/scripts/tphouse.lua:1>

can anybody help me out?
this is a script for older versions
try this instead
Code:
local function Player.setExhaustion(self, key, val)
    return self:setStorageValue(key, os.time() + val)
end

local function Player.hasExhaustion(self, key)
    return (os.time() - self:getStorageValue(key)) > 0
end


local exhaust = 89999

function onSay(player, words, param)
    local house = player:getHouse()
    if not house then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'You do not have a house.')
    end
    if not player:hasExhaustion(exhaust) then
        local pos = house:getExitPosition()
        player:teleportTo(pos)
        player:setExhaustion(exhaust, 10)
        pos:sendMagicEffect(CONST_ME_TELEPORT)
    end
    return true
end
 
I tried to make it work but im not good in lua xD
This is working for me in TFS 1.x
Restrictions
  • You can't use this command when you are PK or PZ Red
  • If you don't have any house, u simply can't.
  • But if u have a house and u have no PK, u might use the command.
P.S: Still having problems with exhaust. If someone can help me please. s2
Lua:
function onSay(player, words, param)
    local house = player:getHouse()

    if player:isPzLocked() then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can't use this command while you are PK!")
        return false
    end

    if not house then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You do not have a house.")
    end

    if house then
        local pos = house:getExitPosition()
        player:teleportTo(pos)
        player:setExhaustion(exhaust, 12000)
        pos:sendMagicEffect(CONST_ME_TELEPORT)
    end
    return true
end
 
Last edited:
Code:
local function Player.setExhaustion(self, value, time)
    self:setStorageValue(value, time + os.time())
end
local function Player.getExhaustion(self, value)
    local storage = self:getStorageValue(value)
    if not storage or storage <= os.time() then
        return 0
    end
    return storage - os.time()
end

local config = {
    storage = 1000,
    pzlocked = true,
    cooldown = 10 -- seconds
}

function onSay(player, words, param)
    local house = player:getHouse()
    if not house then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "You do not have a house.")
        return false
    end

    local cooldown = player:getExhaustion(config.storage)
    if cooldown > 0 then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "Teleport cooldown: (".. cd ..") seconds.")
        return false
    end

    if config.pzlocked and player:isPzLocked() then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "You can't teleport during battles.")
        return false
    end

    local houseExitPosition = house:getExitPosition()
    player:teleportTo(houseExitPosition)
    houseExitPosition:sendMagicEffect(CONST_ME_TELEPORT)
    player:setExhaustion(config.storage, config.cooldown)
    return false
end
 
@Printer Thx for share your code, idk is not working for me... :( I think i'll have to learn more about Lua.



I know @Xeraphus, but my server is hosted on linux and i cant see the console due its based on CLI
 
Last edited:
I would like to use this script, but to do something like !home PLAYERNAME to teleport another player to MY house.
 
actually this one

Lua:
local function Player.setExhaustion(self, value, time)
    self:setStorageValue(value, time + os.time())
end
local function Player.getExhaustion(self, value)
    local storage = self:getStorageValue(value)
    if not storage or storage <= os.time() then
        return 0
    end
    return storage - os.time()
end
local config = {
    storage = 1000,
    pzlocked = true,
    cooldown = 10 -- seconds
}
function onSay(player, words, param)
    if param ~= "" then
        target = Player(param)
    else
        target = player
    end
   
    if not target then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "Player is not online or does not exist.")
        return false
    end
    local house = player:getHouse()
    if not house then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "You do not have a house.")
        return false
    end
    local cooldown = player:getExhaustion(config.storage)
    if cooldown > 0 then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "Teleport cooldown: (".. cd ..") seconds.")
        return false
    end
   
    if config.pzlocked and player:isPzLocked() then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "You cannot teleport yourself or other while in combat.")
        return false
    end
    if config.pzlocked and target:isPzLocked() then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "You can't teleport yourself or others while either are in battle.")
        return false
    end
   
    if player:getSkull() ~= SKULL_NONE then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "You can't teleport yourself or players with a skull.")
        return false
    end
   
    if target:getSkull() ~= SKULL_NONE then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "You can't teleport yourself or a player with a skull.")
        return false
    end
    local houseExitPosition = house:getExitPosition()
    target:teleportTo(houseExitPosition)
    houseExitPosition:sendMagicEffect(CONST_ME_TELEPORT)
    player:setExhaustion(config.storage, config.cooldown)
    return false
end
 
Back
Top