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

[Solved] Check if creature is a summon.

Hermes

dziwki kola gramy w lola
Joined
Nov 17, 2007
Messages
1,867
Reaction score
14
Location
Poland
Hi,

so far I haven't seen function like requested, to check if creature is summoned by something/someone.

Well, let's say I want to make event for killed summons and this function is necessary.

Thanks in advance,
Hermes
 
Last edited:
Lua:
if getCreatureMaster(cid) ~= nil then
	//Creature is Summon
else
	//Creature is not a summon
end
wrong
Code:
	Creature* master = creature->getMaster();
	lua_pushnumber(L, master ? env->addThing(master) : cid);
(returns the creature's master or itself if the creature isn't a summon)
 
Code:
   function isSummon(cid)
        return (isMonster(cid)) and (getCreatureMaster(cid)~=cid)
end
not sure if works in 0.3.6(not tested it yet) but in older releases it was good one
 
Haha, thank you :D. Well, I never thought about making this function in that way :p
(I'll rep you when I will be able to, I have to spread before giving it to you again)
 
Ok, I can use this function to check if it is a summon, but what if I want to check if it is a summon and if how to make the players can not attack the summons, and the only other attack Summons Summons?
I think it's a good event for Monsters VS Monsters.
 
hmm
I dont know onAttack parameters, but it will be like:
isSummon(target) and isPlayer(cid) return false
and so on, but it will still allow you to kill summons with aoe
you can try playing with sources(option no damage to same lookfeet)
 
Ok, I can use this function to check if it is a summon, but what if I want to check if it is a summon and if how to make the players can not attack the summons, and the only other attack Summons Summons?
I think it's a good event for Monsters VS Monsters.

Lua:
function onAttack(cid, target)

	if isPlayer(cid) and isSummon(target) then
		doPlayerSendCancel(cid, "You cannot attack summons.")
		return false
	end
	return true
end
 
Last edited:
Back
Top