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

TFS 0.X 3 bugs summon rune

kennyubuntu

Member
Joined
May 20, 2016
Messages
150
Reaction score
13
i tried to make a rune to summon a monk
but i got 3 errors:
1- not convicing creature (the monk is attacking the summoner)
2- not removing the rune
3- not removing mana

Code:
local mana = 500

function onCastSpell(cid, var)
    local maxSummons = getConfigValue('maxPlayerSummons')
    if #getCreatureSummons(cid) >= maxSummons then
        return (doPlayerSendCancel(cid, "You cannot summon more creatures.") and doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)) and true
    end
    if (getPlayerMana(cid) < mana) then
        return (doPlayerSendCancel(cid, "You need " .. mana .. " mana points to use this rune.") and doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)) and true
    end
    local createMonster = doCreateMonster("Monk", getThingPos(cid))
    if createMonster then
        doPlayerAddMana(cid, (mana * 1))
        doCreatureSetSkullType(createMonster, SKULL_YELLOW)
        setCreatureMaxHealth(createMonster, (getCreatureHealth(createMonster) * 2))
        doCreatureAddHealth(createMonster, getCreatureHealth(createMonster) * 2)
        doConvinceCreature(cid, createMonster)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_BLUE)
        return true
    end
    doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    return false
end
 
Solution
1-
(x) removing mana / checking mana
(x) not summon more then 3
() removing the item

log
Code:
[22:30:20.839] [Error - Spell Interface]
[22:30:20.839] data/spells/scripts/summon/monk rune.lua:onCastSpell
[22:30:20.839] Description:
[22:30:20.839] data/spells/scripts/summon/monk rune.lua:30: attempt to index field '?' (a number value)
[22:30:20.839] stack traceback:
[22:30:20.839]     data/spells/scripts/summon/monk rune.lua:30: in function <data/spells/scripts/summon/monk rune.lua:3>


2-
(x) removing mana / checking mana
(x) not summon more then 3
(x) removing the item
(x) adding yellow skull

no errors on console

but there is a last problem:
none of this messages:
doPlayerSendCancel(cid, "You cannot summon more creatures.")...
doSummonMonster(cid, name) instead of doCreateMonster

use a negative number instead of a positive number to remove mana.

I've never used a rune inside of spells.. so idk how the rune is removed.
It might be inside of spells.xml?
 
doSummonMonster(cid, name) instead of doCreateMonster

use a negative number instead of a positive number to remove mana.

I've never used a rune inside of spells.. so idk how the rune is removed.
It might be inside of spells.xml?

I've tried:
Code:
function onCastSpell(cid, var)
    local maxSummons = getConfigValue('maxPlayerSummons')
    if #getCreatureSummons(cid) >= maxSummons then
        doPlayerSendCancel(cid, "You cannot summon more creatures.")
        doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
        return true
    end
    local mana = 500
    if getPlayerMana(cid) < mana then
        doPlayerSendCancel(cid, "You need " .. mana .. " mana points to use this rune.")
        doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
        return true
    end
    local createMonster = doSummonMonster(cid, "monk")
    if createMonster then
        doPlayerAddMana(cid, (mana * -1))
        doCreatureSetSkullType(createMonster, SKULL_YELLOW)
        setCreatureMaxHealth(createMonster, (getCreatureHealth(createMonster) * 2))
        doCreatureAddHealth(createMonster, getCreatureHealth(createMonster) * 2)
        doConvinceCreature(cid, createMonster)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_BLUE)
        doPlayerRemoveItem(cid, 2348, 1)
        return true
    end
    return false
end

it fix the mana problem...

