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

Capture monsters

josesaucedo

New Member
Joined
Jun 21, 2013
Messages
20
Reaction score
0
Help for a monster capture script
My problem is that it does not capture anything, it is tfs 0.3.6 I will leave my .lua
Lua:
local monsters = {
[1] = {name = "triton" , aid = 1000},
[2] = {name = "jaws" , aid = 1001},
[3] = {name = "aegaeus" , aid = 1002},
[4] = {name = "kraken" , aid = 1003}
}
local effects = {
[1] = {28, 210},
[2] = {29, 180},
[3] = {30, 45}
}
function onUse(cid, item, frompos, item2,
topos)
if item.itemid == 5928 then
if getTilePzInfo(getPlayerPosition(cid))
then
return doPlayerSendCancel(cid,
"You
cannot capture monsters in protection
zone.")
end
local MONS = nil
for i = 1, #monsters do
if monsters[i].name ==
getCreatureName(item2.uid) then
MONS = monsters[i]
break
end
end
if not MONS then
return doPlayerSendCancel(cid,
"You
cannot capture this monster.")
end
local EFF = effects[math.random(1, 3)]
if not EFF then
return doPlayerSendCancel(cid,
"Please
report this error to the gamemaster.")
end
if releasedMonsters[item2.uid] and
releasedMonsters[item2.uid] ~=
getPlayerGUID(cid) then
return doPlayerSendCancel(cid,
"This
monster is not yours to catch.")
end
doItemSetAttribute(item.uid,
"description"
,
"It contains a:
"..getCreatureName(item2.uid)..".")
doItemSetAttribute(item.uid,
"aid"
,
MONS.aid)
if releasedMonsters[item2.uid] then
releasedMonsters[item2.uid] = nil
end
doRemoveCreature(item2.uid)
doSendMagicEffect(topos, EFF[1])
doSendAnimatedText(topos,
'Captured!'
,
EFF[2])
doTransformItem(item.uid, 5929)
elseif item.itemid == 5929 then
if getTilePzInfo(getPlayerPosition(cid))
then
return doPlayerSendCancel(cid,
"You
cannot release monsters in protection
zone.")
end
local MONS = nil
for i = 1, #monsters do
if monsters[i].aid ==
getItemAttribute(item.uid,
"aid") then
MONS = monsters[i]
break
end
end
if not MONS then
return doPlayerSendCancel(cid,
"Please
report this error to the gamemaster.")
end
local EFF = effects[math.random(1, 3)]
if not EFF then
return doPlayerSendCancel(cid,
"Please
report this error to the gamemaster.")
end
local mons =
doCreateMonster(MONS.name,
getCreaturePosition(cid))
if mons then
releasedMonsters[mons] =
getPlayerGUID(cid)
doSendMagicEffect(getCreaturePosition(m
ons), EFF[1])
doSendAnimatedText(getCreaturePosition(
mons),
'Released!'
, EFF[2])
doRemoveItem(item.uid, 1)
else
return doPlayerSendCancel(cid,
"Could
not release monster.")
end
end
return true
end
 
Solution
@josesaucedo

Try
Lua:
local monsters = {
    [1] = {name = "triton" , aid = 1000},
    [2] = {name = "jaws" , aid = 1001},
    [3] = {name = "aegaeus" , aid = 1002},
    [4] = {name = "kraken" , aid = 1003}
}

local effects = {
    [1] = {28, 210},
    [2] = {29, 180},
    [3] = {30, 45}
}

releasedMonsters = {}

function onUse(cid, item, frompos, item2, topos)
    if item.itemid == 5928 then
        if getTilePzInfo(getPlayerPosition(cid)) then
            return doPlayerSendCancel(cid, "You cannot capture monsters in protection zone.")
        end
        local MONS = nil
        for i = 1, #monsters do
            if monsters[i].name == getCreatureName(item2.uid):lower() then
                MONS = monsters[i]...
What a mess.
Did it just copy-paste fail?

Anyway, are you getting any errors?
Did you set up itemid's 5928 and 5929 in actions.xml?

Here's the code from above formatted properly.
Lua:
local monsters = {
	[1] = {name = "triton" , aid = 1000},
	[2] = {name = "jaws" , aid = 1001},
	[3] = {name = "aegaeus" , aid = 1002},
	[4] = {name = "kraken" , aid = 1003}
}
local effects = {
	[1] = {28, 210},
	[2] = {29, 180},
	[3] = {30, 45}
}
function onUse(cid, item, frompos, item2, topos)
	if item.itemid == 5928 then
		if getTilePzInfo(getPlayerPosition(cid)) then
			return doPlayerSendCancel(cid, "You cannot capture monsters in protection zone.")
		end
		local MONS = nil
		for i = 1, #monsters do
			if monsters[i].name == getCreatureName(item2.uid) then
				MONS = monsters[i]
				break
			end
		end
		if not MONS then
			return doPlayerSendCancel(cid, "You cannot capture this monster.")
		end
		local EFF = effects[math.random(1, 3)]
		if not EFF then
			return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
		end
		if releasedMonsters[item2.uid] and releasedMonsters[item2.uid] ~= getPlayerGUID(cid) then
			return doPlayerSendCancel(cid, "This monster is not yours to catch.")
		end
		doItemSetAttribute(item.uid, "description", "It contains a: "..getCreatureName(item2.uid)..".")
		doItemSetAttribute(item.uid, "aid", MONS.aid)
		if releasedMonsters[item2.uid] then
			releasedMonsters[item2.uid] = nil
		end
		doRemoveCreature(item2.uid)
		doSendMagicEffect(topos, EFF[1])
		doSendAnimatedText(topos, 'Captured!', EFF[2])
		doTransformItem(item.uid, 5929)
	elseif item.itemid == 5929 then
		if getTilePzInfo(getPlayerPosition(cid))
		then
			return doPlayerSendCancel(cid, "You cannot release monsters in protection zone.")
		end
		local MONS = nil
		for i = 1, #monsters do
			if monsters[i].aid == getItemAttribute(item.uid, "aid") then
				MONS = monsters[i]
				break
			end
		end
		if not MONS then
			return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
		end
		local EFF = effects[math.random(1, 3)]
		if not EFF then
			return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
		end
		local mons = doCreateMonster(MONS.name, getCreaturePosition(cid))
		if mons then
			releasedMonsters[mons] = getPlayerGUID(cid)
			doSendMagicEffect(getCreaturePosition(mons), EFF[1])
			doSendAnimatedText(getCreaturePosition(mons), 'Released!', EFF[2])
			doRemoveItem(item.uid, 1)
		else
			return doPlayerSendCancel(cid, "Could not release monster.")
		end
	end
	return true
end
 
What a mess.
Did it just copy-paste fail?

Anyway, are you getting any errors?
Did you set up itemid's 5928 and 5929 in actions.xml?

Here's the code from above formatted properly.
Lua:
local monsters = {
    [1] = {name = "triton" , aid = 1000},
    [2] = {name = "jaws" , aid = 1001},
    [3] = {name = "aegaeus" , aid = 1002},
    [4] = {name = "kraken" , aid = 1003}
}
local effects = {
    [1] = {28, 210},
    [2] = {29, 180},
    [3] = {30, 45}
}
function onUse(cid, item, frompos, item2, topos)
    if item.itemid == 5928 then
        if getTilePzInfo(getPlayerPosition(cid)) then
            return doPlayerSendCancel(cid, "You cannot capture monsters in protection zone.")
        end
        local MONS = nil
        for i = 1, #monsters do
            if monsters[i].name == getCreatureName(item2.uid) then
                MONS = monsters[i]
                break
            end
        end
        if not MONS then
            return doPlayerSendCancel(cid, "You cannot capture this monster.")
        end
        local EFF = effects[math.random(1, 3)]
        if not EFF then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        if releasedMonsters[item2.uid] and releasedMonsters[item2.uid] ~= getPlayerGUID(cid) then
            return doPlayerSendCancel(cid, "This monster is not yours to catch.")
        end
        doItemSetAttribute(item.uid, "description", "It contains a: "..getCreatureName(item2.uid)..".")
        doItemSetAttribute(item.uid, "aid", MONS.aid)
        if releasedMonsters[item2.uid] then
            releasedMonsters[item2.uid] = nil
        end
        doRemoveCreature(item2.uid)
        doSendMagicEffect(topos, EFF[1])
        doSendAnimatedText(topos, 'Captured!', EFF[2])
        doTransformItem(item.uid, 5929)
    elseif item.itemid == 5929 then
        if getTilePzInfo(getPlayerPosition(cid))
        then
            return doPlayerSendCancel(cid, "You cannot release monsters in protection zone.")
        end
        local MONS = nil
        for i = 1, #monsters do
            if monsters[i].aid == getItemAttribute(item.uid, "aid") then
                MONS = monsters[i]
                break
            end
        end
        if not MONS then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        local EFF = effects[math.random(1, 3)]
        if not EFF then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        local mons = doCreateMonster(MONS.name, getCreaturePosition(cid))
        if mons then
            releasedMonsters[mons] = getPlayerGUID(cid)
            doSendMagicEffect(getCreaturePosition(mons), EFF[1])
            doSendAnimatedText(getCreaturePosition(mons), 'Released!', EFF[2])
            doRemoveItem(item.uid, 1)
        else
            return doPlayerSendCancel(cid, "Could not release monster.")
        end
    end
    return true
end
Yes have un xml
What a mess.
Did it just copy-paste fail?

Anyway, are you getting any errors?
Did you set up itemid's 5928 and 5929 in actions.xml?

Here's the code from above formatted properly.
Lua:
local monsters = {
    [1] = {name = "triton" , aid = 1000},
    [2] = {name = "jaws" , aid = 1001},
    [3] = {name = "aegaeus" , aid = 1002},
    [4] = {name = "kraken" , aid = 1003}
}
local effects = {
    [1] = {28, 210},
    [2] = {29, 180},
    [3] = {30, 45}
}
function onUse(cid, item, frompos, item2, topos)
    if item.itemid == 5928 then
        if getTilePzInfo(getPlayerPosition(cid)) then
            return doPlayerSendCancel(cid, "You cannot capture monsters in protection zone.")
        end
        local MONS = nil
        for i = 1, #monsters do
            if monsters[i].name == getCreatureName(item2.uid) then
                MONS = monsters[i]
                break
            end
        end
        if not MONS then
            return doPlayerSendCancel(cid, "You cannot capture this monster.")
        end
        local EFF = effects[math.random(1, 3)]
        if not EFF then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        if releasedMonsters[item2.uid] and releasedMonsters[item2.uid] ~= getPlayerGUID(cid) then
            return doPlayerSendCancel(cid, "This monster is not yours to catch.")
        end
        doItemSetAttribute(item.uid, "description", "It contains a: "..getCreatureName(item2.uid)..".")
        doItemSetAttribute(item.uid, "aid", MONS.aid)
        if releasedMonsters[item2.uid] then
            releasedMonsters[item2.uid] = nil
        end
        doRemoveCreature(item2.uid)
        doSendMagicEffect(topos, EFF[1])
        doSendAnimatedText(topos, 'Captured!', EFF[2])
        doTransformItem(item.uid, 5929)
    elseif item.itemid == 5929 then
        if getTilePzInfo(getPlayerPosition(cid))
        then
            return doPlayerSendCancel(cid, "You cannot release monsters in protection zone.")
        end
        local MONS = nil
        for i = 1, #monsters do
            if monsters[i].aid == getItemAttribute(item.uid, "aid") then
                MONS = monsters[i]
                break
            end
        end
        if not MONS then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        local EFF = effects[math.random(1, 3)]
        if not EFF then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        local mons = doCreateMonster(MONS.name, getCreaturePosition(cid))
        if mons then
            releasedMonsters[mons] = getPlayerGUID(cid)
            doSendMagicEffect(getCreaturePosition(mons), EFF[1])
            doSendAnimatedText(getCreaturePosition(mons), 'Released!', EFF[2])
            doRemoveItem(item.uid, 1)
        else
            return doPlayerSendCancel(cid, "Could not release monster.")
        end
    end
    return true
end
What a mess.
Did it just copy-paste fail?

Anyway, are you getting any errors?
Did you set up itemid's 5928 and 5929 in actions.xml?

Here's the code from above formatted properly.
Lua:
local monsters = {
    [1] = {name = "triton" , aid = 1000},
    [2] = {name = "jaws" , aid = 1001},
    [3] = {name = "aegaeus" , aid = 1002},
    [4] = {name = "kraken" , aid = 1003}
}
local effects = {
    [1] = {28, 210},
    [2] = {29, 180},
    [3] = {30, 45}
}
function onUse(cid, item, frompos, item2, topos)
    if item.itemid == 5928 then
        if getTilePzInfo(getPlayerPosition(cid)) then
            return doPlayerSendCancel(cid, "You cannot capture monsters in protection zone.")
        end
        local MONS = nil
        for i = 1, #monsters do
            if monsters[i].name == getCreatureName(item2.uid) then
                MONS = monsters[i]
                break
            end
        end
        if not MONS then
            return doPlayerSendCancel(cid, "You cannot capture this monster.")
        end
        local EFF = effects[math.random(1, 3)]
        if not EFF then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        if releasedMonsters[item2.uid] and releasedMonsters[item2.uid] ~= getPlayerGUID(cid) then
            return doPlayerSendCancel(cid, "This monster is not yours to catch.")
        end
        doItemSetAttribute(item.uid, "description", "It contains a: "..getCreatureName(item2.uid)..".")
        doItemSetAttribute(item.uid, "aid", MONS.aid)
        if releasedMonsters[item2.uid] then
            releasedMonsters[item2.uid] = nil
        end
        doRemoveCreature(item2.uid)
        doSendMagicEffect(topos, EFF[1])
        doSendAnimatedText(topos, 'Captured!', EFF[2])
        doTransformItem(item.uid, 5929)
    elseif item.itemid == 5929 then
        if getTilePzInfo(getPlayerPosition(cid))
        then
            return doPlayerSendCancel(cid, "You cannot release monsters in protection zone.")
        end
        local MONS = nil
        for i = 1, #monsters do
            if monsters[i].aid == getItemAttribute(item.uid, "aid") then
                MONS = monsters[i]
                break
            end
        end
        if not MONS then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        local EFF = effects[math.random(1, 3)]
        if not EFF then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        local mons = doCreateMonster(MONS.name, getCreaturePosition(cid))
        if mons then
            releasedMonsters[mons] = getPlayerGUID(cid)
            doSendMagicEffect(getCreaturePosition(mons), EFF[1])
            doSendAnimatedText(getCreaturePosition(mons), 'Released!', EFF[2])
            doRemoveItem(item.uid, 1)
        else
            return doPlayerSendCancel(cid, "Could not release monster.")
        end
    end
    return true
end
Yes have in xml
 
What a mess.
Did it just copy-paste fail?

Anyway, are you getting any errors?
Did you set up itemid's 5928 and 5929 in actions.xml?

Here's the code from above formatted properly.
Lua:
local monsters = {
    [1] = {name = "triton" , aid = 1000},
    [2] = {name = "jaws" , aid = 1001},
    [3] = {name = "aegaeus" , aid = 1002},
    [4] = {name = "kraken" , aid = 1003}
}
local effects = {
    [1] = {28, 210},
    [2] = {29, 180},
    [3] = {30, 45}
}
function onUse(cid, item, frompos, item2, topos)
    if item.itemid == 5928 then
        if getTilePzInfo(getPlayerPosition(cid)) then
            return doPlayerSendCancel(cid, "You cannot capture monsters in protection zone.")
        end
        local MONS = nil
        for i = 1, #monsters do
            if monsters[i].name == getCreatureName(item2.uid) then
                MONS = monsters[i]
                break
            end
        end
        if not MONS then
            return doPlayerSendCancel(cid, "You cannot capture this monster.")
        end
        local EFF = effects[math.random(1, 3)]
        if not EFF then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        if releasedMonsters[item2.uid] and releasedMonsters[item2.uid] ~= getPlayerGUID(cid) then
            return doPlayerSendCancel(cid, "This monster is not yours to catch.")
        end
        doItemSetAttribute(item.uid, "description", "It contains a: "..getCreatureName(item2.uid)..".")
        doItemSetAttribute(item.uid, "aid", MONS.aid)
        if releasedMonsters[item2.uid] then
            releasedMonsters[item2.uid] = nil
        end
        doRemoveCreature(item2.uid)
        doSendMagicEffect(topos, EFF[1])
        doSendAnimatedText(topos, 'Captured!', EFF[2])
        doTransformItem(item.uid, 5929)
    elseif item.itemid == 5929 then
        if getTilePzInfo(getPlayerPosition(cid))
        then
            return doPlayerSendCancel(cid, "You cannot release monsters in protection zone.")
        end
        local MONS = nil
        for i = 1, #monsters do
            if monsters[i].aid == getItemAttribute(item.uid, "aid") then
                MONS = monsters[i]
                break
            end
        end
        if not MONS then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        local EFF = effects[math.random(1, 3)]
        if not EFF then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        local mons = doCreateMonster(MONS.name, getCreaturePosition(cid))
        si mons entonces
            ReleaseMonsters [mons] = getPlayerGUID (cid)
            doSendMagicEffect (getCreaturePosition (mons), EFF [1])
            doSendAnimatedText (getCreaturePosition (mons), '¡Lanzado!', EFF [2])
            doRemoveItem (item.uid, 1)
        demás
            return doPlayerSendCancel (cid, "No se pudo liberar al monstruo")
        fin
    fin
    volver verdadero
fin [/ código]
[/QUOTE]
Error in console data/actions/script/fishing bowl.lua:18: unfinished string near "You'
Post automatically merged:

Alright.. but are you getting any errors in the console?

Are you getting any of the cancel messages in-game?

Do you have any information that might be helpful?
Post automatically merged:

Alright.. but are you getting any errors in the console?

Are you getting any of the cancel messages in-game?

Do you have any information that might be helpful?
Error in console data/actions/script/fishing bowl.lua:18: unfinished string near "You
 
Last edited:
@josesaucedo

Alright, can you test this code please?
Lua:
local monsters = {
    [1] = {name = "triton" , aid = 1000},
    [2] = {name = "jaws" , aid = 1001},
    [3] = {name = "aegaeus" , aid = 1002},
    [4] = {name = "kraken" , aid = 1003}
}

local effects = {
    [1] = {28, 210},
    [2] = {29, 180},
    [3] = {30, 45}
}

function onUse(cid, item, frompos, item2, topos)
    if item.itemid == 5928 then
        if getTilePzInfo(getPlayerPosition(cid)) then
            return doPlayerSendCancel(cid, "You cannot capture monsters in protection zone.")
        end
        local MONS = nil
        for i = 1, #monsters do
            if monsters[i].name == getCreatureName(item2.uid) then
                MONS = monsters[i]
                break
            end
        end
        if not MONS then
            return doPlayerSendCancel(cid, "You cannot capture this monster.")
        end
        local EFF = effects[math.random(1, 3)]
        if not EFF then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        if releasedMonsters[item2.uid] and releasedMonsters[item2.uid] ~= getPlayerGUID(cid) then
            return doPlayerSendCancel(cid, "This monster is not yours to catch.")
        end
        doItemSetAttribute(item.uid, "description", "It contains a: "..getCreatureName(item2.uid)..".")
        doItemSetAttribute(item.uid, "aid", MONS.aid)
        if releasedMonsters[item2.uid] then
            releasedMonsters[item2.uid] = nil
        end
        doRemoveCreature(item2.uid)
        doSendMagicEffect(topos, EFF[1])
        doSendAnimatedText(topos, 'Captured!', EFF[2])
        doTransformItem(item.uid, 5929)
    elseif item.itemid == 5929 then
        if getTilePzInfo(getPlayerPosition(cid))
        then
            return doPlayerSendCancel(cid, "You cannot release monsters in protection zone.")
        end
        local MONS = nil
        for i = 1, #monsters do
            if monsters[i].aid == getItemAttribute(item.uid, "aid") then
                MONS = monsters[i]
                break
            end
        end
        if not MONS then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        local EFF = effects[math.random(1, 3)]
        if not EFF then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        local mons = doCreateMonster(MONS.name, getCreaturePosition(cid))
        if mons then
            releasedMonsters[mons] = getPlayerGUID(cid)
            doSendMagicEffect(getCreaturePosition(mons), EFF[1])
            doSendAnimatedText(getCreaturePosition(mons), 'Released!', EFF[2])
            doRemoveItem(item.uid, 1)
        else
            return doPlayerSendCancel(cid, "Could not release monster.")
        end
    end
    return true
end
 
@josesaucedo

Alright, can you test this code please?
Lua:
local monsters = {
    [1] = {name = "triton" , aid = 1000},
    [2] = {name = "jaws" , aid = 1001},
    [3] = {name = "aegaeus" , aid = 1002},
    [4] = {name = "kraken" , aid = 1003}
}

local effects = {
    [1] = {28, 210},
    [2] = {29, 180},
    [3] = {30, 45}
}

function onUse(cid, item, frompos, item2, topos)
    if item.itemid == 5928 then
        if getTilePzInfo(getPlayerPosition(cid)) then
            return doPlayerSendCancel(cid, "You cannot capture monsters in protection zone.")
        end
        local MONS = nil
        for i = 1, #monsters do
            if monsters[i].name == getCreatureName(item2.uid) then
                MONS = monsters[i]
                break
            end
        end
        if not MONS then
            return doPlayerSendCancel(cid, "You cannot capture this monster.")
        end
        local EFF = effects[math.random(1, 3)]
        if not EFF then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        if releasedMonsters[item2.uid] and releasedMonsters[item2.uid] ~= getPlayerGUID(cid) then
            return doPlayerSendCancel(cid, "This monster is not yours to catch.")
        end
        doItemSetAttribute(item.uid, "description", "It contains a: "..getCreatureName(item2.uid)..".")
        doItemSetAttribute(item.uid, "aid", MONS.aid)
        if releasedMonsters[item2.uid] then
            releasedMonsters[item2.uid] = nil
        end
        doRemoveCreature(item2.uid)
        doSendMagicEffect(topos, EFF[1])
        doSendAnimatedText(topos, 'Captured!', EFF[2])
        doTransformItem(item.uid, 5929)
    elseif item.itemid == 5929 then
        if getTilePzInfo(getPlayerPosition(cid))
        then
            return doPlayerSendCancel(cid, "You cannot release monsters in protection zone.")
        end
        local MONS = nil
        for i = 1, #monsters do
            if monsters[i].aid == getItemAttribute(item.uid, "aid") then
                MONS = monsters[i]
                break
            end
        end
        if not MONS then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        local EFF = effects[math.random(1, 3)]
        if not EFF then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        local mons = doCreateMonster(MONS.name, getCreaturePosition(cid))
        if mons then
            releasedMonsters[mons] = getPlayerGUID(cid)
            doSendMagicEffect(getCreaturePosition(mons), EFF[1])
            doSendAnimatedText(getCreaturePosition(mons), 'Released!', EFF[2])
            doRemoveItem(item.uid, 1)
        else
            return doPlayerSendCancel(cid, "Could not release monster.")
        end
    end
    return true
end
the console no longer has an error but inside warm it appears
you cannot capture this monster
 
the console no longer has an error but inside warm it appears
you cannot capture this monster
Try this.
Lua:
local monsters = {
    [1] = {name = "triton" , aid = 1000},
    [2] = {name = "jaws" , aid = 1001},
    [3] = {name = "aegaeus" , aid = 1002},
    [4] = {name = "kraken" , aid = 1003}
}

local effects = {
    [1] = {28, 210},
    [2] = {29, 180},
    [3] = {30, 45}
}

function onUse(cid, item, frompos, item2, topos)
    if item.itemid == 5928 then
        if getTilePzInfo(getPlayerPosition(cid)) then
            return doPlayerSendCancel(cid, "You cannot capture monsters in protection zone.")
        end
        if not isCreature(item2.uid) then
            return
        end
        local MONS = nil
        for i = 1, #monsters do
            if monsters[i].name == getCreatureName(item2.uid):lower() then
                MONS = monsters[i]
                break
            end
        end
        if not MONS then
            return doPlayerSendCancel(cid, "You cannot capture this monster. " .. (getCreatureName(item2.uid):lower()))
        end
        local EFF = effects[math.random(1, 3)]
        if not EFF then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        if releasedMonsters[item2.uid] and releasedMonsters[item2.uid] ~= getPlayerGUID(cid) then
            return doPlayerSendCancel(cid, "This monster is not yours to catch.")
        end
        doItemSetAttribute(item.uid, "description", "It contains a: "..getCreatureName(item2.uid)..".")
        doItemSetAttribute(item.uid, "aid", MONS.aid)
        if releasedMonsters[item2.uid] then
            releasedMonsters[item2.uid] = nil
        end
        doRemoveCreature(item2.uid)
        doSendMagicEffect(topos, EFF[1])
        doSendAnimatedText(topos, 'Captured!', EFF[2])
        doTransformItem(item.uid, 5929)
    elseif item.itemid == 5929 then
        if getTilePzInfo(getPlayerPosition(cid))
        then
            return doPlayerSendCancel(cid, "You cannot release monsters in protection zone.")
        end
        local MONS = nil
        for i = 1, #monsters do
            if monsters[i].aid == getItemAttribute(item.uid, "aid") then
                MONS = monsters[i]
                break
            end
        end
        if not MONS then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        local EFF = effects[math.random(1, 3)]
        if not EFF then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        local mons = doCreateMonster(MONS.name, getCreaturePosition(cid))
        if mons then
            releasedMonsters[mons] = getPlayerGUID(cid)
            doSendMagicEffect(getCreaturePosition(mons), EFF[1])
            doSendAnimatedText(getCreaturePosition(mons), 'Released!', EFF[2])
            doRemoveItem(item.uid, 1)
        else
            return doPlayerSendCancel(cid, "Could not release monster.")
        end
    end
    return true
end
 
Try this.
Lua:
local monsters = {
    [1] = {name = "triton" , aid = 1000},
    [2] = {name = "jaws" , aid = 1001},
    [3] = {name = "aegaeus" , aid = 1002},
    [4] = {name = "kraken" , aid = 1003}
}

local effects = {
    [1] = {28, 210},
    [2] = {29, 180},
    [3] = {30, 45}
}

function onUse(cid, item, frompos, item2, topos)
    if item.itemid == 5928 then
        if getTilePzInfo(getPlayerPosition(cid)) then
            return doPlayerSendCancel(cid, "You cannot capture monsters in protection zone.")
        end
        if not isCreature(item2.uid) then
            return
        end
        local MONS = nil
        for i = 1, #monsters do
            if monsters[i].name == getCreatureName(item2.uid):lower() then
                MONS = monsters[i]
                break
            end
        end
        if not MONS then
            return doPlayerSendCancel(cid, "You cannot capture this monster. " .. (getCreatureName(item2.uid):lower()))
        end
        local EFF = effects[math.random(1, 3)]
        if not EFF then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        if releasedMonsters[item2.uid] and releasedMonsters[item2.uid] ~= getPlayerGUID(cid) then
            return doPlayerSendCancel(cid, "This monster is not yours to catch.")
        end
        doItemSetAttribute(item.uid, "description", "It contains a: "..getCreatureName(item2.uid)..".")
        doItemSetAttribute(item.uid, "aid", MONS.aid)
        if releasedMonsters[item2.uid] then
            releasedMonsters[item2.uid] = nil
        end
        doRemoveCreature(item2.uid)
        doSendMagicEffect(topos, EFF[1])
        doSendAnimatedText (topos, 'Capturado!', EFF [2])
        doTransformItem (item.uid, 5929)
    elseif item.itemid == 5929 entonces
        if getTilePzInfo (getPlayerPosition (cid))
        luego
            return doPlayerSendCancel (cid, "No puedes liberar monstruos en la zona de protección").
        fin
        MONS local = cero
        para i = 1, los #monsters hacen
            si los monstruos [i] .aid == getItemAttribute (item.uid, "aid") entonces
                MONS = monstruos [i]
                rotura
            fin
        fin
        si no es MONS entonces
            return doPlayerSendCancel (cid, "Informe este error al director del juego").
        fin
        EFF local = efectos [math.random (1, 3)]
        si no es EFF entonces
            return doPlayerSendCancel (cid, "Informe este error al director del juego").
        fin
        local mons = doCreateMonster (MONS.name, getCreaturePosition (cid))
        si mons entonces
            ReleaseMonsters [mons] = getPlayerGUID (cid)
            doSendMagicEffect (getCreaturePosition (mons), EFF [1])
            doSendAnimatedText (getCreaturePosition (mons), '¡Lanzado!', EFF [2])
            doRemoveItem (item.uid, 1)
        demás
            return doPlayerSendCancel (cid, "No se pudo liberar al monstruo")
        fin
    fin
    volver verdadero
fin [/ código]
[/QUOTE]
No puedo encontrar un error en la consola y dentro de tibia ahora dice
No puedes usar esto object
Post automatically merged:

Try this.
Lua:
local monsters = {
    [1] = {name = "triton" , aid = 1000},
    [2] = {name = "jaws" , aid = 1001},
    [3] = {name = "aegaeus" , aid = 1002},
    [4] = {name = "kraken" , aid = 1003}
}

local effects = {
    [1] = {28, 210},
    [2] = {29, 180},
    [3] = {30, 45}
}

function onUse(cid, item, frompos, item2, topos)
    if item.itemid == 5928 then
        if getTilePzInfo(getPlayerPosition(cid)) then
            return doPlayerSendCancel(cid, "You cannot capture monsters in protection zone.")
        end
        if not isCreature(item2.uid) then
            return
        end
        local MONS = nil
        for i = 1, #monsters do
            if monsters[i].name == getCreatureName(item2.uid):lower() then
                MONS = monsters[i]
                break
            end
        end
        if not MONS then
            return doPlayerSendCancel(cid, "You cannot capture this monster. " .. (getCreatureName(item2.uid):lower()))
        end
        local EFF = effects[math.random(1, 3)]
        if not EFF then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        if releasedMonsters[item2.uid] and releasedMonsters[item2.uid] ~= getPlayerGUID(cid) then
            return doPlayerSendCancel(cid, "This monster is not yours to catch.")
        end
        doItemSetAttribute(item.uid, "description", "It contains a: "..getCreatureName(item2.uid)..".")
        doItemSetAttribute(item.uid, "aid", MONS.aid)
        if releasedMonsters[item2.uid] then
            releasedMonsters[item2.uid] = nil
        end
        doRemoveCreature(item2.uid)
        doSendMagicEffect(topos, EFF[1])
        doSendAnimatedText(topos, 'Captured!', EFF[2])
        doTransformItem(item.uid, 5929)
    elseif item.itemid == 5929 then
        if getTilePzInfo(getPlayerPosition(cid))
        then
            return doPlayerSendCancel(cid, "You cannot release monsters in protection zone.")
        end
        local MONS = nil
        for i = 1, #monsters do
            if monsters[i].aid == getItemAttribute(item.uid, "aid") then
                MONS = monsters[i]
                break
            end
        end
        if not MONS then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        local EFF = effects[math.random(1, 3)]
        if not EFF then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        local mons = doCreateMonster(MONS.name, getCreaturePosition(cid))
        if mons then
            releasedMonsters[mons] = getPlayerGUID(cid)
            doSendMagicEffect(getCreaturePosition(mons), EFF[1])
            doSendAnimatedText(getCreaturePosition(mons), 'Released!', EFF[2])
            doRemoveItem(item.uid, 1)
        else
            return doPlayerSendCancel(cid, "Could not release monster.")
        end
    end
    return true
end
I can't find an error in console and inside tibia now it says
You cannot use this object
 
Post automatically merged:


I can't find an error in console and inside tibia now it says
You cannot use this object
🤔

I guess I'll remove the extra checks.

Try this
Lua:
local monsters = {
    [1] = {name = "triton" , aid = 1000},
    [2] = {name = "jaws" , aid = 1001},
    [3] = {name = "aegaeus" , aid = 1002},
    [4] = {name = "kraken" , aid = 1003}
}

local effects = {
    [1] = {28, 210},
    [2] = {29, 180},
    [3] = {30, 45}
}

function onUse(cid, item, frompos, item2, topos)
    if item.itemid == 5928 then
        if getTilePzInfo(getPlayerPosition(cid)) then
            return doPlayerSendCancel(cid, "You cannot capture monsters in protection zone.")
        end
        local MONS = nil
        for i = 1, #monsters do
            if monsters[i].name == getCreatureName(item2.uid):lower() then
                MONS = monsters[i]
                break
            end
        end
        if not MONS then
            return doPlayerSendCancel(cid, "You cannot capture this monster.")
        end
        local EFF = effects[math.random(1, 3)]
        if not EFF then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        if releasedMonsters[item2.uid] and releasedMonsters[item2.uid] ~= getPlayerGUID(cid) then
            return doPlayerSendCancel(cid, "This monster is not yours to catch.")
        end
        doItemSetAttribute(item.uid, "description", "It contains a: "..getCreatureName(item2.uid)..".")
        doItemSetAttribute(item.uid, "aid", MONS.aid)
        if releasedMonsters[item2.uid] then
            releasedMonsters[item2.uid] = nil
        end
        doRemoveCreature(item2.uid)
        doSendMagicEffect(topos, EFF[1])
        doSendAnimatedText(topos, 'Captured!', EFF[2])
        doTransformItem(item.uid, 5929)
    elseif item.itemid == 5929 then
        if getTilePzInfo(getPlayerPosition(cid))
        then
            return doPlayerSendCancel(cid, "You cannot release monsters in protection zone.")
        end
        local MONS = nil
        for i = 1, #monsters do
            if monsters[i].aid == getItemAttribute(item.uid, "aid") then
                MONS = monsters[i]
                break
            end
        end
        if not MONS then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        local EFF = effects[math.random(1, 3)]
        if not EFF then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        local mons = doCreateMonster(MONS.name, getCreaturePosition(cid))
        if mons then
            releasedMonsters[mons] = getPlayerGUID(cid)
            doSendMagicEffect(getCreaturePosition(mons), EFF[1])
            doSendAnimatedText(getCreaturePosition(mons), 'Released!', EFF[2])
            doRemoveItem(item.uid, 1)
        else
            return doPlayerSendCancel(cid, "Could not release monster.")
        end
    end
    return true
end
 
Try this.
Lua:
local monsters = {
    [1] = {name = "triton" , aid = 1000},
    [2] = {name = "jaws" , aid = 1001},
    [3] = {name = "aegaeus" , aid = 1002},
    [4] = {name = "kraken" , aid = 1003}
}

local effects = {
    [1] = {28, 210},
    [2] = {29, 180},
    [3] = {30, 45}
}

function onUse(cid, item, frompos, item2, topos)
    if item.itemid == 5928 then
        if getTilePzInfo(getPlayerPosition(cid)) then
            return doPlayerSendCancel(cid, "You cannot capture monsters in protection zone.")
        end
        if not isCreature(item2.uid) then
            return
        end
        local MONS = nil
        for i = 1, #monsters do
            if monsters[i].name == getCreatureName(item2.uid):lower() then
                MONS = monsters[i]
                break
            end
        end
        if not MONS then
            return doPlayerSendCancel(cid, "You cannot capture this monster. " .. (getCreatureName(item2.uid):lower()))
        end
        local EFF = effects[math.random(1, 3)]
        if not EFF then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        if releasedMonsters[item2.uid] and releasedMonsters[item2.uid] ~= getPlayerGUID(cid) then
            return doPlayerSendCancel(cid, "This monster is not yours to catch.")
        end
        doItemSetAttribute(item.uid, "description", "It contains a: "..getCreatureName(item2.uid)..".")
        doItemSetAttribute(item.uid, "aid", MONS.aid)
        if releasedMonsters[item2.uid] then
            releasedMonsters[item2.uid] = nil
        end
        doRemoveCreature(item2.uid)
        doSendMagicEffect(topos, EFF[1])
        doSendAnimatedText(topos, 'Captured!', EFF[2])
        doTransformItem(item.uid, 5929)
    elseif item.itemid == 5929 then
        if getTilePzInfo(getPlayerPosition(cid))
        then
            return doPlayerSendCancel(cid, "You cannot release monsters in protection zone.")
        end
        local MONS = nil
        for i = 1, #monsters do
            if monsters[i].aid == getItemAttribute(item.uid, "aid") then
                MONS = monsters[i]
                break
            end
        end
        if not MONS then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        local EFF = effects[math.random(1, 3)]
        if not EFF then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        local mons = doCreateMonster(MONS.name, getCreaturePosition(cid))
        if mons then
            releasedMonsters[mons] = getPlayerGUID(cid)
            doSendMagicEffect(getCreaturePosition(mons), EFF[1])
            doSendAnimatedText(getCreaturePosition(mons), 'Released!', EFF[2])
            doRemoveItem(item.uid, 1)
        else
            return doPlayerSendCancel(cid, "Could not release monster.")
        end
    end
    return true
end
 

Attachments

@josesaucedo

Try
Lua:
local monsters = {
    [1] = {name = "triton" , aid = 1000},
    [2] = {name = "jaws" , aid = 1001},
    [3] = {name = "aegaeus" , aid = 1002},
    [4] = {name = "kraken" , aid = 1003}
}

local effects = {
    [1] = {28, 210},
    [2] = {29, 180},
    [3] = {30, 45}
}

releasedMonsters = {}

function onUse(cid, item, frompos, item2, topos)
    if item.itemid == 5928 then
        if getTilePzInfo(getPlayerPosition(cid)) then
            return doPlayerSendCancel(cid, "You cannot capture monsters in protection zone.")
        end
        local MONS = nil
        for i = 1, #monsters do
            if monsters[i].name == getCreatureName(item2.uid):lower() then
                MONS = monsters[i]
                break
            end
        end
        if not MONS then
            return doPlayerSendCancel(cid, "You cannot capture this monster.")
        end
        local EFF = effects[math.random(1, 3)]
        if not EFF then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        if releasedMonsters[item2.uid] and releasedMonsters[item2.uid] ~= getPlayerGUID(cid) then
            return doPlayerSendCancel(cid, "This monster is not yours to catch.")
        end
        doItemSetAttribute(item.uid, "description", "It contains a: "..getCreatureName(item2.uid)..".")
        doItemSetAttribute(item.uid, "aid", MONS.aid)
        if releasedMonsters[item2.uid] then
            releasedMonsters[item2.uid] = nil
        end
        doRemoveCreature(item2.uid)
        doSendMagicEffect(topos, EFF[1])
        doSendAnimatedText(topos, 'Captured!', EFF[2])
        doTransformItem(item.uid, 5929)
    elseif item.itemid == 5929 then
        if getTilePzInfo(getPlayerPosition(cid))
        then
            return doPlayerSendCancel(cid, "You cannot release monsters in protection zone.")
        end
        local MONS = nil
        for i = 1, #monsters do
            if monsters[i].aid == getItemAttribute(item.uid, "aid") then
                MONS = monsters[i]
                break
            end
        end
        if not MONS then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        local EFF = effects[math.random(1, 3)]
        if not EFF then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        local mons = doCreateMonster(MONS.name, getCreaturePosition(cid))
        if mons then
            releasedMonsters[mons] = getPlayerGUID(cid)
            doSendMagicEffect(getCreaturePosition(mons), EFF[1])
            doSendAnimatedText(getCreaturePosition(mons), 'Released!', EFF[2])
            doRemoveItem(item.uid, 1)
        else
            return doPlayerSendCancel(cid, "Could not release monster.")
        end
    end
    return true
end
 
Solution
@josesaucedo

Try
Lua:
local monsters = {
    [1] = {name = "triton" , aid = 1000},
    [2] = {name = "jaws" , aid = 1001},
    [3] = {name = "aegaeus" , aid = 1002},
    [4] = {name = "kraken" , aid = 1003}
}

local effects = {
    [1] = {28, 210},
    [2] = {29, 180},
    [3] = {30, 45}
}

releasedMonsters = {}

function onUse(cid, item, frompos, item2, topos)
    if item.itemid == 5928 then
        if getTilePzInfo(getPlayerPosition(cid)) then
            return doPlayerSendCancel(cid, "You cannot capture monsters in protection zone.")
        end
        local MONS = nil
        for i = 1, #monsters do
            if monsters[i].name == getCreatureName(item2.uid):lower() then
                MONS = monsters[i]
                break
            end
        end
        if not MONS then
            return doPlayerSendCancel(cid, "You cannot capture this monster.")
        end
        local EFF = effects[math.random(1, 3)]
        if not EFF then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        if releasedMonsters[item2.uid] and releasedMonsters[item2.uid] ~= getPlayerGUID(cid) then
            return doPlayerSendCancel(cid, "This monster is not yours to catch.")
        end
        doItemSetAttribute(item.uid, "description", "It contains a: "..getCreatureName(item2.uid)..".")
        doItemSetAttribute(item.uid, "aid", MONS.aid)
        if releasedMonsters[item2.uid] then
            releasedMonsters[item2.uid] = nil
        end
        doRemoveCreature(item2.uid)
        doSendMagicEffect(topos, EFF[1])
        doSendAnimatedText(topos, 'Captured!', EFF[2])
        doTransformItem(item.uid, 5929)
    elseif item.itemid == 5929 then
        if getTilePzInfo(getPlayerPosition(cid))
        then
            return doPlayerSendCancel(cid, "You cannot release monsters in protection zone.")
        end
        local MONS = nil
        for i = 1, #monsters do
            if monsters[i].aid == getItemAttribute(item.uid, "aid") then
                MONS = monsters[i]
                break
            end
        end
        if not MONS then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        local EFF = effects[math.random(1, 3)]
        if not EFF then
            return doPlayerSendCancel(cid, "Please report this error to the gamemaster.")
        end
        local mons = doCreateMonster(MONS.name, getCreaturePosition(cid))
        if mons then
            releasedMonsters[mons] = getPlayerGUID(cid)
            doSendMagicEffect(getCreaturePosition(mons), EFF[1])
            doSendAnimatedText(getCreaturePosition(mons), 'Released!', EFF[2])
            doRemoveItem(item.uid, 1)
        else
            return doPlayerSendCancel(cid, "Could not release monster.")
        end
    end
    return true
end
Uff friend, if you can, you are incredible, thank you very much
 

Similar threads

Back
Top