Ir para conteúdo

Featured Replies

Postado
  • Autor

Eu uso esse talkactions pra criar item. talvez por ele voce consiga achar a solução.

Citar
local itemwithtier = TalkAction("/itemwithtier")
     
    -- usage: /itemwithtier item id or name, tier
    -- example: /itemwithtier falcon coif, 8
    -- make sure to move the item at least 1 time to refresh item tier icon
     
    function itemwithtier.onSay(player, words, param)
    local split = param:split(",")
    local itemType = ItemType(split[1])
    if itemType:getId() == 0 then
    itemType = ItemType(tonumber(split[1]))
    if not tonumber(split[1]) or itemType:getId() == 0 then
    player:sendCancelMessage("There is no item with that id or name.")
    return false
    end
    end
    local tier = tonumber(split[2])
    if tier <= 0 or tier == nil or tier > 10 then
    player:sendCancelMessage("Invalid tier count.")
    return false
    end
     
    player:addItem(itemType:getId(), 1?setTier(tier)
    return false
    end
     
    itemwithtier:separator(" ")
    itemwithtier:register()

 

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

  • Respostas 18
  • Visualizações 2.4k
  • Created
  • Última resposta

Top Posters In This Topic

Postado
local forge = Action()

local count = 1
local porcentagem = 100 -- porcentagem de chance de forjar
local chance = { -- cada id significa 10% de chance de acerto
	[1] = 100,
	[2] = 90,
	[3] = 80,
	[4] = 70,
	[5] = 60,
	[6] = 50,
	[7] = 40,
	[8] = 30,
	[9] = 20,
	[10] = 10  
}
	
function forge.onUse(player, item, fromPosition, target, toPosition, isHotkey)
	if not target or not target:isItem() then
		return false
	end

	if not target:remove(count) then
		player:sendTextMessage(MESSAGE_STATUS_SMALL, "Voce nao tem a quantidade de items necessaria para forjar.")
		player:getPosition():sendMagicEffect(CONST_ME_POFF)
		return false
	end

	local rand = math.random(100)
	local targetTier = target:getTier() and target:getTier() or 0
	if rand > chance[targetTier] then
		player:sendTextMessage(MESSAGE_STATUS_SMALL, "Voce forja falhou.")
		player:getPosition():sendMagicEffect(CONST_ME_POFF)
		return false
	end	

	if targetTier > 0 then
		if target:setTier(targetTier + 1) then
			player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "Parabens, o item foi forjado.")
			player:getPosition():sendMagicEffect(50)
		else
			player:sendTextMessage(MESSAGE_STATUS_SMALL, "Este item nao pode ser forjado.")
			player:getPosition():sendMagicEffect(CONST_ME_POFF)
			return false
		end
	else
		if target:setTier(1) then
			player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "Parabens, o item foi forjado.")
			player:getPosition():sendMagicEffect(50)
		else
			player:sendTextMessage(MESSAGE_STATUS_SMALL, "Este item nao pode ser forjado.")
			player:getPosition():sendMagicEffect(CONST_ME_POFF)
			return false
		end
	end

	return true
end


forge:id(24963)
forge:register()

 

Postado
  • Autor

Bom dia, ele retorna mesmo erro ainda:

Citar

[error] Lua script error:
scriptInterface: [Scripts Interface]
scriptId: [C:\Program Files (x86)\canary-global-windows-x64-full\data\scripts\custom\forja.lua:callback]
timerEvent: []
 callbackId:[]
function: []
error [...ry-global-windows-x64-full\data\scripts\custom\forja.lua:27: attempt to compare nil with number
stack traceback:
        [C]: in function '__lt'
        ...ry-global-windows-x64-full\data\scripts\custom\forja.lua:27: in function <...ry-global-windows-x64-full\data\scripts\custom\forja.lua:18>]

 

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

Informação Importante

Confirmação de Termo