its making the monk, but without SKULL_YELLOW, without * 2 health
not removing the rune too :(

on spells.xml
Code:
<rune name="Monk Rune" id="2348" allowfaruse="1" charges="1" maglv="4" exhaustion="2000" blocktype="solid" event="script" value="summon/monk rune.lua">
        <vocation id="3"/>
        <vocation id="11"/>
        <vocation id="12"/>
        <vocation id="13"/>
        <vocation id="14"/>
        <vocation id="15"/>
        <vocation id="16"/>
        <vocation id="17"/>
    </rune>
 
I've tried:
Code:
function onCastSpell(cid, var)
    local maxSummons = getConfigValue('maxPlayerSummons')
    if #getCreatureSummons(cid) >= maxSummons then
        doPlayerSendCancel(cid, "You cannot summon more creatures.")
        doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
        return true
    end
    local mana = 500
    if getPlayerMana(cid) < mana then
        doPlayerSendCancel(cid, "You need " .. mana .. " mana points to use this rune.")
        doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
        return true
    end
    local createMonster = doSummonMonster(cid, "monk")
    if createMonster then
        doPlayerAddMana(cid, (mana * -1))
        doCreatureSetSkullType(createMonster, SKULL_YELLOW)
        setCreatureMaxHealth(createMonster, (getCreatureHealth(createMonster) * 2))
        doCreatureAddHealth(createMonster, getCreatureHealth(createMonster) * 2)
        doConvinceCreature(cid, createMonster)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_BLUE)
        doPlayerRemoveItem(cid, 2348, 1)
        return true
    end
    return false
end

it fix the mana problem...

its making the monk, but without SKULL_YELLOW, without * 2 health
not removing the rune too :(

on spells.xml
Code:
<rune name="Monk Rune" id="2348" allowfaruse="1" charges="1" maglv="4" exhaustion="2000" blocktype="solid" event="script" value="summon/monk rune.lua">
        <vocation id="3"/>
        <vocation id="11"/>
        <vocation id="12"/>
        <vocation id="13"/>
        <vocation id="14"/>
        <vocation id="15"/>
        <vocation id="16"/>
        <vocation id="17"/>
    </rune>
Still not sure about removing the rune.. xD
and everything else looks right..
Without being thereto actually test some stuff myself.. The only thing I can think of is to use createMonster.uid ?
Doesn't make sense why you'd need to do that though.
 
Still not sure about removing the rune.. xD
and everything else looks right..
Without being thereto actually test some stuff myself.. The only thing I can think of is to use createMonster.uid ?
Doesn't make sense why you'd need to do that though.

:(

createMonster.uid where?
in the if?
or in every createMonster after local createMonster?
 
Try this, show us what the console says.
Lua:
function onCastSpell(cid, var)
    local maxSummons = getConfigValue('maxPlayerSummons')
    print(1 .. ", " .. getCreatureSummons(cid) .. ", " .. maxSummons)
    if #getCreatureSummons(cid) >= maxSummons then
        print(2 .. ", You cannot summon more creatures.")
        doPlayerSendCancel(cid, "You cannot summon more creatures.")
        doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
        return false
    end
    local mana = 500
    print(3 .. ", " .. getPlayerMana(cid) .. ", " .. mana)
    if getPlayerMana(cid) < mana then
        print(4 .. ", You need " .. mana .. " mana points to use this rune.")
        doPlayerSendCancel(cid, "You need " .. mana .. " mana points to use this rune.")
        doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
        return false
    end
    print(5)
    local createMonster = doSummonMonster(cid, "monk")
    --if createMonster then
        doPlayerAddMana(cid, (mana * -1))
        print(6)
        doCreatureSetSkullType(createMonster, SKULL_YELLOW)
        print(7)
        setCreatureMaxHealth(createMonster, (getCreatureHealth(createMonster) * 2))
        print(8)
        doCreatureAddHealth(createMonster, getCreatureHealth(createMonster) * 2)
        print(9)
        doConvinceCreature(cid, createMonster)
        print(10)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_BLUE)
        print(11)
        doPlayerRemoveItem(cid, 2348, 1)
        print(12 .. ", Successfully summoned monster.")
        return true
    --end
    --return false
end
 
Try this, show us what the console says.
Lua:
function onCastSpell(cid, var)
    local maxSummons = getConfigValue('maxPlayerSummons')
    print(1 .. ", " .. getCreatureSummons(cid) .. ", " .. maxSummons)
    if #getCreatureSummons(cid) >= maxSummons then
        print(2 .. ", You cannot summon more creatures.")
        doPlayerSendCancel(cid, "You cannot summon more creatures.")
        doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
        return false
    end
    local mana = 500
    print(3 .. ", " .. getPlayerMana(cid) .. ", " .. mana)
    if getPlayerMana(cid) < mana then
        print(4 .. ", You need " .. mana .. " mana points to use this rune.")
        doPlayerSendCancel(cid, "You need " .. mana .. " mana points to use this rune.")
        doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
        return false
    end
    print(5)
    local createMonster = doSummonMonster(cid, "monk")
    --if createMonster then
        doPlayerAddMana(cid, (mana * -1))
        print(6)
        doCreatureSetSkullType(createMonster, SKULL_YELLOW)
        print(7)
        setCreatureMaxHealth(createMonster, (getCreatureHealth(createMonster) * 2))
        print(8)
        doCreatureAddHealth(createMonster, getCreatureHealth(createMonster) * 2)
        print(9)
        doConvinceCreature(cid, createMonster)
        print(10)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_BLUE)
        print(11)
        doPlayerRemoveItem(cid, 2348, 1)
        print(12 .. ", Successfully summoned monster.")
        return true
    --end
    --return false
