Ir para conteúdo
  • Cadastre-se

(Resolvido)Bau inteligente


Ir para solução Resolvido por Dwarfer,

Posts Recomendados

 

Em 22/08/2018 em 21:18, 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"/>

 

@Dwarfer

até funcionou porem aparece esse erro é desliga o server sozinho

image.png.07aabcaec067722d8f0982eaf9f377c9.png

 

o erro acontece quando eu clicko na backpack pra pega a premiação 

não teria como tirar a backpack ? exemplo clicka no bau é já recebe os items sem precisa de backpack

 

Editado por ADM Mayk on BaiakME
não funcionou totalmente (veja o histórico de edições)
Link para o post
Compartilhar em outros sites
  • 9 months later...
  • Respostas 10
  • Created
  • Última resposta

Top Posters In This Topic

Top Posters In This Topic

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 mesmo valor para o actionid do baú. <action actionid="XXXX" script="NOMEDOSEUARQUIVO.lua"/>  

Posted Images

Em 23/08/2018 em 19:11, Dwarfer disse:

 

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

 

 

 

lamento por reviver o tópico mais poderia me ajudar dwarfer ? estou precisando muito 

Link para o post
Compartilhar em outros sites
5 horas atrás, ADM Mayk on BaiakME disse:

lamento por reviver o tópico mais poderia me ajudar dwarfer ? estou precisando muito 

 

diga, talvez eu possa

O rei de seu proprio destino é aquele que luta pela gloria do amanhã!
Discord : ZoR#9373


 

Link para o post
Compartilhar em outros sites
Em 21/06/2019 em 01:32, ZikaLord disse:

diga, talvez eu possa

 

até funcionou porem aparece esse erro é desliga o server sozinho

image.png.07aabcaec067722d8f0982eaf9f377c9.png

 

o erro acontece quando eu clicko na backpack pra pega a premiação 

não teria como tirar a backpack ? exemplo clicka no bau é já recebe os items sem precisa de backpack

Link para o post
Compartilhar em outros sites
5 horas atrás, ADM Mayk on BaiakME disse:

até funcionou porem aparece esse erro é desliga o server sozinho

image.png.07aabcaec067722d8f0982eaf9f377c9.png

 

o erro acontece quando eu clicko na backpack pra pega a premiação 

não teria como tirar a backpack ? exemplo clicka no bau é já recebe os items sem precisa de backpack

 

qual script você tá usando?

O rei de seu proprio destino é aquele que luta pela gloria do amanhã!
Discord : ZoR#9373


 

Link para o post
Compartilhar em outros sites

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

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

  • Estatísticas dos Fóruns

    96850
    Tópicos
    519614
    Posts



×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo