Ir para conteúdo

Featured Replies

Postado

base: 1.2

Bom dia pessoal do tibia king! Gente teriam como me ajudar com um "bau inteligente"?

Tipo ele vai funcionar da seguinte maneira:

preciso de um bau que irá da itens de acordo com a  vocação, ele vai da uma backpack para o player contendo itens dentro dela (não sei quantos itens irão ser então se possível deixa de uma forma que eu possa adicionar quantos eu precisar), alem dos itens ele vai da um bônus de experiencia o bônus pode ser a mesma configuração para todas as vocações, somente os itens deverão ser separados por vocações, se possível colocar um efeito quando o player clicar junto com uma mensagem(o efeito e a mensagem pode ser o mesmo para todas as vocações), apos o processo ser realizado caso o player venha clicar novamente no bau aparecerá uma nova mensagem dizendo que ele só irá poder pegar os itens novamente depois de 24 horas, logo ele não poderá pegar o bônus de experiencia, somente os itens.


OBS: Espero que tenha ficado bem explicado, mas qualquer duvido e só postar que eu tentarei tirá-la o mais rápido possível, eu mesmo tentei reproduzir esse script, mas não obtive muito sucesso. :(

 

 

 



Aliás agradeço desde já a boa alma que for me ajudar e claro! Nunca esquecerei do REP+ ?

Resolvido por Dwarfer

Ir para solução
  • Respostas 10
  • Visualizações 1k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • @Navegante   Em actions/scripts crie um arquivo.lua e cole isto dentro:     No actions.xml, coloque a tag como o exemplo abaixo, inserindo um actionid no lugar do XXXX e o m

Posted Images

Postado
  • Solução

@Navegante

 

Em actions/scripts crie um arquivo.lua e cole isto dentro:

 

Spoiler

local t = {
    backpack_id = 1988, -- id da backpack
    experience = 1000, -- quantidade de experiência adicionada
    effect = CONST_ME_FIREAREA, -- efeito
    msg = "Congratulations! You have received your reward.", -- mensagem
    time_to_get_again = {24, "hour"},  -- tempo para poder abrir novamente, use 'sec', 'min', 'hour', 'day'
    storage = 78660, -- só modifique se necessário
    voc_items = {
        [{1,2}] = {{1111, 10}, {2222, 3}}, -- [{ids das vocações}] = {id do item, quantidade}
        [{3,4}] = {{1111, 10}, {2222, 3}},
        [{5,6}] = {{1111, 10}, {2222, 3}}
    }
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getStorageValue(t.storage) > os.time() then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can take the reward again at "..os.date("%d %B %Y %X", player:getStorageValue(t.storage))..".")
        return true
    end
    local tab = {}
    for voc_tab, items in pairs(t.voc_items) do
        if isInArray(voc_tab, player:getVocation():getId()) then
            tab = items
            break
        end
    end
    if #tab == 0 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your vocation is not allowed to get the reward.")
        return true
    end
    local bp = Container(doCreateItemEx(t.backpack_id, 1))
    for i = 1, #tab do
        local id, count = tab[i][1], tab[i][2]
        if ItemType(id):isStackable() then
            bp:addItem(id, count)
        else
            for k = 1, count do
                bp:addItem(id, 1)
            end
        end
    end
    local bpWeight = bp:getWeight()
    if player:getFreeCapacity() < bpWeight then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have found a ' .. ItemType(t.backpack_id):getName() .. ' weighing ' .. bpWeight .. ' oz it\'s too heavy.')
        return true
    end
    if player:getStorageValue(t.storage) == -1 then
        player:addExperience(t.experience, true)
    end
    player:addItemEx(bp)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, t.msg)
    player:getPosition():sendMagicEffect(t.effect)
    player:setStorageValue(t.storage, mathtime(t.time_to_get_again) + os.time())
    return true
end

function mathtime(table) -- by dwarfer
local unit = {"sec", "min", "hour", "day"}
for i, v in pairs(unit) do
if v == table[2] then
return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1)
end
end
return error("Bad declaration in mathtime function.")
end

 

 

No actions.xml, coloque a tag como o exemplo abaixo, inserindo um actionid no lugar do XXXX e o mesmo valor para o actionid do baú.

<action actionid="XXXX" script="NOMEDOSEUARQUIVO.lua"/>

 

Contato:

 

Postado
2 horas atrás, Dwarfer disse:

@Navegante

 

