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.
Feel free to help shorten or improve it.
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: