• 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 Summon Item

Lbtg

Intermediate OT User
Joined
Nov 22, 2008
Messages
2,312
Reaction score
135
Hey! Please help on converting this script into tfs 1,4+ revscript


The script on use summons the monster as pet/summoner monster


Example of my old from 0.4tfs script that didint worked perfectly but did its job good.

Lua:
local config = {
    [6119] = { -- # SCROLL ID # --
        monster = "Demon Skeleton",
        charges = 20,
        mana = 600,
        summons = 2
    }
}

local exhausted = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhausted, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local v = config[item.itemid]
    if table.maxn(getCreatureSummons(cid)) >= v.summons then
        return doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    end
 
    if getCreatureMana(cid) < v.mana then
        return doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    end
   
    if hasCondition(cid, CONDITION_EXHAUST_HEAL) then
        return doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
    end
 
    if item.actionid <= 0 then
        doItemSetAttribute(item.uid, "aid", v.charges - 1)
    elseif item.actionid == 1 then
        doTransformItem(item.uid, 7491)
    else
        doItemSetAttribute(item.uid, "aid", item.actionid - 1)
    end
   
    return doPlayerAddMana(cid, - v.mana) and doSummonMonster(cid, v.monster) and doAddCondition(cid, exhausted) and doItemSetAttribute(item.uid, "description", "It has " .. item.actionid - 1 .. "x charge" .. (item.actionid > 1 and "s" or "") .. ".")
end
 
I only got this simple one, I can't add "charges" and stuff, but at least the script is working, everything is fine.

Lua:
local monster = "Demon Skeleton"

local function onUse(player, item, fromPosition, target, toPosition)
    local cid = player:getId()
    local playerMana = player:getMana()
    local creatures = getCreatureSummons(cid)
   
    local aliveCount = 0
    for _, creature in ipairs(creatures) do
        if isCreature(creature) then
            aliveCount = aliveCount + 1
        end
    end
   
    if aliveCount >= 2 then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_RED, "You cannot summon more creatures, two are already alive.")
        return false
    end
   
    if playerMana < 600 then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_RED, "Not enough mana.")
        return false
    end
   
    if not player:removeItem(item:getId(), 1) then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_RED, "You don't have the required item.")
        return false
    end
   
    doSummonMonster(cid, monster)
    player:addMana(-600)
   
    return true
end

local summonAction = Action()

function summonAction.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    return onUse(player, item, fromPosition, target, toPosition)
end

summonAction:id(39553)
summonAction:register()
 
I only got this simple one, I can't add "charges" and stuff, but at least the script is working, everything is fine.

Lua:
local monster = "Demon Skeleton"

local function onUse(player, item, fromPosition, target, toPosition)
    local cid = player:getId()
    local playerMana = player:getMana()
    local creatures = getCreatureSummons(cid)
 
    local aliveCount = 0
    for _, creature in ipairs(creatures) do
        if isCreature(creature) then
            aliveCount = aliveCount + 1
        end
    end
 
    if aliveCount >= 2 then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_RED, "You cannot summon more creatures, two are already alive.")
        return false
    end
 
    if playerMana < 600 then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_RED, "Not enough mana.")
        return false
    end
 
    if not player:removeItem(item:getId(), 1) then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_RED, "You don't have the required item.")
        return false
    end
 
    doSummonMonster(cid, monster)
    player:addMana(-600)
 
    return true
end

local summonAction = Action()

function summonAction.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    return onUse(player, item, fromPosition, target, toPosition)
end

summonAction:id(39553)
summonAction:register()

You can add it to the main function, not needed to create a local function again :D
Here a summon script which support multi items and has a simple effect aswell

Lua:
local config = {
    [2298] = { monster = "skeleton", requiredLevel = 0, summonAmount = 1, },
    [46502] = { monster = "demon", requiredLevel = 20, summonAmount = 1, },
}

local summonsystem = Action()

function summonsystem.onUse(player, item, fromPosition, summonrget, toPosition, isHotkey)
   
    local exhaust = 9091
    if player:getStorageValue(exhaust) > os.time() then
        return player:sendTextMessage(MESSAGE_INFO_DESCR, "You can spawn your summon again in "..player:getStorageValue(exhaust) - os.time().." secs")
    end
   
    local summon = config[item.itemid]
    if not summon then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "It seems like this summon stone is not supposed to work, upsssss.")
        return true
    end
   
    if player:getLevel() < summon.requiredLevel then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You must be level "..summon.level.." or higher to use this summon.")
        return true
    end
       
    local tile = player:getTile()
    local ground = tile:hasFlag(TILESTE_PROTECTIONZONE) and tile:getGround()
    if ground then
        player:sendCancelMessage("You cannot spawn your summons in protection zone.")
        return true
    end
       
    local playerSummons = player:getSummons()
    local maxSummons = summon.summonAmount
    if #playerSummons >= maxSummons then
        for i = 1, #playerSummons do
            playerSummons[i]:getPosition():sendMagicEffect(CONST_ME_POFF)
            playerSummons[i]:getPosition():sendDistanceEffect(player:getPosition(), 5)
            Game.sendAnimatedText('REMOVED', playerSummons[i]:getPosition(), TEXTCOLOR_RED)
            playerSummons[i]:remove()
            player:setStorageValue(exhaust, os.time() + 10)
        end
    else
    local monster = Game.createMonster(summon.monster, player:getPosition())
    player:getPosition():sendDistanceEffect(monster:getPosition(), 5)
    player:addSummon(monster)
    Game.sendAnimatedText('SPAWNED', monster:getPosition(), TEXTCOLOR_RED)
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    player:setStorageValue(exhaust, os.time() + 10)
    end
    return true
end

for v in pairs(config) do
    summonsystem:id(v)
end
summonsystem:register()

1693373675238.png1693373684527.png1693373690962.png

Let me know when something is missing
 
Last edited:
I only got this simple one, I can't add "charges" and stuff, but at least the script is working, everything is fine.

Lua:
local monster = "Demon Skeleton"

local function onUse(player, item, fromPosition, target, toPosition)
    local cid = player:getId()
    local playerMana = player:getMana()
    local creatures = getCreatureSummons(cid)
 
    local aliveCount = 0
    for _, creature in ipairs(creatures) do
        if isCreature(creature) then
            aliveCount = aliveCount + 1
        end
    end
 
    if aliveCount >= 2 then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_RED, "You cannot summon more creatures, two are already alive.")
        return false
    end
 
    if playerMana < 600 then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_RED, "Not enough mana.")
        return false
    end
 
    if not player:removeItem(item:getId(), 1) then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_RED, "You don't have the required item.")
        return false
    end
 
    doSummonMonster(cid, monster)
    player:addMana(-600)
 
    return true
end

local summonAction = Action()

function summonAction.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    return onUse(player, item, fromPosition, target, toPosition)
end

summonAction:id(39553)
summonAction:register()

You can add it to the main function, not needed to create a local function again :D
Here a summon script which support multi items and has a simple effect aswell

Lua:
local config = {
    [2298] = { monster = "skeleton", requiredLevel = 0, summonAmount = 1, },
    [46502] = { monster = "demon", requiredLevel = 20, summonAmount = 1, },
}

local summonsystem = Action()

function summonsystem.onUse(player, item, fromPosition, summonrget, toPosition, isHotkey)
  
    local exhaust = 9091
    if player:getStorageValue(exhaust) > os.time() then
        return player:sendTextMessage(MESSAGE_INFO_DESCR, "You can spawn your summon again in "..player:getStorageValue(exhaust) - os.time().." secs")
    end
  
    local summon = config[item.itemid]
    if not summon then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "It seems like this summon stone is not supposed to work, upsssss.")
        return true
    end
  
    if player:getLevel() < summon.requiredLevel then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You must be level "..summon.level.." or higher to use this summon.")
        return true
    end
      
    local tile = player:getTile()
    local ground = tile:hasFlag(TILESsummonTE_PROTECTIONZONE) and tile:getGround()
    if ground then
        player:sendCancelMessage("You cannot spawn your summons in protection zone.")
        return true
    end
      
    local playerSummons = player:getSummons()
    local maxSummons = summon.summonAmount
    if #playerSummons >= maxSummons then
        for i = 1, #playerSummons do
            playerSummons[i]:getPosition():sendMagicEffect(CONST_ME_POFF)
            playerSummons[i]:getPosition():sendDistanceEffect(player:getPosition(), 5)
            Game.sendAnimatedText('REMOVED', playerSummons[i]:getPosition(), TEXTCOLOR_RED)
            playerSummons[i]:remove()
            player:setStorageValue(exhaust, os.time() + 10)
        end
    else
    local monster = Game.createMonster(summon.monster, player:getPosition())
    player:getPosition():sendDistanceEffect(monster:getPosition(), 5)
    player:addSummon(monster)
    Game.sendAnimatedText('SPAWNED', monster:getPosition(), TEXTCOLOR_RED)
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    player:setStorageValue(exhaust, os.time() + 10)
    end
    return true
end

for v in pairs(config) do
    summonsystem:id(v)
end
summonsystem:register()

View attachment 78005View attachment 78006View attachment 78007

Let me know when something is missing
what about charges bro ? does it possible to make vissible on item ? Thanks alot tho
 
You can add it to the main function, not needed to create a local function again :D
Here a summon script which support multi items and has a simple effect aswell

Lua:
local config = {
    [2298] = { monster = "skeleton", requiredLevel = 0, summonAmount = 1, },
    [46502] = { monster = "demon", requiredLevel = 20, summonAmount = 1, },
}

local summonsystem = Action()

function summonsystem.onUse(player, item, fromPosition, summonrget, toPosition, isHotkey)
  
    local exhaust = 9091
    if player:getStorageValue(exhaust) > os.time() then
        return player:sendTextMessage(MESSAGE_INFO_DESCR, "You can spawn your summon again in "..player:getStorageValue(exhaust) - os.time().." secs")
    end
  
    local summon = config[item.itemid]
    if not summon then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "It seems like this summon stone is not supposed to work, upsssss.")
        return true
    end
  
    if player:getLevel() < summon.requiredLevel then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You must be level "..summon.level.." or higher to use this summon.")
        return true
    end
      
    local tile = player:getTile()
    local ground = tile:hasFlag(TILESTE_PROTECTIONZONE) and tile:getGround()
    if ground then
        player:sendCancelMessage("You cannot spawn your summons in protection zone.")
        return true
    end
      
    local playerSummons = player:getSummons()
    local maxSummons = summon.summonAmount
    if #playerSummons >= maxSummons then
        for i = 1, #playerSummons do
            playerSummons[i]:getPosition():sendMagicEffect(CONST_ME_POFF)
            playerSummons[i]:getPosition():sendDistanceEffect(player:getPosition(), 5)
            Game.sendAnimatedText('REMOVED', playerSummons[i]:getPosition(), TEXTCOLOR_RED)
            playerSummons[i]:remove()
            player:setStorageValue(exhaust, os.time() + 10)
        end
    else
    local monster = Game.createMonster(summon.monster, player:getPosition())
    player:getPosition():sendDistanceEffect(monster:getPosition(), 5)
    player:addSummon(monster)
    Game.sendAnimatedText('SPAWNED', monster:getPosition(), TEXTCOLOR_RED)
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    player:setStorageValue(exhaust, os.time() + 10)
    end
    return true
end

for v in pairs(config) do
    summonsystem:id(v)
end
summonsystem:register()

View attachment 78005View attachment 78006View attachment 78007

Let me know when something is missing

I like this script. Look, I'm just learning how to revscript yet, lol.
 
I've already converted the spells and actions to my server's revscript... I'm really loving revscript, haha.

I have questions about adding spells (revscripts) to monsters... I couldn't implement them. So are spells just for players? Where am I wrong?

Its working for Monster aswell
Post automatically merged:

So my solution about the charges would be to create a custom attribute for it

item:setCustomAttribute("ChargesSummon", 20)
as example once u received the "item"
and then in the pet system you could just remove it by -1 always as it used to be on the first script
item:setCustomAttribute("ChargesSummon", item:getCustomAttribute("ChargesSummon") -1)
Im not sure if it works like this but u can try
 
Last edited:
Back
Top