• 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 Homecoming stone/command. Teleport you to pos after countdown (if not in fight etc.)

Ub Kenobi

Member
Joined
Apr 10, 2009
Messages
144
Reaction score
8
Location
Sweden
Hey, I'm releasing my first script here on otland. It's tested by me and works for 100%.

After using talkaction !home, the player will get an animated countdown over his/her head. (ex. starts from 10, 9, 8, 7, 6... in seconds) When the countdown reaches 0 you will be teleported home to temple.

*If you are in fight, it will not work. Same if you gets into fight while countdown is on, it will be canceled.

TODO:
Cancel command if player moves. I cant figure out how to do it. I was getting errors when I tryed to fix it...

EDIT: Added: if you move character while countdown is on, the command will be canceled.



XML:
<talkaction words="!home" event="script" value="tpTemple.lua"/>

Lua:
local temple = {x=1005, y=1001, z=7} -- destination position
local level = 20 -- level to ues this command
local loadingTime = 10  -- in seconds -- How long you have to wait until teleported
local storage = 58478
local exhaust = 10 -- Time until you can cast this command again

function countDown(n, cid)
	if getPlayerStorageValue(cid, storage) == 1 then
	local pos = getPlayerPosition(cid)
	local playerPos = getThingPos(cid)
		if getPlayerStorageValue(cid, storage + 1) == playerPos.x and getPlayerStorageValue(cid, storage + 2) == playerPos.y then
			if getCreatureCondition(cid, CONDITION_INFIGHT) == false then
				if(n > 0) then
					doSendAnimatedText(pos, n, TEXTCOLOR_RED)
					doSendMagicEffect(pos, 7)
					addEvent(countDown, 1000, n - 1, cid)
				else
						
					doSendAnimatedText(pos, "I'M OUT!", TEXTCOLOR_RED)
					doSendMagicEffect(pos, CONST_ME_POFF)
					doTeleportThing(cid, temple)
					doSendMagicEffect(temple, CONST_ME_TELEPORT)
					setPlayerStorageValue(cid, storage, 0)
					doRemoveConditions(cid, false)
						
				end
			else
				doPlayerSendCancel(cid, 'Command canceled. Get out of fight!')
				setPlayerStorageValue(cid, storage, 0)
			end
		else
			doPlayerSendCancel(cid, 'Command canceled. You are moving!')
			setPlayerStorageValue(cid, storage, 0)
		end
	end

end

function onSay(cid, words, param, channel, position) 
	if exhaustion.get(cid, 101) then
		doPlayerSendCancel(cid, 'You can use this command only once per 10 seconds.')
		return true
	end
	exhaustion.set(cid, 101, exhaust)
	if isPlayerPzLocked(cid) then
		doPlayerSendTextMessage(cid,MESSAGE_STATUS_SMALL,"You cannot use this command while you are pz locked.")
		return true
	end 
	if getCreatureCondition(cid, CONDITION_INFIGHT) then
         return doPlayerSendCancel(cid, 'You can\'t use this command in fight.')
    end
	if getPlayerLevel(cid) < level then
		return doPlayerSendCancel(cid, 'You need to be from level '..level..' to use this command.')
	end
	
	local pos = getThingPos(cid)
	setPlayerStorageValue(cid, storage + 1, pos.x)
	setPlayerStorageValue(cid, storage + 2, pos.y)
	setPlayerStorageValue(cid, storage, 1)
	
	countDown(loadingTime, cid)
	
	return true
end

Feel free to help shorten or improve it.
 
Last edited:
Try using just 1 tab when needed, not 2 it looks fugly like that :p
 
Why loop through all the players when you can get "cid" (pid) from the function? Also, it's gonna break if 2 or more players are using the command at the same time.
 
Why loop through all the players when you can get "cid" (pid) from the function? Also, it's gonna break if 2 or more players are using the command at the same time.

Thx for tip! You were right!

Here is the new fixed version: (Also updated topic)

Lua:
local temple = {x=1005, y=1001, z=7} -- destination position
local level = 20 -- level to ues this command
local loadingTime = 10  -- in seconds -- How long you have to wait until teleported
local storage = 58478
local exhaust = 10 -- Time until you can cast this command again

function countDown(n, cid)
	if getPlayerStorageValue(cid, storage) == 1 then
	local pos = getPlayerPosition(cid)
	local playerPos = getThingPos(cid)
		if getPlayerStorageValue(cid, storage + 1) == playerPos.x and getPlayerStorageValue(cid, storage + 2) == playerPos.y then
			if getCreatureCondition(cid, CONDITION_INFIGHT) == false then
				if(n > 0) then
					doSendAnimatedText(pos, n, TEXTCOLOR_RED)
					doSendMagicEffect(pos, 7)
					addEvent(countDown, 1000, n - 1, cid)
				else
						
					doSendAnimatedText(pos, "I'M OUT!", TEXTCOLOR_RED)
					doSendMagicEffect(pos, CONST_ME_POFF)
					doTeleportThing(cid, temple)
					doSendMagicEffect(temple, CONST_ME_TELEPORT)
					setPlayerStorageValue(cid, storage, 0)
					doRemoveConditions(cid, false)
						
				end
			else
				doPlayerSendCancel(cid, 'Command canceled. Get out of fight!')
				setPlayerStorageValue(cid, storage, 0)
			end
		else
			doPlayerSendCancel(cid, 'Command canceled. You are moving!')
			setPlayerStorageValue(cid, storage, 0)
		end
	end

end

function onSay(cid, words, param, channel, position) 
	if exhaustion.get(cid, 101) then
		doPlayerSendCancel(cid, 'You can use this command only once per 10 seconds.')
		return true
	end
	exhaustion.set(cid, 101, exhaust)
	if isPlayerPzLocked(cid) then
		doPlayerSendTextMessage(cid,MESSAGE_STATUS_SMALL,"You cannot use this command while you are pz locked.")
		return true
	end 
	if getCreatureCondition(cid, CONDITION_INFIGHT) then
         return doPlayerSendCancel(cid, 'You can\'t use this command in fight.')
    end
	if getPlayerLevel(cid) < level then
		return doPlayerSendCancel(cid, 'You need to be from level '..level..' to use this command.')
	end
	
	local pos = getThingPos(cid)
	setPlayerStorageValue(cid, storage + 1, pos.x)
	setPlayerStorageValue(cid, storage + 2, pos.y)
	setPlayerStorageValue(cid, storage, 1)
	
	countDown(loadingTime, cid)
	
	return true
end
 
Last edited:
I thought just who had storage That could use the command , it's possible ?
how ? I can do it, but, this will work ?? haha tks tks
 
Back
Top