Ir para conteúdo

-=[TFS]=- 0.4 8.60 USAR MAGIA SE TIVER "X" ITEM QUERO YELLOW GEM QUE QUANDO DA USE ELE USA A MAGIA E SOME YELLOW GEM SE JA USOU A MAGIA AI PRECISA DE OUTRA YELLOW GEM

Featured Replies

Postado

Tenta esse então

 

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
	if item.itemid == 9999 then -- ID DA GEMA QUE AO USAR LANÇA A MAGIA
		local combat = createCombatObject()
		setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_LIFEDRAIN)
		setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_EXPLOSIONHIT)
		setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -1000.0, -1000.0, -1000.0, -1000.0)
		local arr = {
			{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
			{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
			{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
			{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
			{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
			{1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 0},
			{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
			{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
			{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
			{0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0},
		}
		local area = createCombatArea(arr)
			setCombatArea(combat, area)
			doCombat(player.uid, combat, var)
			doSendMagicEffect(getThingPos(player.uid), CONST_ME_POFF)
			player:removeItem(9999, 1) -- ID DA GEMA Q VAI SER REMOVIDA
		else
			doPlayerSendCancel(player.uid, "Você não usou o Crystal de sua vocação ainda!")
		end
	return true
end

 

uma outra alternativa, é mais simples de entender

 

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_LIFEDRAIN)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_EXPLOSIONHIT)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -1000.0, -1000.0, -1000.0, -1000.0)

local arr = {
	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
	{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
	{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
	{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
	{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
	{1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 0},
	{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
	{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
	{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
	{0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0},
}

local area = createCombatArea(arr)
setCombatArea(combat, area)

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local yellowGem = 9999 -- ID da Yellow Gem (pode ser outro ID)
	if getPlayerItemCount(cid, yellowGem) >= 1 then
		doCombat(cid, combat, var)
		doPlayerRemoveItem(cid, yellowGem, 1)
		return true
	else
		doPlayerSendCancel(cid, "Você não tem a Yellow Gem necessária para usar essa habilidade.")
		return false
	end
end

 

  • Respostas 10
  • Visualizações 576
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • vê se isso te ajuda   local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_LIFEDRAIN) setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_EXPLOSIONHIT) setCom

  • Tenta esse então   function onUse(player, item, fromPosition, target, toPosition, isHotkey) if item.itemid == 9999 then -- ID DA GEMA QUE AO USAR LANÇA A MAGIA local combat = createCombatO

Posted Images

Postado


na pasta scripts, que vai estar dentro da pasta actions voce vai criar um yellowgem.lua e colar isso

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_LIFEDRAIN)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_EXPLOSIONHIT)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -1000.0, -1000.0, -1000.0, -1000.0)

local arr = {
	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
	{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
	{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
	{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
	{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
	{1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 0},
	{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
	{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
	{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
	{0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0},
}

local area = createCombatArea(arr)
setCombatArea(combat, area)

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local yellowGem = 2154 -- ID da Yellow Gem (pode ser outro ID)
	if getPlayerItemCount(cid, yellowGem) >= 1 then
		doCombat(cid, combat, var)
		doPlayerRemoveItem(cid, yellowGem, 1)
		return true
	else
		doPlayerSendCancel(cid, "Você não tem a Yellow Gem necessária para usar essa habilidade.")
		return false
	end
end



tem que adicionar em actions.xml a chamada

 

<action itemid="2154" event="script" value="yellowgem.lua"/>


 

Postado
  • Autor

Ele continua não usando a magia @drigobo nome da magia 'Karamatsu' funciona assim eu do use na gema ela desaoarece eu uso a magia igual do fox world

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

91-thais.png

Postado
local config = {
    itemId = 2154,
    vocationId = 2,
    vocationName = "clerigo",
    minLevel = 500,
}

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_LIFEDRAIN)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_EXPLOSIONHIT)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -1000.0, -1000.0, -1000.0, -1000.0)

local arr = {
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
    { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
    { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
    { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
    { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
    { 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 0 },
    { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
    { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
    { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
    { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0 },
}

setCombatArea(combat, createCombatArea(arr))

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if not getPlayerVocation(cid) == config.vocationId then
        doPlayerSendCancel(cid, "Para usar a gema voce precisa ser um " .. config.vocationId)
        return false
    end
    
    if getPlayerLevel(cid) < config.minLevel then
        doPlayerSendCancel(cid, "Para usar a gema voce precisa ter pelo menos nivel " .. config.minLevel)
        return false
    end

    local itemId, amount = config.itemId, 1
    if getPlayerItemCount(cid, config.itemId) >= amount then
        doPlayerRemoveItem(cid, itemId, amount)
        return doCombat(cid, combat, var) and true
    end
end

 

Melhoramento no script:

local config = {
    itemId = 2154,
    vocationId = 2,
    vocationName = "clerigo",
    minLevel = 500,
}

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_LIFEDRAIN)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_EXPLOSIONHIT)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -1000.0, -1000.0, -1000.0, -1000.0)

local arr = {
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
    { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
    { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
    { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
    { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
    { 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 0 },
    { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
    { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
    { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
    { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0 },
}

setCombatArea(combat, createCombatArea(arr))

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if not getPlayerVocation(cid) == config.vocationId then
        return doPlayerSendCancel(cid, "Para usar a gema voce precisa ser um " .. config.vocationId) and false
    end

    if getPlayerLevel(cid) < config.minLevel then
        return doPlayerSendCancel(cid, "Para usar a gema voce precisa ter pelo menos nivel " .. config.minLevel) and
            false
    end

    local itemId, amount = config.itemId, 1
    if getPlayerItemCount(cid, config.itemId) >= amount then
        doPlayerRemoveItem(cid, itemId, amount)
        return doCombat(cid, combat, var) and true
    else
        return doPlayerSendCancel(cid, getItemNameById(config.itemId) .. " precisa estar com voce.") and false
    end
end

 

Editado por Anderson Sacani
Para melhor entendimento (veja o histórico de edições)

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

Informação Importante

Confirmação de Termo