Hello, i have problem, i need add more "vial" reward for catching monster assigned to:
monster 1 vial id: 1680
monster 2 vial id: 1690
monster 3 vial id : 1700 etc
So when we catch monster 1 then we got vial id 1680, when we catch monster 2 then got vial id 1690, can someone help me? please
monster 1 vial id: 1680
monster 2 vial id: 1690
monster 3 vial id : 1700 etc
So when we catch monster 1 then we got vial id 1680, when we catch monster 2 then got vial id 1690, can someone help me? please
Code:
local t = {
percent = 100, -- percent of health which allow to catch a monster
vial = 1680, -- vial which should appear instead empty one.
monsters = {
--['monsterName'] = {min level to catch, chance to catch a monster},
['monster1'] = {1, 100},
['monster2'] = {1, 100},
['monster3'] = {30, 70},
['monster4'] = {50, 100}
}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local desc = getItemAttribute(item.uid, 'description') == nil and getItemInfo(item.itemid).description or getItemAttribute(item.uid, 'description')
if isMonster(itemEx.uid) then
if t.monsters[getCreatureName(itemEx.uid):lower()] then
if getCreatureHealth(itemEx.uid) <= getCreatureMaxHealth(itemEx.uid) * t.percent / 100 then
local desc = getItemAttribute(item.uid, 'description') == nil and getItemInfo(item.itemid).description or getItemAttribute(item.uid, 'description')
if string.find(desc:lower(), 'pact:') == nil then
if getPlayerLevel(cid) < t.monsters[getCreatureName(itemEx.uid):lower()][1] then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You cant get pact with ' .. getCreatureName(itemEx.uid):lower() .. '\'s because you are not enough experienced to do it.')
elseif getCreatureMaster(itemEx.uid) == cid then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You can\'t catch your own summon.')
end
if math.random(1, 100) < t.monsters[getCreatureName(itemEx.uid):lower()][2] then
doSendMagicEffect(toPosition, 111)
local newItem = doPlayerAddItem(cid, t.vial, 1)
doItemSetAttribute(newItem, 'description', desc .. ' Pact with: ' .. getCreatureName(itemEx.uid):lower() .. '.')
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You successful catched ' .. getCreatureName(itemEx.uid):lower() .. '\'s into pact.')
doRemoveCreature(itemEx.uid)
else
doSendMagicEffect(toPosition, 122)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You failed at catching kuchiyose.')
doRemoveCreature(itemEx.uid)
end
doRemoveItem(item.uid)
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You can\'t catch summon two times into same pact.')
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'monster do not have require low health.')
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You can use it only farm monsters.')
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You can use it only on farm monsters.')
end
return true
end