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

Action PokeBall System v2

Stewie

Family Guy # ;3
Joined
May 3, 2010
Messages
786
Reaction score
12
Location
TV
PokeBall System v3 //

PokeBall System v3

Credits: Mazen

Hello everyone!

TFS: 0.3.6 PL1


Here is the catching monsters script for your item:
Lua:
-- Options for releasing the monster with another item --
local useBreakWithItem = false -- Enable this feature
local breakWithItem = 7428 -- Item to release the monster with.

-- Item Options --
local setActionId = 1000 -- Action id that will be set for an used item.
local breakChanse = 500 -- Break chanse. For example: if breakChanse = 500 then break chanse will be ((CurrentHp/monsterMaxHp)*monsterMaxHp)/500).

-- Limits --
local playerLevel = 50 -- Player level needed.
local monsterStatus = "convinced" -- Keep it as "convinced" if you want the monster to be like a pet for the releaser, otherwise make it "wild".
local avalibleMonsters = {"Butterfly", "Dragon", "Rat", "Demon"} -- Monsters that is possible to catch. ALWAYS write the name exactly as it is written in the monster files(It maters in this case).
local validVocations = {0, 1, 2, 3, 4, 5, 6, 7, 8} -- Vocationids of vocations that are able to use this item.

-- Effects --
local breakEffect = CONST_ME_POFF -- This effect will apear on the item when it breakes.
local usedEffect = CONST_ME_POFF -- This effect will apear on the item if it is used.
local successEffect = CONST_ME_MAGIC_GREEN -- This effect will apear on the monster when it's catched.
local releaseEffect = CONST_ME_FIREWORK_RED -- This effect will apear when the monster is released.

-- Messages --
local emptyDesc = "It\'s empty." -- Description that will be set for the item when the monster is released.

local messageColor = TALKTYPE_ORANGE_1
local successMessages = {"You\'ve succefully caught the monster.", "Success!!"} -- Success messages when the creature is caught.
local failureMessages = {"You\'ve failed to catch the monster.", "The monster ran away."} -- Failure messages.
local usedMessages = {"This item is already used", "You\'ve already used this item."} -- One of these messages apears if the item is already used.
local abortMessages = {"You\'ve failed to catch the monster.", "The monster is too strong."} -- Abort messages if the monster is in the ignore list above.
local notOnGroundMessage = {"Please put the item on the ground first.", "You can\'t release the creature in your backpack."} -- These messages apears if the item is not on the ground.
local inOnInvalidGround = {"The item is on a protected zone.", "You can\'t release the monster here."} -- These messages apears if the item is on a protected zone.
local tooLowLevel = {"You are too low level to use this item, you'll need level ".. playerLevel .." or higher."}
local invalidVocation = {"You are not able to use this item."}

--------------- END OF CONFIG -------------

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getPlayerLevel(cid) < playerLevel then
		sendMessage(cid, tooLowLevel, messageColor)
		return true
	end
	
	if not isInArray(validVocations, getPlayerVocation(cid)) then
		sendMessage(cid, invalidVocation, messageColor)
		return true
	end
	
	if useBreakWithItem then
		if item.itemid == breakWithItem and releaseMonster(cid, itemEx, toPosition) then
			return true
		end
	else
		if releaseMonster(cid, item, toPosition) then
			return true
		end
	end

	if item.actionid > 100 then
		if item.actionid ~= setActionId then
			doItemSetAttribute(item.uid, "aid", setActionId)
		end
		sendMessage(cid, usedMessages, messageColor)
		doSendMagicEffect(getCreaturePosition(cid), usedEffect)
		return true
	end
	if isMonster(itemEx.uid) then
		monsterFullHp, monsterHp = getCreatureMaxHealth(itemEx.uid), getCreatureHealth(itemEx.uid)
		formula = (monsterHp/monsterFullHp)*monsterFullHp
		chanse, bchanse = math.random(1, formula), math.floor(formula)
		if (chanse+breakChanse) >= bchanse then
			s = 0
			for i = 1, #avalibleMonsters do
				if getCreatureName(itemEx.uid) ~= avalibleMonsters[i] then
					s = s + 1
				end
			end
			if s == #avalibleMonsters then
				sendMessage(cid, abortMessages, messageColor)
				doSendMagicEffect(getCreaturePosition(cid), breakEffect)
				return true
			end
			doItemSetAttribute(item.uid, "description", "It contains a captured ".. getCreatureName(itemEx.uid) ..".")
			doItemSetAttribute(item.uid, "aid", setActionId)
			doRemoveCreature(itemEx.uid)
			sendMessage(cid, successMessages, messageColor)
			doSendMagicEffect(toPosition, successEffect)
		else
			if getCreatureMaster(itemEx.uid) ~= cid then
				doRemoveItem(item.uid, 1)
			end
			doSendMagicEffect(getCreaturePosition(cid), breakEffect)
			sendMessage(cid, failureMessages, messageColor)
		end
	else
		doSendMagicEffect(getCreaturePosition(cid), breakEffect)
	end
	return true