end


Code:
[6:37:52.652] [Error - Spell Interface] 
[6:37:52.652] data/spells/scripts/summon/monk rune.lua:onCastSpell
[6:37:52.652] Description: 
[6:37:52.653] data/spells/scripts/summon/monk rune.lua:3: attempt to concatenate a table value
[6:37:52.653] stack traceback:
[6:37:52.653]     data/spells/scripts/summon/monk rune.lua:3: in function <data/spells/scripts/summon/monk rune.lua:1>
 
Code:
[6:37:52.652] [Error - Spell Interface]
[6:37:52.652] data/spells/scripts/summon/monk rune.lua:onCastSpell
[6:37:52.652] Description:
[6:37:52.653] data/spells/scripts/summon/monk rune.lua:3: attempt to concatenate a table value
[6:37:52.653] stack traceback:
[6:37:52.653]     data/spells/scripts/summon/monk rune.lua:3: in function <data/spells/scripts/summon/monk rune.lua:1>
Ah that's fine.
Green text line 3 and go again
 
no mana
Code:
3, 198, 500
4, You need 500 mana points to use this rune.

with mana
Code:
3, 710, 500
5
6

[19:15:13.064] [Error - Spell Interface] 
[19:15:13.064] data/spells/scripts/summon/monk rune.lua:onCastSpell
[19:15:13.064] Description: 
[19:15:13.064] (luaDoCreatureSetSkullType) Creature not found
7

[19:15:13.065] [Error - Spell Interface] 
[19:15:13.065] data/spells/scripts/summon/monk rune.lua:onCastSpell
[19:15:13.065] Description: 
[19:15:13.065] (luaGetCreatureHealth) Creature not found

[19:15:13.065] [Error - Spell Interface] 
[19:15:13.066] data/spells/scripts/summon/monk rune.lua:onCastSpell
[19:15:13.066] Description: 
[19:15:13.066] data/spells/scripts/summon/monk rune.lua:25: attempt to perform arithmetic on a boolean value
[19:15:13.066] stack traceback:
[19:15:13.066]     data/spells/scripts/summon/monk rune.lua:25: in function <data/spells/scripts/summon/monk rune.lua:1>
 
no mana
Code:
3, 198, 500
4, You need 500 mana points to use this rune.

with mana
Code:
3, 710, 500
5
6

[19:15:13.064] [Error - Spell Interface]
[19:15:13.064] data/spells/scripts/summon/monk rune.lua:onCastSpell
[19:15:13.064] Description:
[19:15:13.064] (luaDoCreatureSetSkullType) Creature not found
7