Em actions/scripts crie um arquivo.lua e cole isto dentro:

 

  Ocultar conteúdo


local t = {
    backpack_id = 1988, -- id da backpack
    experience = 1000, -- quantidade de experiência adicionada
    effect = CONST_ME_FIREAREA, -- efeito
    msg = "Congratulations! You have received your reward.", -- mensagem
    time_to_get_again = {24, "hour"},  -- tempo para poder abrir novamente, use 'sec', 'min', 'hour', 'day'
    storage = 78660, -- só modifique se necessário
    voc_items = {
        [{1,2}] = {{1111, 10}, {2222, 3}}, -- [{ids das vocações}] = {id do item, quantidade}
        [{3,4}] = {{1111, 10}, {2222, 3}},
        [{5,6}] = {{1111, 10}, {2222, 3}}
    }
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getStorageValue(t.storage) > os.time() then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can take the reward again at "..os.date("%d %B %Y %X", player:getStorageValue(t.storage))..".")
        return true
    end
    local tab = {}
    for voc_tab, items in pairs(t.voc_items) do
        if isInArray(voc_tab, player:getVocation():getId()) then
            tab = items
            break
        end
    end
    if #tab == 0 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your vocation is not allowed to get the reward.")
        return true
    end
    local bp = Container(doCreateItemEx(t.backpack_id, 1))
    for i = 1, #tab do
        local id, count = tab[i][1], tab[i][2]
        if ItemType(id):isStackable() then
            bp:addItem(id, count)
        else
            for k = 1, count do
                bp:addItem(id, 1)
            end
        end
    end
    local bpWeight = bp:getWeight()
    if player:getFreeCapacity() < bpWeight then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have found a ' .. ItemType(t.backpack_id):getName() .. ' weighing ' .. bpWeight .. ' oz it\'s too heavy.')
        return true
    end
    if player:getStorageValue(t.storage) == -1 then
        player:addExperience(t.experience, true)
    end
    player:addItemEx(bp)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, t.msg)
    player:getPosition():sendMagicEffect(t.effect)
    player:setStorageValue(t.storage, mathtime(t.time_to_get_again) + os.time())
    return true
end

function mathtime(table) -- by dwarfer
local unit = {"sec", "min", "hour", "day"}
for i, v in pairs(unit) do
if v == table[2] then
return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1)
end
end
return error("Bad declaration in mathtime function.")
end

 

 

No actions.xml, coloque a tag como o exemplo abaixo, inserindo um actionid no lugar do XXXX e o mesmo valor para o actionid do baú.


<action actionid="XXXX" script="NOMEDOSEUARQUIVO.lua"/>

 

 

tem como modificar pra tfs 0.4? se tiver agradeço parabéns pelo o script <3 

Citar

[23:46:52.555] [Error - Action Interface]
[23:46:52.555] data/actions/scripts/BauHoras.lua:onUse
[23:46:52.571] Description:
[23:46:52.571] data/actions/scripts/BauHoras.lua:16: attempt to index local 'player' (a number value)
[23:46:52.571] stack traceback:
[23:46:52.571]  data/actions/scripts/BauHoras.lua:16: in function <data/actions/scripts/BauHoras.lua:15>

 

Postado
  • Autor
4 horas atrás, Dwarfer disse:

@Navegante

 

Em actions/scripts crie um arquivo.lua e cole isto dentro:

 

  Mostrar conteúdo oculto


local t = {
    backpack_id = 1988, -- id da backpack
    experience = 1000, -- quantidade de experiência adicionada
    effect = CONST_ME_FIREAREA, -- efeito
    msg = "Congratulations! You have received your reward.", -- mensagem
    time_to_get_again = {24, "hour"},  -- tempo para poder abrir novamente, use 'sec', 'min', 'hour', 'day'
    storage = 78660, -- só modifique se necessário
    voc_items = {
        [{1,2}] = {{1111, 10}, {2222, 3}}, -- [{ids das vocações}] = {id do item, quantidade}
        [{3,4}] = {{1111, 10}, {2222, 3}},
        [{5,6}] = {{1111, 10}, {2222, 3}}
    }
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getStorageValue(t.storage) > os.time() then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can take the reward again at "..os.date("%d %B %Y %X", player:getStorageValue(t.storage))..".")
        return true
    end
    local tab = {}
    for voc_tab, items in pairs(t.voc_items) do
        if isInArray(voc_tab, player:getVocation():getId()) then
            tab = items
            break
        end
    end
    if #tab == 0 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your vocation is not allowed to get the reward.")
        return true
    end
    local bp = Container(doCreateItemEx(t.backpack_id, 1))
    for i = 1, #tab do
        local id, count = tab[i][1], tab[i][2]
        if ItemType(id):isStackable() then
            bp:addItem(id, count)
        else
            for k = 1, count do
                bp:addItem(id, 1)
            end
        end
    end
    local bpWeight = bp:getWeight()
    if player:getFreeCapacity() < bpWeight then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have found a ' .. ItemType(t.backpack_id):getName() .. ' weighing ' .. bpWeight .. ' oz it\'s too heavy.')
        return true
    end
    if player:getStorageValue(t.storage) == -1 then
        player:addExperience(t.experience, true)
    end
    player:addItemEx(bp)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, t.msg)
    player:getPosition():sendMagicEffect(t.effect)
    player:setStorageValue(t.storage, mathtime(t.time_to_get_again) + os.time())
    return true
