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

RevScripts Monster item Spawner

Kawaki69

Member
Joined
Mar 4, 2022
Messages
72
Reaction score
8
Requesting an item that spawn monster if you clicked on it and it have 1 minuet cooldown.
Thanks
 
Solution
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

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...
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

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()
 
Solution
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()
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 appear
Code:
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>
 
Its because u cant spawn a monster inside of protection zone.

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)

    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()
 
Back
Top Bottom