[19:15:13.065] [Error - Spell Interface]
[19:15:13.065] data/spells/scripts/summon/monk rune.lua:onCastSpell
[19:15:13.065] Description:
[19:15:13.065] (luaGetCreatureHealth) Creature not found

[19:15:13.065] [Error - Spell Interface]
[19:15:13.066] data/spells/scripts/summon/monk rune.lua:onCastSpell
[19:15:13.066] Description:
[19:15:13.066] data/spells/scripts/summon/monk rune.lua:25: attempt to perform arithmetic on a boolean value
[19:15:13.066] stack traceback:
[19:15:13.066]     data/spells/scripts/summon/monk rune.lua:25: in function <data/spells/scripts/summon/monk rune.lua:1>
Lua:
function onCastSpell(cid, var)
    local maxSummons = getConfigValue('maxPlayerSummons')
    print(1 .. ", " .. #getCreatureSummons(cid) .. ", " .. maxSummons)
    if #getCreatureSummons(cid) >= maxSummons then
        print(2 .. ", You cannot summon more creatures.")
        doPlayerSendCancel(cid, "You cannot summon more creatures.")
        doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
        return false
    end
    local mana = 500
    print(3 .. ", " .. getPlayerMana(cid) .. ", " .. mana)
    if getPlayerMana(cid) < mana then
        print(4 .. ", You need " .. mana .. " mana points to use this rune.")
        doPlayerSendCancel(cid, "You need " .. mana .. " mana points to use this rune.")
        doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
        return false
    end
    print(5)
    local createMonster = doSummonMonster(cid, "monk")
    if not isCreature(createMonster.uid) then
        print(13 .. ", NOT successfully summoned monster.")
        return false
    end
    
    doPlayerAddMana(cid, (mana * -1))
    print(6)
    doCreatureSetSkullType(createMonster.uid, SKULL_YELLOW)
    print(7)
    setCreatureMaxHealth(createMonster.uid, (getCreatureHealth(createMonster.uid) * 2))
    print(8)
    doCreatureAddHealth(createMonster.uid, getCreatureHealth(createMonster.uid) * 2)
    print(9)
    doConvinceCreature(cid, createMonster.uid)
    print(10)
    doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_BLUE)
    print(11)
    doPlayerRemoveItem(cid, 2348, 1)
    print(12 .. ", Successfully summoned monster.")
    return true
end
 
Lua:
function onCastSpell(cid, var)
    local maxSummons = getConfigValue('maxPlayerSummons')
    print(1 .. ", " .. #getCreatureSummons(cid) .. ", " .. maxSummons)
    if #getCreatureSummons(cid) >= maxSummons then
        print(2 .. ", You cannot summon more creatures.")
        doPlayerSendCancel(cid, "You cannot summon more creatures.")
        doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
        return false
    end
    local mana = 500
    print(3 .. ", " .. getPlayerMana(cid) .. ", " .. mana)
    if getPlayerMana(cid) < mana then
        print(4 .. ", You need " .. mana .. " mana points to use this rune.")
        doPlayerSendCancel(cid, "You need " .. mana .. " mana points to use this rune.")
        doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
        return false
    end
    print(5)
    local createMonster = doSummonMonster(cid, "monk")
    if not isCreature(createMonster.uid) then
        print(13 .. ", NOT successfully summoned monster.")
        return false
    end
   
    doPlayerAddMana(cid, (mana * -1))
    print(6)
    doCreatureSetSkullType(createMonster.uid, SKULL_YELLOW)
    print(7)
    setCreatureMaxHealth(createMonster.uid, (getCreatureHealth(createMonster.uid) * 2))
    print(8)
    doCreatureAddHealth(createMonster.uid, getCreatureHealth(createMonster.uid) * 2)
    print(9)
    doConvinceCreature(cid, createMonster.uid)
    print(10)
    doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_BLUE)
    print(11)
    doPlayerRemoveItem(cid, 2348, 1)
    print(12 .. ", Successfully summoned monster.")
    return true
end

with mana:
Code:
1, 1, 3
3, 620, 500
5

