Ir para conteúdo

Featured Replies

Postado

Boa tarde

 

 

Uso em meu server de tibia um sistema de pescar alguns bichos e também tem a opção de capturar só que o que acontece, o script de capturar não captura apenas os monstros que o player pesca, ele captura todos os monstros do server. Então, precisaria de duas coisas nessa script:

 

1° Que o monstro só possa ser capturado por quem o pescou. Ex: Vanish pescou um Dragon, em cima do Dragon tem que aparecer que foi pego por Vanish e só o Vanish pode captura-ló.

 

2° No server só podem ser pescados os monstros que eu coloco no script de fishing do OT, então o script de captura deve capturar somente os que estão descritos na script de fishing e os demais do server não, deve aparecer 'You cannot catch it.'

 

Script do item que captura \/

function onUse(cid, item, frompos, item2, topos)
local r = {
 [28] = 210,
 [29] = 180,
 [30] = 45}
local s = math.random(28,30) 
if item.itemid == 5928 then
   if getTilePzInfo(getThingPos(cid)) == FALSE then
      if isMonster(item2.uid) == TRUE then
         setItemArticle(item.uid, getCreatureName(item2.uid))
         doRemoveCreature(item2.uid)
         doSendMagicEffect(topos, s)
         doSendAnimatedText(topos, 'Capitured!', r[s])  
         doTransformItem(item.uid, 5929)
         return TRUE
      else
         doSendMagicEffect(frompos, 2)
         doPlayerSendCancel(cid, 'You cannot catch it.')
         return TRUE
      end
      return TRUE
   else
      doPlayerSendCancel(cid, 'You cannot use in protection zone.')
      doSendMagicEffect(frompos, 2)
      return TRUE
   end
elseif item.itemid == 5929 then
     if getTilePzInfo(getThingPos(cid)) == FALSE then
          doCreateMonster(getItemDescriptions(item.uid).article, getThingPos(cid))
          return doRemoveItem(item.uid, 1)
     else
          return doPlayerSendCancel(cid, 'You cannot use in protection zone.')
     end         
end
return TRUE                                                          
end

 

Script do sistema de pesca \/

 

local configg = {
    waterIds = {493, 4608, 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 4820, 4821, 4822, 4823, 4824, 4825}
    }
local monsters = {
    {'rat'},
    {'dragon'},

}
local numero = 2 -- numero de monstros que você colocou /\
local segundos = 2
local storage = 123456
local number = 1 -- < quanto maior, mais dificil de pescar um monstro 175000
local config = {
    rateSkill = getConfigValue("rateSkill"),
    allowFromPz = false,
    useWorms = false
}
function onUse(cid, item, frompos, item2, topos)
if getPlayerStorageValue(cid, storage) <= os.time() then
    setPlayerStorageValue(cid, storage, os.time() + segundos)

    local chance = math.random(1,numero+number) --
    if chance >= 1 and chance <= numero then
    create = monsters[chance][1]
    doSummonCreature(create, getCreaturePosition(cid))
    doSendMagicEffect(topos, 11)
    doCreatureSay(cid, "A Big Monster Has Become Very Disgruntled Due To You !", TEXTCOLOR_BLUE)
    
    else
    doSendMagicEffect(topos, CONST_ME_LOSEENERGY)
    end
    if((config.allowFromPz or not getTileInfo(getCreaturePosition(cid)).protection) and item2.itemid ~= 493 and
        math.random(1, (100 + (getPlayerSkill(cid, SKILL_FISHING) / 10))) < getPlayerSkill(cid, SKILL_FISHING) and
        (not config.useWorms or (getPlayerItemCount(cid, ITEM_WORM) > 0 and doPlayerRemoveItem(cid, ITEM_WORM, 1)))) then
        doPlayerAddSkillTry(cid, SKILL_FISHING, config.rateSkill)
        doSendMagicEffect(topos, CONST_ME_LOSEENERGY)
    else
    doSendMagicEffect(topos, CONST_ME_LOSEENERGY)
    end
else
doPlayerSendCancel(cid, "You're exhausted.")
end    
    return true
