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

Lua Check summon names

Xagul

deathzot.net
Joined
Jun 30, 2008
Messages
1,294
Solutions
3
Reaction score
1,037
Hello, I have been trying to make a summoning spell with limits to how many monsters you can summon. I have the number limit working but I would like it to check for a specific monster name for example:

utevo res rat: summons a rat
utevo res rat: you can not have more than 1 rat at a time.
utevo res cave rat: summons cave rat
utevo res cave rat: you can not have more than 1 cave rat at a time.

So the player ends up with 1 rat and 1 cave rat.

The script I am currently using is:
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, TRUE)

function onCastSpell(cid, var)
	if(table.maxn(getCreatureSummons(cid)) >= 1) then
		doPlayerSendCancel(cid, "You can't summon more than 1 rat at a time.")
	else
		creature = doCreateMonster("rat", getCreaturePosition(cid))
		doConvinceCreature(cid, creature)
		return doCombat(cid, combat, var)
    end
end

As you can see its almost working, I just need it to check the names of summons instead of every summon the player has.
 
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, TRUE)

function onCastSpell(cid, var)
	local summon = true
	if(#getCreatureSummons(cid) >= 1) then
			for _,pid in ipairs(getCreatureSummons(cid)) do
				if string.lower(getCreatureName(pid)) == string.lower("rAt") then
					summon = false
				end
			end
    end
	if summon == true then 
		creature = doCreateMonster("rat", getCreaturePosition(cid))
		doConvinceCreature(cid, creature)
		doCombat(cid, combat, var)
	else
		doPlayerSendCancel(cid,"You already have a summoned rat.")
		return doSendMagicEffect(getThingPos(cid),2) and false
	end
	return true
end
 
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, TRUE)

function onCastSpell(cid, var)
    local summon = true
    if(#getCreatureSummons(cid) >= 1) then
            for _,pid in ipairs(getCreatureSummons(cid)) do
                if string.lower(getCreatureName(pid)) == string.lower("rAt") then
                    summon = false
                end
            end
    end
    if summon == true then
        creature = doCreateMonster("rat", getCreaturePosition(cid))
        doConvinceCreature(cid, creature)
        doCombat(cid, combat, var)
    else
        doPlayerSendCancel(cid,"You already have a summoned rat.")
        return doSendMagicEffect(getThingPos(cid),2) and false
    end
    return true
end
Hi, I'm trying to make a system with different summons. And I need to have the count of each summon different that I have summoned (Exemplo: print->Rat = 2, Bug = 3, ...). I'm not sure how to build this code, can anyone help me based on this one? Please
 
Back
Top