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

doSummonMonster(cid, monster)

Evil Hero

Legacy Member
TFS Developer
Joined
Dec 12, 2007
Messages
1,254
Solutions
27
Reaction score
721
Location
Germany
Hello everybody~

I've saw a function like that many times requested before, so i thought I'll just make one myself.

It's basicly a Summon function but with a max ammount of Monsters you can just summon 2 monsters instead of as much as you want.

You should be prepared that the function need the StorageValue from 30001-30003 else it will curse errors for you.

Put the following Code on the bottom of your Global.lua

Code:
-- Function Made by Evil Hero currently version 1.0 --
function doSummonMonster(cid, monster)
	if isCreature(getPlayerStorageValue(cid, 30002)) == FALSE then
		summon = doSummonCreature("".. monster .."", getPlayerPosition(cid))
		doConvinceCreature(cid, summon)
		setPlayerStorageValue(cid, 30002, summon)
		setPlayerStorageValue(cid, 30003, summon+1)
		return TRUE
	elseif isCreature(getPlayerStorageValue(cid, 30001)) == FALSE then
		summon = doSummonCreature("".. monster .."", getPlayerPosition(cid))
		doConvinceCreature(cid, summon)
		setPlayerStorageValue(cid, 30001, summon)
		setPlayerStorageValue(cid, 30003, summon+1)
		return TRUE
	elseif isCreature((getPlayerStorageValue(cid, 30003)) == summon+2) then
		doPlayerSendCancel(cid, "You can't summon more monsters!")
		return FALSE
	end
end

kind regards, Evil Hero
 
What about this ? :)
PHP:
function getPlayerSummonCount(cid, fromStorage, toStorage)
	local summons = 0
	local storage = 0
	for storageValue = fromStorage, toStorage do
		storage = getPlayerStorageValue(cid, storageValue)
		summons = summons + (isCreature(storage) == TRUE and TRUE or FALSE)
	end
	return summons
end

function hasPlayerMaxSummons(cid, fromStorage, toStorage)
	local maxSummons = toStorage - fromStorage
	return (getPlayerSummonCount(cid, fromStorage, toStorage, monster) < maxSummons and TRUE or FALSE)
end

function getPlayerAvailableStorage(cid, fromStorage, toStorage)
	local storage = 0
	for storageValue = fromStorage, toStorage do
		storage = getPlayerStorageValue(cid, storageValue)
		if isCreature(storage) == FALSE then
			return storage
		end
	end
end

function doPlayerSummonCreature(cid, fromStorage, toStorage, monster, pos)
	if hasPlayerMaxSummons(cid, fromStorage, toStorage) == FALSE then
		local uid = doSummonCreature(monster, pos)
		local storage = getPlayerAvailableStorage(cid, fromStorage, toStorage)
		setPlayerStorageValue(cid, storage, uid)
		return uid
	end
	return FALSE
end

Lot easier to use, and more configureable. You can also convince the creature using this ;)

PHP:
local monster = doPlayerSummonCreature(cid, fromStorage, toStorage, name, pos) -- change vars
if monster ~= FALSE then
	doConvinceCreature(cid, monster)
else
	doPlayerSendCancel(cid, "You cannot summon more creatures.")
end
 
Last edited:
OMG Colandus is there anything that u can't do?

anyway can u pm me ur MSN?
 
@ Colandus. Well mine is just the simpler one of us. I've did mine just in the use like the "utevo res" spell because people complained they can't use the normal doSummonCreature neither doConvinceCreature because you could summon as much as you wanted.

I think I'm maybe going to add a maxsummon function into it so people can declare that themselves :p

Your function is nice like always but mine is easier to use ^_^

kind regards, Evil Hero
 
@ Colandus
the global function doPlayerSummonCreature + this
PHP:
local monster = doPlayerSummonCreature(cid, fromStorage, toStorage, name, pos) -- change vars
if monster ~= FALSE then
    doConvinceCreature(cid, monster)
else
    doPlayerSendCancel(cid, "You cannot summon more creatures.")
end
will be like this right?
PHP:
function doPlayerSummonCreature(cid, fromStorage, toStorage, monster, pos)
local monster = doPlayerSummonCreature(cid, fromStorage, toStorage, name, pos) -- change vars
if monster ~= FALSE then
    doConvinceCreature(cid, monster)
else
    doPlayerSendCancel(cid, "You cannot summon more creatures.")
end  
    if hasPlayerMaxSummons == FALSE then
        local uid = doSummonCreature(monster, pos)
        local storage = getPlayerAvailableStorage(cid, fromStorage, toStorage)
        setPlayerStorageValue(cid, storage, uid)
        return uid
    end
    return FALSE
end
 
Nah, rather:
PHP:
function doPlayerSummonCreature(cid, fromStorage, toStorage, monster, pos)
    if hasPlayerMaxSummons(cid, fromStorage, toStorage) == FALSE then
        local uid = doSummonCreature(monster, pos)
        local storage = getPlayerAvailableStorage(cid, fromStorage, toStorage)
        setPlayerStorageValue(cid, storage, uid)
        return uid
    end
    return FALSE
end

Just add that line there ^^

And now, all you need to do is:
PHP:
doPlayerSummonCreature(cid, fromStorage, toStorage, name, pos) -- change vars
if monster ~= FALSE then
    doConvinceCreature(cid, monster)
end
 
Last edited:
Back
Top