I've been running a server for the past few weeks between my friends while I get it to a standard I'd be happy to make public. I keep running into a problem with various scripts where I simply can NOT get any functions to work that deal with being in battle.
I've been scouring the forums looking for something, with the most common fix being to add CONDITIONID_DEFAULT, though this doesn't work for me. My scripts are running without errors though they always work when in combat. I'm absolutely out of ideas.
EDIT: TFS 1.2
My current creaturescript lua file is:
This functions exactly as I'd like it to with a cooldown and delayed teleport to the temple, however it will always work in in battle no matter what I change. I'd appreciate any advice, thanks!
I've been scouring the forums looking for something, with the most common fix being to add CONDITIONID_DEFAULT, though this doesn't work for me. My scripts are running without errors though they always work when in combat. I'm absolutely out of ideas.
EDIT: TFS 1.2
My current creaturescript lua file is:
Lua:
function onThink(creature, interval)
local player = Player(creature)
if not Player(player) then
return creature:unregisterEvent("tpTimer")
end
if player:getCondition(CONDITION_INFIGHT) then
player:sendTextMessage(MESSAGE_STATUS_WARNING, "You are in combat! Teleport failed.")
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You can't teleport while in combat.")
return player:unregisterEvent("tpTimer")
end
if player:getStorageValue(10) < os.time() then
player:getPosition():sendMagicEffect(CONST_ME_POFF)
player:teleportTo(player:getTown():getTemplePosition())
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
return player:unregisterEvent("tpTimer")
end
local remaining = math.ceil(player:getStorageValue(10) - os.time()) * 1000
player:sendTextMessage(MESSAGE_STATUS_SMALL, "Time before teleport: "..remaining..".")
return true
end
This functions exactly as I'd like it to with a cooldown and delayed teleport to the temple, however it will always work in in battle no matter what I change. I'd appreciate any advice, thanks!