Ir para conteúdo

Aprender spells por comando


TaaG

Posts Recomendados

Essa talkaction serve para que o player execute tal comando para aprender a tal spell se tiver a quantidade certa do item.

 

Exemplo:
!learnspell exori frigo

 

Se quiser usar só uma quantidade de um único item por spell:

 

 

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

Já 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, "Coloque o nome da spell que deseja aprender.")
        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

talkactions.xml (data/talkactions/scripts):

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

Não se esqueça de ativar a obtenção da spell na tag da mesma.

É só mudar o valor, de 0 para 1, onde está escrito needlearn:

needlearn="1"

Créditos: Suicide/Wise

 

 

Editado por TaaG
Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...