end

function mathtime(table) -- by dwarfer
local unit = {"sec", "min", "hour", "day"}
for i, v in pairs(unit) do
if v == table[2] then
return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1)
end
end
return error("Bad declaration in mathtime function.")
end

 

 

No actions.xml, coloque a tag como o exemplo abaixo, inserindo um actionid no lugar do XXXX e o mesmo valor para o actionid do baú.


<action actionid="XXXX" script="NOMEDOSEUARQUIVO.lua"/>

 

Amigo, eu ainda não tiver oportunidade de testar o script, mas amanha a tarde eu irei testa-lo com toda certeza! Já vou deixando o meu obrigado e REP+ pela ajuda no tópico. :)

Muito obrigado!!!!

Postado
19 horas atrás, ADM Mayk on BaiakME disse:

tem como modificar pra tfs 0.4? se tiver agradeço parabéns pelo o script <3 

 

Spoiler

local t = {
    backpack_id = 1988, -- id da backpack
    experience = 1000, -- quantidade de experiência adicionada
    effect = CONST_ME_FIREAREA, -- efeito
    msg = "Congratulations! You have received your reward.", -- mensagem
    time_to_get_again = {24, "hour"},  -- tempo para poder abrir novamente, use 'sec', 'min', 'hour', 'day'
    storage = 78660, -- só modifique se necessário
    voc_items = {
        [{1,2}] = {{1111, 10}, {2222, 3}}, -- [{ids das vocações}] = {id do item, quantidade}
        [{3,4}] = {{1111, 10}, {2222, 3}},
        [{5,6}] = {{1111, 10}, {2222, 3}}
    }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, t.storage) > os.time() then
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You can take the reward again at "..os.date("%d %B %Y %X", getPlayerStorageValue(cid, t.storage))..".")
        return true 
    end
    local tab = {}
    for voc_tab, items in pairs(t.voc_items) do
        if isInArray(voc_tab, getPlayerVocation(cid)) then
            tab = items
            break
        end
    end
    if #tab == 0 then
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Your vocation is not allowed to get the reward.")
        return true
    end
    local bp = doCreateItemEx(t.backpack_id, 1)
    for i = 1, #tab do
        local id, count = tab[i][1], tab[i][2]
        if isItemStackable(id) then
            doAddContainerItem(bp, id, count)
        else
            for k = 1, count do
                doAddContainerItem(bp, id, 1)
            end
        end
    end
    local bpWeight = getItemWeight(bp)
    if getPlayerFreeCap(cid) < bpWeight then
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You have found a " .. getItemNameById(t.backpack_id) .. " weighing " .. bpWeight .. " oz it\'s too heavy.")
        return true
    end
    local p = getPlayerPosition(cid)
    if getPlayerStorageValue(cid, t.storage) == -1 then
        doPlayerAddExperience(cid, t.experience)
        doSendAnimatedText(p, tostring(t.experience), TEXTCOLOR_WHITE)
    end
    doPlayerAddItemEx(cid, bp)
    doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, t.msg)
    doSendMagicEffect(p, t.effect)
    setPlayerStorageValue(cid, t.storage, mathtime(t.time_to_get_again) + os.time())
    return true
end

function mathtime(table) -- by dwarfer
local unit = {"sec", "min", "hour", "day"}
for i, v in pairs(unit) do
if v == table[2] then
return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1)
end
end
return error("Bad declaration in mathtime function.")
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.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo