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

Summon Monster.

pasibun

New Member
Joined
Nov 7, 2011
Messages
147
Reaction score
1
Hello there,

I got a request..

I want to create a spell, thats summon a hero.
But this monsters only stays with u for 30sec.
and u can only cast the spell every 5min.

Can some one help me?


I'm usings TFS 0.3.6

Greedings,
Pasibun
 
LUA:
local function f(c) -- By Cykotitan
	if isMonster(c) then
		doRemoveCreature(c)
	end
end

local = summonName = "Hero"
local = summonTime = 30
function onCastSpell(cid, var) -- Spell by Cykotitan / edited by OTx
	local p = getThingPos(cid)
	if getTileInfo(p).protection then
		doCreatureSay(cid, 'You cannot summon in PZ!', TALKTYPE_ORANGE_1, false, cid, p)
		doSendMagicEffect(p, CONST_ME_POFF)
	elseif #getCreatureSummons(cid) ~= 0 then
		doPlayerSendCancel(cid, 'You can\'t summon more than one.')
		doSendMagicEffect(p, CONST_ME_POFF)
	else
		local r = doSummonMonster(cid, summonName)
		if r == 1 then
			doSendMagicEffect(p, CONST_ME_MAGIC_BLUE)
			doPlayerSendCancel(cid, getMonsterInfo(summonName).nameDescription .." is ready to help you.")
			addEvent(f, summonTime*1000, getCreatureSummons(cid)[1])
			return true
		else
			doPlayerSendDefaultCancel(cid, r)
		end
	end
end
 
Alright, First of all.. Thanks for helping..

Code:
local = summonName = "Hero"
local = summonTime = 30

This part diddn't work..
It was:

Code:
local  summonName = "Hero"
local  summonTime = 30

But anyhow, the monster summons.. but after 30sec the monster is not being removed.
Code:
local function f(c) -- By Cykotitan
	if isMonster(c) then
		doRemoveCreature(c)
	end
end

I think something is wrong with this part.

I hope to hear from some one soon!..
 
oh lol, fail xd

but if that local didn't work then the remove summon shouldn't work..
LUA:
local function f(c) -- By Cykotitan
	if isMonster(c) then
		doRemoveCreature(c)
	end
end
 
local summonName = "Hero"
local summonTime = 30
function onCastSpell(cid, var) -- Spell by Cykotitan / edited by OTx
	local p = getThingPos(cid)
	if getTileInfo(p).protection then
		doCreatureSay(cid, 'You cannot summon in PZ!', TALKTYPE_ORANGE_1, false, cid, p)
		doSendMagicEffect(p, CONST_ME_POFF)
	elseif #getCreatureSummons(cid) ~= 0 then
		doPlayerSendCancel(cid, 'You can\'t summon more than one.')
		doSendMagicEffect(p, CONST_ME_POFF)
	else
		local r = doSummonMonster(cid, summonName)
		if r == 1 then
			doSendMagicEffect(p, CONST_ME_MAGIC_BLUE)
			doPlayerSendCancel(cid, getMonsterInfo(summonName).nameDescription .." is ready to help you.")
			addEvent(f, summonTime*1000, getCreatureSummons(cid)[1])
			return true
		else
			doPlayerSendDefaultCancel(cid, r)
		end
	end
end
 
Well what i said. If i use the spell the monster will summon.. but the creature issn't being removed.. that part must be fixed:D

- - - Updated - - -

I found The original script of Cykotitan
http://otland.net/f132/remove-summon-after-5-sec-125875/#post1220830

Code:
local function f(c)
	if isMonster(c) then
		doRemoveCreature(c)
	end
end
 
function onCastSpell(cid, var)
	local p = getThingPos(cid)
	if getTileInfo(p).protection then
		doCreatureSay(cid, 'You cannot summon in PZ!', TALKTYPE_ORANGE_1, false, cid, p)
		doSendMagicEffect(p, CONST_ME_POFF)
	elseif #getCreatureSummons(cid) ~= 0 then
		doPlayerSendCancel(cid, 'You can\'t summon more than one.')
		doSendMagicEffect(p, CONST_ME_POFF)
	else
		local r = doSummonMonster(cid, 'Fire Totem')
		if r == 1 then
			doSendMagicEffect(p, CONST_ME_MAGIC_BLUE)
			doPlayerSendCancel(cid, 'You put out your fire totem.')
			doCreatureSetStorage(cid, 21981, 1)
			addEvent(f, 5000, getCreatureSummons(cid)[1])
			return true
		else
			doPlayerSendDefaultCancel(cid, r)
		end
	end
end

Ill keep using this one, altho its a bit less userfriendly it does work xD
Thanks OTX for your effort!
 
Last edited:
Back
Top