[20:15:09.301] [Error - Spell Interface] 
[20:15:09.301] data/spells/scripts/summon/monk rune.lua:onCastSpell
[20:15:09.301] Description: 
[20:15:09.301] data/spells/scripts/summon/monk rune.lua:20: attempt to index local 'createMonster' (a number value)
[20:15:09.301] stack traceback:
[20:15:09.301]     data/spells/scripts/summon/monk rune.lua:20: in function <data/spells/scripts/summon/monk rune.lua:1>

its not removing the mana...
 
with mana:
Code:
1, 1, 3
3, 620, 500
5

[20:15:09.301] [Error - Spell Interface]
[20:15:09.301] data/spells/scripts/summon/monk rune.lua:onCastSpell
[20:15:09.301] Description:
[20:15:09.301] data/spells/scripts/summon/monk rune.lua:20: attempt to index local 'createMonster' (a number value)
[20:15:09.301] stack traceback:
[20:15:09.301]     data/spells/scripts/summon/monk rune.lua:20: in function <data/spells/scripts/summon/monk rune.lua:1>

its not removing the mana...
Okay well, I have no idea why the hell it won't let us use it normally.. so let's go a completely different approach.

Try this one first
Lua:
local mana = 500

function onCastSpell(cid, var)

    local max_summons = getConfigValue('maxPlayerSummons')
    local player_summons = getCreatureSummons(cid)
    
    if #player_summons >= max_summons then
        doPlayerSendCancel(cid, "You cannot summon more creatures.")
        doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
        return false
    end
    
    if getPlayerMana(cid) < mana then
        doPlayerSendCancel(cid, "You need " .. mana .. " mana points to use this rune.")
        doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
        return false
    end
    
    doSummonMonster(cid, "monk")
    
    local new_player_summons = getCreatureSummons(cid)
    if #player_summons == #new_player_summons then
        doPlayerSendCancel(cid, "Not enough room to summon creature.")
        doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
        return false
    end
        
    doPlayerAddMana(cid, mana * -1)
    doCreatureSetSkullType(new_player_summons[#new_player_summons].uid, SKULL_YELLOW)
    setCreatureMaxHealth(new_player_summons[#new_player_summons].uid, (getCreatureHealth(new_player_summons[#new_player_summons].uid) * 2))
    doCreatureAddHealth(new_player_summons[#new_player_summons].uid, getCreatureHealth(new_player_summons[#new_player_summons].uid) * 2)
    doConvinceCreature(cid, new_player_summons[#new_player_summons].uid)
    doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_BLUE)
    doPlayerRemoveItem(cid, 2348, 1)
    
    return true
end

If for some reason that one doesn't work, try this one.
Lua:
local mana = 500

function onCastSpell(cid, var)

    local max_summons = getConfigValue('maxPlayerSummons')
    local player_summons = getCreatureSummons(cid)
    
    if #player_summons >= max_summons then
        doPlayerSendCancel(cid, "You cannot summon more creatures.")
        doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
        return false
    end
    
    if getPlayerMana(cid) < mana then
        doPlayerSendCancel(cid, "You need " .. mana .. " mana points to use this rune.")
        doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
        return false
    end
    
    doSummonMonster(cid, "monk")
    
    local new_player_summons = getCreatureSummons(cid)
    if #player_summons == #new_player_summons then
        doPlayerSendCancel(cid, "Not enough room to summon creature.")
        doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
        return false
    end
        
    doPlayerAddMana(cid, mana * -1)
    doCreatureSetSkullType(new_player_summons[#new_player_summons], SKULL_YELLOW)
    setCreatureMaxHealth(new_player_summons[#new_player_summons], (getCreatureHealth(new_player_summons[#new_player_summons]) * 2))
    doCreatureAddHealth(new_player_summons[#new_player_summons], getCreatureHealth(new_player_summons[#new_player_summons]) * 2)
    doConvinceCreature(cid, new_player_summons[#new_player_summons])
    doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_BLUE)
    doPlayerRemoveItem(cid, 2348, 1)
    
    return true
end
 
I don't see why this wouldn't work. Post any errors with this.

Lua:
local mana = 500
local summon = "Monk"

function onCastSpell(cid, var)
    local maxSummons = getConfigValue('maxPlayerSummons')
   
    if #getCreatureSummons(cid) == maxSummons then
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
        doPlayerSendCancel(cid, "You cannot summon anymore creatures.")
        return false
    end
   
    if getPlayerMana(cid) < mana then
        doPlayerSendCancel(cid, "You do not have enough mana.")
        return false
    end
   
    local createMonster = doSummonMonster(cid, summon)
   
    if createMonster then
        doPlayerAddMana(cid, -mana)
        doCreatureSetSkullType(createMonster, SKULL_YELLOW)
        setCreatureMaxHealth(createMonster, (getCreatureHealth(createMonster) * 2))
        doCreatureAddHealth(createMonster, getCreatureMaxHealth(createMonster))
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_BLUE)
        return true
    end
   
    doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    return false
end
 
I don't see why this wouldn't work. Post any errors with this.

Lua:
local mana = 500
local summon = "Monk"

function onCastSpell(cid, var)
    local maxSummons = getConfigValue('maxPlayerSummons')
  
    if #getCreatureSummons(cid) == maxSummons then
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
        doPlayerSendCancel(cid, "You cannot summon anymore creatures.")
        return false
    end
  
    if getPlayerMana(cid) < mana then
        doPlayerSendCancel(cid, "You do not have enough mana.")
        return false
    end
  
    local createMonster = doSummonMonster(cid, summon)
  
    if createMonster then
        doPlayerAddMana(cid, -mana)
        doCreatureSetSkullType(createMonster, SKULL_YELLOW)
        setCreatureMaxHealth(createMonster, (getCreatureHealth(createMonster) * 2))
        doCreatureAddHealth(createMonster, getCreatureMaxHealth(createMonster))
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_BLUE)
        return true
    end
  
    doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    return false
end
Yeah that's what I'm saying as well. It doesn't make sense why it wouldn't work like this. :s
 
Okay well, I have no idea why the hell it won't let us use it normally.. so let's go a completely different approach.

Try this one first
Lua:
local mana = 500

function onCastSpell(cid, var)

    local max_summons = getConfigValue('maxPlayerSummons')
    local player_summons = getCreatureSummons(cid)
  
    if #player_summons >= max_summons then
        doPlayerSendCancel(cid, "You cannot summon more creatures.")
        doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
        return false
    end
  
    if getPlayerMana(cid) < mana then
        doPlayerSendCancel(cid, "You need " .. mana .. " mana points to use this rune.")
        doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
        return false
    end
  
    doSummonMonster(cid, "monk")
  
    local new_player_summons = getCreatureSummons(cid)
    if #player_summons == #new_player_summons then
        doPlayerSendCancel(cid, "Not enough room to summon creature.")
        doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
        return false
    end
      
    doPlayerAddMana(cid, mana * -1)
    doCreatureSetSkullType(new_player_summons[#new_player_summons].uid, SKULL_YELLOW)
    setCreatureMaxHealth(new_player_summons[#new_player_summons].uid, (getCreatureHealth(new_player_summons[#new_player_summons].uid) * 2))
    doCreatureAddHealth(new_player_summons[#new_player_summons].uid, getCreatureHealth(new_player_summons[#new_player_summons].uid) * 2)
    doConvinceCreature(cid, new_player_summons[#new_player_summons].uid)
    doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_BLUE)
    doPlayerRemoveItem(cid, 2348, 1)
  
    return true
end

If for some reason that one doesn't work, try this one.
Lua:
local mana = 500

function onCastSpell(cid, var)

    local max_summons = getConfigValue('maxPlayerSummons')
    local player_summons = getCreatureSummons(cid)
  
    if #player_summons >= max_summons then
        doPlayerSendCancel(cid, "You cannot summon more creatures.")
        doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
        return false
    end
  
    if getPlayerMana(cid) < mana then
        doPlayerSendCancel(cid, "You need " .. mana .. " mana points to use this rune.")
        doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
        return false
    end
  
    doSummonMonster(cid, "monk")
  
    local new_player_summons = getCreatureSummons(cid)
    if #player_summons == #new_player_summons then
        doPlayerSendCancel(cid, "Not enough room to summon creature.")
        doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
        return false
    end
      
    doPlayerAddMana(cid, mana * -1)
    doCreatureSetSkullType(new_player_summons[#new_player_summons], SKULL_YELLOW)
    setCreatureMaxHealth(new_player_summons[#new_player_summons], (getCreatureHealth(new_player_summons[#new_player_summons]) * 2))
    doCreatureAddHealth(new_player_summons[#new_player_summons], getCreatureHealth(new_player_summons[#new_player_summons]) * 2)
    doConvinceCreature(cid, new_player_summons[#new_player_summons])
    doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_BLUE)
    doPlayerRemoveItem(cid, 2348, 1)
  
    return true
end

1-
(x) removing mana / checking mana
(x) not summon more then 3
() removing the item

log
Code:
[22:30:20.839] [Error - Spell Interface]
[22:30:20.839] data/spells/scripts/summon/monk rune.lua:onCastSpell
[22:30:20.839] Description:
[22:30:20.839] data/spells/scripts/summon/monk rune.lua:30: attempt to index field '?' (a number value)
[22:30:20.839] stack traceback:
[22:30:20.839]     data/spells/scripts/summon/monk rune.lua:30: in function <data/spells/scripts/summon/monk rune.lua:3>


2-
(x) removing mana / checking mana
(x) not summon more then 3
(x) removing the item
(x) adding yellow skull

no errors on console

but there is a last problem:
none of this messages:
doPlayerSendCancel(cid, "You cannot summon more creatures.")
doPlayerSendCancel(cid, "You need " .. mana .. " mana points to use this rune.")
doPlayerSendCancel(cid, "Not enough room to summon creature.")
are showing...
why?
Post automatically merged:

I don't see why this wouldn't work. Post any errors with this.

Lua:
local mana = 500
local summon = "Monk"

function onCastSpell(cid, var)
    local maxSummons = getConfigValue('maxPlayerSummons')
 
    if #getCreatureSummons(cid) == maxSummons then
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
        doPlayerSendCancel(cid, "You cannot summon anymore creatures.")
        return false
    end
 
    if getPlayerMana(cid) < mana then
        doPlayerSendCancel(cid, "You do not have enough mana.")
        return false
    end
 
    local createMonster = doSummonMonster(cid, summon)
 
    if createMonster then
        doPlayerAddMana(cid, -mana)
        doCreatureSetSkullType(createMonster, SKULL_YELLOW)
        setCreatureMaxHealth(createMonster, (getCreatureHealth(createMonster) * 2))
        doCreatureAddHealth(createMonster, getCreatureMaxHealth(createMonster))
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_BLUE)
        return true
    end
 
    doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    return false
end



3-
(x) removing mana / checking mana
(x) not summon more then 3
() removing the item
() adding yellow skull

but this is different to 2, is not showing lose man

and is showing this errors on console
Code:
[22:37:45.494] [Error - Spell Interface]
[22:37:45.494] data/spells/scripts/summon/monk rune.lua:onCastSpell
[22:37:45.494] Description:
[22:37:45.494] (luaGetCreatureHealth) Creature not found

[22:37:45.494] [Error - Spell Interface]
[22:37:45.494] data/spells/scripts/summon/monk rune.lua:onCastSpell
[22:37:45.494] Description:
[22:37:45.494] data/spells/scripts/summon/monk rune.lua:23: attempt to perform arithmetic on a boolean value
[22:37:45.494] stack traceback:
[22:37:45.494]     data/spells/scripts/summon/monk rune.lua:23: in function <data/spells/scripts/summon/monk rune.lua:4>
 
Last edited:
Back
Top