end

  • Respostas 5
  • Visualizações 834
  • Created
  • Última resposta

Top Posters In This Topic

Postado

@Infused

De forma simples, use assim: (Não tive como testar)

 

Para o sistema de pesca:

 

Spoiler

local monsters = {'rat', 'dragon'}
local chanceToFish = 50 -- chance para pescar
local segundos = 2
local storage = 123456

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if itemEx.itemid ~= 493 then return false end
    if getPlayerStorageValue(cid, storage) <= os.time() then
        setPlayerStorageValue(cid, storage, os.time() + segundos)
        if chanceToFish <= math.random(1,100) then
            local m = monsters[math.random(1, #monsters)]
            local monster = doSummonCreature(m, getCreaturePosition(cid))
            doPlayerAddFishedMonster(cid, monster)
            doSendMagicEffect(toPosition, 11)
            doCreatureSay(cid, "A Big Monster Has Become Very Disgruntled Due To You !", TEXTCOLOR_BLUE)
        else
            doSendMagicEffect(toPosition, CONST_ME_LOSEENERGY)
        end
    else
        doPlayerSendCancel(cid, "You're exhausted.")
    end    
    return true
end

function doPlayerAddFishedMonster(cid, monster)
    local t = getPlayerStorageValue(cid, 87663)
    if t == -1 then
        setPlayerStorageValue(cid, 87663, "'"..monster.."',")
    else
        local monsters = string.explode(t:sub(1,-2), ",")
        local check, new = {}, ''
        for i = 1, #monsters do
            local m = monsters[i]:gsub("'","")
            if not isMonster(tonumber(m)) then
                table.insert(check, i)
            end
        end
        if #check > 0 then
            table.sort(check, function(a, b) return a > b end)
            for i = 1, #check do
                table.remove(monsters, check[i])
            end
        end
        table.insert(monsters, "'"..monster.."'")
        for i = 1, #monsters do
            new = new..""..monsters[i]..","
        end
        setPlayerStorageValue(cid, 87663, new)
    end
    return true
end

 

 

 

Para o item que captura:

 

Spoiler

local colors = {210, 180, 45}
local effects = {28, 29, 30}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local p = getPlayerPosition(cid)
    if getTilePzInfo(p) then
        doPlayerSendDefaultCancel(cid, RETURNVALUE_ACTIONNOTPERMITTEDINPROTECTIONZONE)
        doSendMagicEffect(p, 2)
        return true
    end
    if item.itemid == 5928 then
        if not isMonster(itemEx.uid) then
            doPlayerSendCancel(cid, "You can not catch it.")
            doSendMagicEffect(p, 2)
            return true
        end
        if not isMonsterFished(cid, itemEx.uid) then
            doPlayerSendCancel(cid, "This "..getCreatureName(itemEx.uid).." was not fished by you.")
            doSendMagicEffect(p, 2)
            return true
        end
        local mname = getCreatureName(itemEx.uid)
        doItemSetAttribute(item.uid, "monster", mname)
        local desc = getItemAttribute(item.uid, "description")
        local newdesc = "It contains "..getArticle(mname).." "..mname.."."
        doItemSetAttribute(item.uid, "description", (desc and desc:len() > 0) and desc.."\n"..newdesc or newdesc)
        doRemoveCreature(itemEx.uid)
        doSendMagicEffect(toPosition, effects[math.random(1, #effects)])
        doSendAnimatedText(toPosition, "Captured!", colors[math.random(1, #colors)])
        doTransformItem(item.uid, 5929)
    elseif item.itemid == 5929 then
        local mname = getItemAttribute(item.uid, "monster")
        if not mname then
            doPlayerSendCancel(cid, "You have not catched a monster yet.")
            return true
        end
        local monster = doCreateMonster(mname, p)
        doCreatureSay(monster, "I'm back!", TALKTYPE_ORANGE_1)
        doSendMagicEffect(getCreaturePosition(monster), 10)
        doRemoveItem(item.uid)      
    end         
    return true                                                          
end

function isMonsterFished(cid, monster)
    local t = getPlayerStorageValue(cid, 87663)
    if t == -1 then return false end
    local monsters = string.explode(t:sub(1,-2):gsub("'",""), ",")
    if isInArray(monsters, monster) then
        return true
    end
    return false
end

 

 

Lembrando que não coloquei para aparecer o nome de quem pescou em cima do nome, pois você tem que ter a função que troca o nome do monstro. Procure aqui no mesmo TK e adicione-a ao seu servidor.

 

Contato:

 

Postado
  • Autor

@Dwarfer vou testar amanhã cedo, to sem internet em casa.

 

Duas dúvidas, consigo adicionar mais monstros?

 

Sobre aparecer o nome de quem pescou, poderia me mostrar como faço? Sou leigo em script e não entendi muito bem o que tenho que procurar. 

 

Assim que testar comento aqui.

 

9 minutos atrás, Dwarfer disse:

@Infused

De forma simples, use assim: (Não tive como testar)

 

Para o sistema de pesca:

 

  Mostrar conteúdo oculto


local monsters = {'rat', 'dragon'}
local chanceToFish = 50 -- chance para pescar
local segundos = 2
local storage = 123456

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if itemEx.itemid ~= 493 then return false end
    if getPlayerStorageValue(cid, storage) <= os.time() then
        setPlayerStorageValue(cid, storage, os.time() + segundos)
        if chanceToFish <= math.random(1,100) then
            local m = monsters[math.random(1, #monsters)]
            local monster = doSummonCreature(m, getCreaturePosition(cid))
            doPlayerAddFishedMonster(cid, monster)
            doSendMagicEffect(toPosition, 11)
            doCreatureSay(cid, "A Big Monster Has Become Very Disgruntled Due To You !", TEXTCOLOR_BLUE)
        else
            doSendMagicEffect(toPosition, CONST_ME_LOSEENERGY)
        end
    else
        doPlayerSendCancel(cid, "You're exhausted.")
    end    
    return true
end

function doPlayerAddFishedMonster(cid, monster)
    local t = getPlayerStorageValue(cid, 87663)
    if t == -1 then
        setPlayerStorageValue(cid, 87663, "'"..monster.."',")
    else
        local monsters = string.explode(t:sub(1,-2), ",")
        local check, new = {}, ''
        for i = 1, #monsters do
            local m = monsters[i]:gsub("'","")
            if not isMonster(tonumber(m)) then
                table.insert(check, i)
            end
        end
        if #check > 0 then
            table.sort(check, function(a, b) return a > b end)
            for i = 1, #check do
                table.remove(monsters, check[i])
            end
        end
        table.insert(monsters, "'"..monster.."'")
        for i = 1, #monsters do
            new = new..""..monsters[i]..","
        end
        setPlayerStorageValue(cid, 87663, new)
    end
    return true
end

 

 

 

Para o item que captura:

 

  Mostrar conteúdo oculto


local colors = {210, 180, 45}
local effects = {28, 29, 30}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local p = getPlayerPosition(cid)
    if getTilePzInfo(p) then
        doPlayerSendDefaultCancel(cid, RETURNVALUE_ACTIONNOTPERMITTEDINPROTECTIONZONE)
        doSendMagicEffect(p, 2)
        return true
    end
    if item.itemid == 5928 then
        if not isMonster(itemEx.uid) then
            doPlayerSendCancel(cid, "You can not catch it.")
            doSendMagicEffect(p, 2)
            return true
        end
        if not isMonsterFished(cid, itemEx.uid) then
            doPlayerSendCancel(cid, "This "..getCreatureName(itemEx.uid).." was not fished by you.")
            doSendMagicEffect(p, 2)
            return true
        end
        local mname = getCreatureName(itemEx.uid)
        doItemSetAttribute(item.uid, "monster", mname)
        local desc = getItemAttribute(item.uid, "description")
        local newdesc = "It contains "..getArticle(mname).." "..mname.."."
        doItemSetAttribute(item.uid, "description", (desc and desc:len() > 0) and desc.."\n"..newdesc or newdesc)
        doRemoveCreature(itemEx.uid)
        doSendMagicEffect(toPosition, effects[math.random(1, #effects)])
        doSendAnimatedText(toPosition, "Captured!", colors[math.random(1, #colors)])
        doTransformItem(item.uid, 5929)
    elseif item.itemid == 5929 then
        local mname = getItemAttribute(item.uid, "monster")
        if not mname then
            doPlayerSendCancel(cid, "You have not catched a monster yet.")
            return true
        end
        local monster = doCreateMonster(mname, p)
        doCreatureSay(monster, "I'm back!", TALKTYPE_ORANGE_1)
        doSendMagicEffect(getCreaturePosition(monster), 10)
        doRemoveItem(item.uid)      
    end         
    return true                                                          
end

function isMonsterFished(cid, monster)
    local t = getPlayerStorageValue(cid, 87663)
    if t == -1 then return false end
    local monsters = string.explode(t:sub(1,-2):gsub("'",""), ",")
    if isInArray(monsters, monster) then
        return true
    end
    return false
end

 

 

Lembrando que não coloquei para aparecer o nome de quem pescou em cima do nome, pois você tem que ter a função que troca o nome do monstro. Procure aqui no mesmo TK e adicione-a ao seu servidor.

 

 

@Dwarfer não pescou cara.

Postado
12 horas atrás, Infused disse:

Duas dúvidas, consigo adicionar mais monstros?

 

Sim, é só adicionar os nomes dos monstros nessa linha:

local monsters = {'rat', 'dragon'}

 

12 horas atrás, Infused disse:

Sobre aparecer o nome de quem pescou, poderia me mostrar como faço? Sou leigo em script e não entendi muito bem o que tenho que procurar. 

 

Procure a função setCreatureName ou semelhante (caso não tenha) e adicione à source do seu servidor. Depois compile e aí será possível trocar de nome.

 

12 horas atrás, Infused disse:

@Dwarfer não pescou cara.

 

Eu tinha colocado para pescar somente no id de água igual a 493, já que a parte dos ids de água ali no seu script não servia para nada assim como outras coisas desnecessárias. Se você testar com o id 493 vai funcionar corretamente. Se quiser que funcione com todos os ids configurados em waterIds, utilize assim:

 

Spoiler

local monsters = {'rat', 'dragon'}
local chanceToFish = 50 -- chance para pescar
local waterIds = {493, 4608, 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 4820, 4821, 4822, 4823, 4824, 4825}
local segundos = 2
local storage = 123456

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if not isInArray(waterIds, itemEx.itemid) then return false end
    if getPlayerStorageValue(cid, storage) <= os.time() then
        setPlayerStorageValue(cid, storage, os.time() + segundos)
        if chanceToFish <= math.random(1,100) then
            local m = monsters[math.random(1, #monsters)]
            local monster = doSummonCreature(m, getCreaturePosition(cid))
            doPlayerAddFishedMonster(cid, monster)
            doSendMagicEffect(toPosition, 11)
            doCreatureSay(cid, "A Big Monster Has Become Very Disgruntled Due To You !", TEXTCOLOR_BLUE)
        else
            doSendMagicEffect(toPosition, CONST_ME_LOSEENERGY)
        end
    else
        doPlayerSendCancel(cid, "You're exhausted.")
    end    
    return true
end

function doPlayerAddFishedMonster(cid, monster)
    local t = getPlayerStorageValue(cid, 87663)
    if t == -1 then
        setPlayerStorageValue(cid, 87663, "'"..monster.."',")
    else
        local monsters = string.explode(t:sub(1,-2), ",")
        local check, new = {}, ''
        for i = 1, #monsters do
            local m = monsters[i]:gsub("'","")
            if not isMonster(tonumber(m)) then
                table.insert(check, i)
            end
        end
        if #check > 0 then
            table.sort(check, function(a, b) return a > b end)
            for i = 1, #check do
                table.remove(monsters, check[i])
            end
        end
        table.insert(monsters, "'"..monster.."'")
        for i = 1, #monsters do
            new = new..""..monsters[i]..","
        end
        setPlayerStorageValue(cid, 87663, new)
    end
    return true
end

 

 

 

 

 

Contato:

 

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Conteúdo Similar

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo