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