end

function sendMessage(cid, table, color)
	if table[1] == nil then
		return nil
	end
	messageId = math.random(1, #table)
	doCreatureSay(cid, table[messageId], color)
end

function releaseMonster(cid, itemEx, toPosition)
	if itemEx.actionid == setActionId then
		for i = 1, #avalibleMonsters do
			desc = getItemDescriptions(itemEx.uid).special
			local fromS, toS = desc:find(avalibleMonsters[i])
			if toS then
				if toPosition.x ~= CONTAINER_POSITION then
					if not getTilePzInfo(getThingPos(itemEx.uid)) then
						monsPar = doCreateMonster(desc:sub(fromS, toS), toPosition)
						if monsterStatus == "convinced" then
							doConvinceCreature(cid, monsPar)
						end
						doItemSetAttribute(itemEx.uid, "aid", 0)
						doItemSetAttribute(itemEx.uid, "description", emptyDesc)
						doSendMagicEffect(getCreaturePosition(monsPar), releaseEffect)
					else
						sendMessage(cid, inOnInvalidGround, messageColor)
						doSendMagicEffect(getCreaturePosition(cid), breakEffect)
					end
					return true
				else
					sendMessage(cid, notOnGroundMessage, messageColor)
					doSendMagicEffect(getCreaturePosition(cid), breakEffect)
				end
				break
			end
		end
	end
	return false
end

In actions.xml:
Lua:
	<action itemid="7428" event="script" value="other/Pokeball.lua"/> -- For the item to release the monster with.
	<action itemid="9743" event="script" value="other/Pokeball.lua"/> -- For the item that the monster should be captured in.

Note: The script is both for the item that the monster is captured in and for the item to release the monster from the trapping item. (Don't get confused :S)
 
Last edited:
That entire post hurt my eyes as did the lua script. No rep for you.
 
[Error - Action Interface]
data/actions/scripts/rep/pokeball.lua:eek:nUse
Description:
data/lib/000-constant.lua:826: attempt to call global 'getPlayerStorageInteger'
(a nil value)
stack traceback:
data/lib/000-constant.lua:826: in function 'getPlayerStorageString'
data/actions/scripts/rep/pokeball.lua:10: in function <data/actions/scri
pts/rep/pokeball.lua:8>

Using 0.3.6 pl1/854
 
@up you fucked up the install. If you have a lib folder just take that first script and put it in a blank .lua file and save it to the lib folder.

Then do the rest of the shit.
 
can create a PET SYSTEM with this script,would be very good
 
[07/05/2010 17:26:30] [Error - Action Interface]
[07/05/2010 17:26:30] data/actions/scripts/pokebola.lua:eek:nUse
[07/05/2010 17:26:30] Description:
[07/05/2010 17:26:30] (luaGetTileInfo) Tile not found

[07/05/2010 17:26:30] [Error - Action Interface]
[07/05/2010 17:26:30] data/actions/scripts/pokebola.lua:eek:nUse
[07/05/2010 17:26:30] Description:
[07/05/2010 17:26:30] data/lib/function.lua:262: attempt to index a boolean value
[07/05/2010 17:26:30] stack traceback:
 
Add this in Function .
PHP:
function doConvinceSummon(cid, creature, amount, pos)
summonplayerpos = {x=pos.x, y=pos.y, z=pos.z, stackpos=253}
summonplayer = getThingfromPos(summonplayerpos)


if(summonplayer ~= nil and summonplayer.itemid > 0) then 
doPlayerSendCancel(cid,"There is not enough room to summon here.")
ret = 0
else
convince = doSummonCreature(creature, pos)
doConvinceCreature(cid, convince)
ret = 1
end

return ret
end
 

hey man i got this error:

Code:
`[10/05/2010 19:16:32] [Error - Action Interface] 
[10/05/2010 19:16:32] data/actions/scripts/pokeball.lua:onUse
[10/05/2010 19:16:32] Description: 
[10/05/2010 19:16:32] data/lib/000-Pokeball.lua:53: attempt to call global 'getPlayerStorageInteger' (a nil value)
[10/05/2010 19:16:32] stack traceback:
[10/05/2010 19:16:32] 	data/lib/000-Pokeball.lua:53: in function 'getPlayerStorageString'
[10/05/2010 19:16:32] 	data/actions/scripts/pokeball.lua:10: in function <data/actions/scripts/pokeball.lua:8>

in TFS 0.3.6pl1 (8.54)
 
Code:
[18/05/2010 00:26:41] data/actions/scripts/other/pokeballsystem.lua:64: attempt to call global 'doSetItemSpecialDescription' (a nil value)
[18/05/2010 00:26:41] stack traceback:
[18/05/2010 00:26:41] 	data/actions/scripts/other/pokeballsystem.lua:64: in function <data/actions/scripts/other/pokeballsystem.lua:8>

TFs 0.3.6pl1
 
doesnt work for me

files:

data/lib/pokeball.lua <-- for funcions

data/actions/pokeball.lua <-- for script
 
Back
Top