Ir para conteúdo

Featured Replies

Postado

Essa talkaction consiste em fazer com que o player que possui determinada quantidade de um item, aprenda uma spell em troca do mesmo.


Exemplo de uso (do parâmetro):

!learnspell exori frigo



Se preferir apenas uma determinada quantidade de um único item por spell:


learnspell.lua (data/talkactions/scripts):

local tab = {
["exori frigo"] = {spell = "Ice Strike", item = {1234, 5}}, -- ["nome da spell"] = {spell = "nome da conjuração da spell", item = {itemid, quantidade}},
["exori mort"] = {spell = "Death Strike", item = {1234, 5}},
["exori vis"] = {spell = "Energy Strike", item = {1234, 5}},
["exori flam"] = {spell = "Flame Strike", item = {1234, 5}},
["exori tera"] = {spell = "Terra Strike", item = {1234, 5}},
["exori san"] = {spell = "Divine Missile", item = {1234, 5}}
}

function onSay(cid, words, param, channel)
    local sparam = string.lower(param)
    
        if(param == "") then
            return doPlayerSendCancel(cid, "Enter the name of the spell you want to learn.")
        end
    
            if not (tab[sparam]) then
                return doPlayerSendCancel(cid, "Spell not found.")
            end
        
        if(getPlayerLearnedInstantSpell(cid, tab[sparam].spell)) then
            return doPlayerSendCancel(cid, "You already have learned this spell.")
        end
        
    if(getPlayerItemCount(cid, tab[sparam].item[1]) >= tab[sparam].item[2]) then
        doPlayerLearnInstantSpell(cid, tab[sparam].spell)
        doPlayerRemoveItem(cid, tab[sparam].item[1], tab[sparam].item[2])
        doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have learned the spell!")
    else
        doPlayerSendCancel(cid, "You need "..tab[sparam].item[2].." "..getItemNameById(tab[sparam].item[1]).." to learn this spell.")
    end
        
    return true
end



 

Se quiser 2 itens por spell, use este script (mesmo arquivo):

local tab = {
["exori frigo"] = {spell = "Ice Strike", item = {1234, 5}, item2 = {5678, 9}}, -- ["nome da spell"] = {spell = "nome da conjuração da spell", item = {itemid, quantidade}, item2 = {itemid, quantidade}}},
["exori mort"] = {spell = "Death Strike", item = {1234, 5}, item2 = {5678, 9}},
["exori vis"] = {spell = "Energy Strike", item = {1234, 5}, item2 = {5678, 9}},
["exori flam"] = {spell = "Flame Strike", item = {1234, 5}, item2 = {5678, 9}},
["exori tera"] = {spell = "Terra Strike", item = {1234, 5}, item2 = {5678, 9}},
["exori san"] = {spell = "Divine Missile", item = {1234, 5}, item2 = {5678, 9}}
}

function onSay(cid, words, param, channel)
    local sparam = string.lower(param)
    
        if(param == "") then
            return doPlayerSendCancel(cid, "Enter the name of the spell you want to learn.")
        end
    
            if not (tab[sparam]) then
                return doPlayerSendCancel(cid, "Spell not found.")
            end
        
        if(getPlayerLearnedInstantSpell(cid, tab[sparam].spell)) then
            return doPlayerSendCancel(cid, "You already have learned this spell.")
        end
        
    if(getPlayerItemCount(cid, tab[sparam].item[1]) >= tab[sparam].item[2] and (getPlayerItemCount(cid, tab[sparam].item2[1]) >= tab[sparam].item2[2])) then
        doPlayerLearnInstantSpell(cid, tab[sparam].spell)
        doPlayerRemoveItem(cid, tab[sparam].item[1], tab[sparam].item[2])
        doPlayerRemoveItem(cid, tab[sparam].item2[1], tab[sparam].item2[2])
        doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have learned the spell!")
    else
        doPlayerSendCancel(cid, "You need "..tab[sparam].item[2].." "..getItemNameById(tab[sparam].item[1]).." and "..tab[sparam].item2[2].." "..getItemNameById(tab[sparam].item2[1]).." to learn this spell.")
    end
        
    return true
end

Se quiser um script com mais de 2 itens para uma spell, peça no tópico que eu faço.




Adicione a tag ao arquivo talkactions.xml (data/talkactions/scripts):

<talkaction words="!learnspell" event="script" value="learnspell.lua"/>


 

Não se esqueça de "ativar" a obtenção da spell, para que os players não aprendam ela ao criar o character.
Basta mudar o valor na tag da spell, para 1, onde está needlearn. Ficando então:

needlearn="1"



Créditos: Suicide.

Editado por Suicide (veja o histórico de edições)

The corrupt fear us.

The honest support us.

The heroic join us.

  • 6 months later...
Postado

Eu queria saber como colocar uma storage pra spell que aprender pra mim poder colocar uma opçao de escolher 1 entre 2 spells sendo impossivel ter as 2 independente dos itens que vc tem

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.7k

Informação Importante

Confirmação de Termo