• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Solved Talkaction max summons TFS 1.2

knighters god

Active Member
Joined
Feb 14, 2009
Messages
166
Solutions
1
Reaction score
40
Server version: TFS 1.2.

I'm in need of some help with my talkaction script.

In short. This script is a talkaction which needs a storage. And I have tried to make it have max summons.
This is what I've tried.
Code:
if getCreatureSummons(cid) >= 1 then
     -- Do stuff
end
-- I've tried
if #getCreatureSummons(cid) >= 1 then
     -- Do stuff
end
I have searched around on OTland with no luck.

If you want the full script just ask.

Help would be appreciated!
 
If creature get summons is less or equal to 1 then do things.
Code:
if #getCreatureSummons(cid) <= 1 then
     -- do things
end
I forgot to add the error message I recived.
And this gave the same.
8wIgROF.jpg
 
Here is a fast sketch:

Code:
local config = {
    monsterName = "Fire Devil",
    vocations = {3, 7},
    maxSummons = 2
}

function onSay(player, words, param)
    if not isInArray(config.vocations, player:getVocation():getId()) then
        return false
    end

    if #player:getSummons() >= config.maxSummons then
        return false
    end

    local monster = Game.createMonster(config.monsterName, player:getPosition())
    if monster then
        monster:setMaster(player)
        monster:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    end

    return true
end
 
Last edited:
Code:
   local summoncount = creature:getSummons()
   if #summoncount <= 1 then
     -- do things
   end
Didn't notice it's TFS 1.2, try this one.
 
Here is a fast sketch:

Code:
local config = {
    monsterName = "Fire Devil",
    vocations = {3, 7},
    maxSummons = 2
}

function onSay(player, words, param)
    if not isInArray(config.vocations, player:getVocation():getId()) then
        return false
    end

-- Here comes the error
    if player:getSummons() >= config.maxSummons then
        return false
    end
-- The one above me

    local monster = Game.createMonster(config.monsterName, player:getPosition())
    if monster then
        monster:setMaster(player)
        monster:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    end

    return true
end

error ;/
"Attempt to compare number with table"

I'll give you my code just incase it will be in the favor of fixing this quickly.

Code:
local _config = {
    _monsterName = "Holy Monk",
    _maxSummons = 1
}

function onSay(player, words, param)

    local _paladin = 17300
    local _currentMana = player:getMana()
    local _mana = 650;

    if player:getStorageValue(_paladin) ~= 3 then
        player:sendCancelMessage("You can not use this.")
        return false
    end

    if player:getLevel() < 60 then
        player:sendCancelMessage("You must be level 60 to use this.")
        return false
    end
  
    if player:getSummons() >= _config._maxSummons then
        player:sendCancelMessage("The gods only let you have one!")
        return false
    end
  
    if _currentMana < 650 then
        player:sendCancelMessage("Not enough mana.")
        return false
    end
  
    player:addMana(-_mana)
    local orig = player:getPosition()
    local _summon = Game.CreateMonster(_config._monsterName, player:getPosition())
    if _summon then
        local monster = Monster(creatureId)
        monster:setMaster(player)
        orig:sendMagicEffect(CONST_ME_MAGIC_RED)
    else
        player:sendCancelMessage("There is not enough room.")
        orig:sendMagicEffect(CONST_ME_POFF)
    end
    return true
end

Code:
   local summoncount = creature:getSummons()
   if #summoncount <= 1 then
     -- do things
   end
Didn't notice it's TFS 1.2, try this one.

And this one gives me "attempt to index global 'creature' (a nil value)
 
Last edited by a moderator:
Code:
local summoncount = getCreatureSummons(player)
count = 0
for i = 1, #summoncount do
count = count + 1
end

if count <= 1 then
-- do things
end
 
Try this one.
Code:
local _config = {
    _monsterName = "Holy Monk",
    _maxSummons = 1
}

function onSay(player, words, param)

    local _paladin = 17300
    local _currentMana = player:getMana()
    local _mana = 650;

    if player:getStorageValue(_paladin) ~= 3 then
        player:sendCancelMessage("You can not use this.")
        return false
    end

    if player:getLevel() < 60 then
        player:sendCancelMessage("You must be level 60 to use this.")
        return false
    end
 
    if #player:getSummons() >= _config._maxSummons then
        player:sendCancelMessage("The gods only let you have one!")
        return false
    end
 
    if _currentMana < 650 then
        player:sendCancelMessage("Not enough mana.")
        return false
    end
 
    player:addMana(-_mana)
    local orig = player:getPosition()
    local _summon = Game.createMonster(_config._monsterName, player:getPosition())
    if _summon then
        _summon:setMaster(player)
        orig:sendMagicEffect(CONST_ME_MAGIC_RED)
    else
        player:sendCancelMessage("There is not enough room.")
        orig:sendMagicEffect(CONST_ME_POFF)
    end
    return true
end
 
Try this one.
Code:
local _config = {
    _monsterName = "Holy Monk",
    _maxSummons = 1
}

function onSay(player, words, param)

    local _paladin = 17300
    local _currentMana = player:getMana()
    local _mana = 650;

    if player:getStorageValue(_paladin) ~= 3 then
        player:sendCancelMessage("You can not use this.")
        return false
    end

    if player:getLevel() < 60 then
        player:sendCancelMessage("You must be level 60 to use this.")
        return false
    end

    if #player:getSummons() >= _config._maxSummons then
        player:sendCancelMessage("The gods only let you have one!")
        return false
    end

    if _currentMana < 650 then
        player:sendCancelMessage("Not enough mana.")
        return false
    end

    player:addMana(-_mana)
    local orig = player:getPosition()
    local _summon = Game.createMonster(_config._monsterName, player:getPosition())
    if _summon then
        _summon:setMaster(player)
        orig:sendMagicEffect(CONST_ME_MAGIC_RED)
    else
        player:sendCancelMessage("There is not enough room.")
        orig:sendMagicEffect(CONST_ME_POFF)
    end
    return true
end

Even when the last person fixed it I tried this one.
This also works like a charm. No errors.

Thank you!
Rep++
 
Back
Top