I was already tagging the post for tfs 1.4.1 and i meant by spawning the monster works like /m command behind the player
local action = Action()
local config = {
itemId = 2493,
monsterN = "Demon",
cooldown = 1, -- 60 = 60 seconds
cooldownStorage = 6500,
effect = CONST_ME_HOLYAREA,
effectSpawn = true
}
function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
if player:getStorageValue(config.cooldownStorage) - os.time() > 0 then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can use it again in: "..player:getStorageValue(config.cooldownStorage) - os.time().." seconds.")
return true
end
local monster = Game.createMonster(config.monsterN...
It have cooldown only when you use itDoes the item have the cooldown, or is it per player?
I was already tagging the post for tfs 1.4.1 and i meant by spawning the monster works like /m command behind the playerNo tfs version
Not enough information like where the monster should spawn
I was already tagging the post for tfs 1.4.1 and i meant by spawning the monster works like /m command behind the player
local action = Action()
local config = {
itemId = 2493,
monsterN = "Demon",
cooldown = 1, -- 60 = 60 seconds
cooldownStorage = 6500,
effect = CONST_ME_HOLYAREA,
effectSpawn = true
}
function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
if player:getStorageValue(config.cooldownStorage) - os.time() > 0 then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can use it again in: "..player:getStorageValue(config.cooldownStorage) - os.time().." seconds.")
return true
end
local monster = Game.createMonster(config.monsterN, player:getPosition())
player:setStorageValue(config.cooldownStorage, os.time() + config.cooldown)
if config.effectSpawn then
monster:getPosition():sendMagicEffect(config.effect)
end
return true
end
action:id(config.itemId)
action:register()
ty rep++LUA:local action = Action() local config = { itemId = 2493, monsterN = "Demon", cooldown = 1, -- 60 = 60 seconds cooldownStorage = 6500, effect = CONST_ME_HOLYAREA, effectSpawn = true } function action.onUse(player, item, fromPosition, target, toPosition, isHotkey) if player:getStorageValue(config.cooldownStorage) - os.time() > 0 then player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can use it again in: "..player:getStorageValue(config.cooldownStorage) - os.time().." seconds.") return true end local monster = Game.createMonster(config.monsterN, player:getPosition()) player:setStorageValue(config.cooldownStorage, os.time() + config.cooldown) if config.effectSpawn then monster:getPosition():sendMagicEffect(config.effect) end return true end action:id(config.itemId) action:register()
When i use it in safezone this error appearLUA:local action = Action() local config = { itemId = 2493, monsterN = "Demon", cooldown = 1, -- 60 = 60 seconds cooldownStorage = 6500, effect = CONST_ME_HOLYAREA, effectSpawn = true } function action.onUse(player, item, fromPosition, target, toPosition, isHotkey) if player:getStorageValue(config.cooldownStorage) - os.time() > 0 then player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can use it again in: "..player:getStorageValue(config.cooldownStorage) - os.time().." seconds.") return true end local monster = Game.createMonster(config.monsterN, player:getPosition()) player:setStorageValue(config.cooldownStorage, os.time() + config.cooldown) if config.effectSpawn then monster:getPosition():sendMagicEffect(config.effect) end return true end action:id(config.itemId) action:register()
Lua Script Error: [Scripts Interface]
C:\Users\angelica\Desktop\server\data\scripts\actions\spawner.lua:callback
...\Desktop\server\data\scripts\actions\spawner.lua:22: attempt to index local 'monster' (a nil value)
stack traceback:
[C]: in function '__index'
..\Desktop\server\data\scripts\actions\spawner.lua:22: in function <...\Desktop\server\data\scripts\actions\lucifer_spawner.lua:12>
local action = Action()
local config = {
itemId = 2493,
monsterN = "Demon",
cooldown = 1, -- 60 = 60 seconds
cooldownStorage = 6500,
effect = CONST_ME_HOLYAREA,
effectSpawn = true
}
function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
local tile = player:getTile()
local ground = tile:hasFlag(TILESTATE_PROTECTIONZONE) and tile:getGround()
if ground then
return true
end
if player:getStorageValue(config.cooldownStorage) - os.time() > 0 then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can use it again in: "..player:getStorageValue(config.cooldownStorage) - os.time().." seconds.")
return true
end
local monster = Game.createMonster(config.monsterN, player:getPosition())
player:setStorageValue(config.cooldownStorage, os.time() + config.cooldown)
if config.effectSpawn then
monster:getPosition():sendMagicEffect(config.effect)
end
return true
end
action:id(config.itemId)
action:register()