• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Catch Summons [Actions] tfs 0.3.6

adamox223

New Member
Joined
Oct 21, 2017
Messages
100
Reaction score
4
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 :)




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
 
Solution
Change this:
LUA:
['monster1'] = {1, 100},
 ['monster2'] = {1, 100},
   ['monster3'] = {30, 70},
  ['monster4'] = {50, 100}

To this:
LUA:
['monster1'] = {1, 100, 1680},
['monster2'] = {1, 100, 1690},
['monster3'] = {30, 70, 1700},       
['monster4'] = {50, 100, 1710}

And this line:
LUA:
32.            local newItem = doPlayerAddItem(cid, t.vial, 1)

To this:
LUA:
32.            local newItem = doPlayerAddItem(cid, t.monsters[getCreatureName(itemEx.uid):lower()][3], 1)
Change this:
LUA:
['monster1'] = {1, 100},
 ['monster2'] = {1, 100},
   ['monster3'] = {30, 70},
  ['monster4'] = {50, 100}

To this:
LUA:
['monster1'] = {1, 100, 1680},
['monster2'] = {1, 100, 1690},
['monster3'] = {30, 70, 1700},       
['monster4'] = {50, 100, 1710}

And this line:
LUA:
32.            local newItem = doPlayerAddItem(cid, t.vial, 1)

To this:
LUA:
32.            local newItem = doPlayerAddItem(cid, t.monsters[getCreatureName(itemEx.uid):lower()][3], 1)
 
Solution
Back
Top