Ir para conteúdo
  • Cadastre-se

(Resolvido)Modificação de Script


Ir para solução Resolvido por Vodkart,

Posts Recomendados

Olá Tibia king, peço encarecidamente por uma ajudinha.

 

Estou usando um sistema de rpg no meu tibia.

Peguei o sistema de Durabilidade de itens e armas do @jhon992.

 

A questão é que eu queria modificar um script de talkation que faz reparar os itens quebrados.
Porém o script está pedindo dinheiro para reparar, eu gostaria de modificar o script para pedir determinado item ao invés de dinheiro.

Eu já modifiquei muito e ainda não consegui :(

Spoiler

function onSay(cid, words, param)

local charge_price = 25 -- preço por carga em gps.

local slotShield = nil
local slotArmor = nil
local slotLegs = nil
local slotHelmet = nil
local slotBoots = nil	
local slotWeapon = nil

	local slots = {
		[1] = {slot=slotHelmet, lib=helmets},	
		[4] = {slot=slotArmor, lib=armors},
		[5] = {slot=slotShield, lib=shields},
		[6] = {slot=slotShield, lib=shields},
		[7] = {slot=slotLegs, lib=legs},
		[8] = {slot=slotBoots, lib=boots}	
	}

	if weapons[getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid] then
		slotWeapon = CONST_SLOT_RIGHT					
	elseif weapons[getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid] then
		slotWeapon = CONST_SLOT_LEFT
	end

	if shields[getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid] then
		slotShield = CONST_SLOT_RIGHT					
	elseif shields[getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid] then
		slotShield = CONST_SLOT_LEFT
	end

	local price = 0
	if param == "weapon" then
		if slotWeapon ~= nil then
			if (getItemAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges") == "Broken") then
				price = (weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge)
			else
				price = ((weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges")))
			end
			if doPlayerRemoveMoney(cid, price*charge_price) then
				doItemSetAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges", weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge)
				setItemName(getPlayerSlotItem(cid, slotWeapon).uid, getItemNameById(getPlayerSlotItem(cid, slotWeapon).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges")) ..'/'.. weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge ..']')
				doPlayerSendTextMessage(cid, 22, "Sua weapon foi reparada.")
				doSendMagicEffect(getPlayerPosition(cid), 29)
			else
				doPlayerSendTextMessage(cid, 23, "Você não possui gps's suficiente para reparar sua weapon, é necessario "..(price*charge_price).." gps.")
				return true
			end
		else
			doPlayerSendTextMessage(cid, 23, "Seu slot de weapon esta vazio.")
		end
	return true
	end

	if param == "shield" then
		if slotShield ~= nil then
		if (getItemAttribute(getPlayerSlotItem(cid, slotShield).uid, "Charges") == "Broken") then
				price = (shields[getPlayerSlotItem(cid, slotShield).itemid].charge)
			else
				price = ((shields[getPlayerSlotItem(cid, slotShield).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, slotShield).uid, "Charges")))
			end
			if doPlayerRemoveMoney(cid, price*charge_price) then
				doItemSetAttribute(getPlayerSlotItem(cid, slotShield).uid, "Charges", shields[getPlayerSlotItem(cid, slotShield).itemid].charge)
				setItemName(getPlayerSlotItem(cid, slotShield).uid, getItemNameById(getPlayerSlotItem(cid, slotShield).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, slotShield).uid, "Charges")) ..'/'.. shields[getPlayerSlotItem(cid, slotShield).itemid].charge ..']')
				setItemDefense(getPlayerSlotItem(cid, slotShield).uid, shields[getPlayerSlotItem(cid, slotShield).itemid].def)
				doPlayerSendTextMessage(cid, 22, "Seu shield foi reparado.")
				doSendMagicEffect(getPlayerPosition(cid), 29)
			else
				doPlayerSendTextMessage(cid, 23, "Você não possui gps's suficiente para reparar seu shield, é necessario "..(price*charge_price).." gps.")
				return true
			end
		else
			doPlayerSendTextMessage(cid, 23, "Seu slot de shield esta vazio.")
		end
	return true
	end

	if param == "armor" then
	i = 4
		if slots[i].lib[getPlayerSlotItem(cid, i).itemid] then
			slots[i].slot = i
			if (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges") == "Broken") then
				price = (slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge)
			else
				price = ((slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")))
			end
			if doPlayerRemoveMoney(cid, price*charge_price) then					
				doItemSetAttribute(getPlayerSlotItem(cid, i).uid, "Charges", slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge)
				setItemName(getPlayerSlotItem(cid, i).uid, getItemNameById(getPlayerSlotItem(cid, i).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")) ..'/'.. slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge ..']')
				setItemArmor(getPlayerSlotItem(cid, i).uid, slots[i].lib[getPlayerSlotItem(cid, i).itemid].arm)
				doPlayerSendTextMessage(cid, 22, "Seu armor foi reparado.")
				doSendMagicEffect(getPlayerPosition(cid), 29)
			else
				doPlayerSendTextMessage(cid, 23, "Você não possui gps's suficiente para reparar sua armor, é necessario "..(price*charge_price).." gps.")
				return true
			end
		else	
			doPlayerSendTextMessage(cid, 23, "Seu slot de armor esta vazio.")
		end
	return true
	end

	if param == "legs" then
	i = 7
		if slots[i].lib[getPlayerSlotItem(cid, i).itemid] then
			slots[i].slot = i
			if (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges") == "Broken") then
				price = (slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge)
			else
				price = ((slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")))
			end
			if doPlayerRemoveMoney(cid, price*charge_price) then	
				doItemSetAttribute(getPlayerSlotItem(cid, i).uid, "Charges", slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge)
				setItemName(getPlayerSlotItem(cid, i).uid, getItemNameById(getPlayerSlotItem(cid, i).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")) ..'/'.. slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge ..']')
				setItemArmor(getPlayerSlotItem(cid, i).uid, slots[i].lib[getPlayerSlotItem(cid, i).itemid].arm)
				doPlayerSendTextMessage(cid, 22, "Sua legs foi reparada.")
				doSendMagicEffect(getPlayerPosition(cid), 29)
			else
				doPlayerSendTextMessage(cid, 23, "Você não possui gps's suficiente para reparar sua legs, é necessario "..(price*charge_price).." gps.")
				return true
			end
		else	
			doPlayerSendTextMessage(cid, 23, "Seu slot de legs esta vazio.")
		end
	return true
	end

	if param == "boots" then
	i = 8
		if slots[i].lib[getPlayerSlotItem(cid, i).itemid] then
			slots[i].slot = i
			if (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges") == "Broken") then
				price = (slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge)
			else
				price = ((slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")))
			end
			if doPlayerRemoveMoney(cid, price*charge_price) then	
				doItemSetAttribute(getPlayerSlotItem(cid, i).uid, "Charges", slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge)
				setItemName(getPlayerSlotItem(cid, i).uid, getItemNameById(getPlayerSlotItem(cid, i).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")) ..'/'.. slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge ..']')
				setItemArmor(getPlayerSlotItem(cid, i).uid, slots[i].lib[getPlayerSlotItem(cid, i).itemid].arm)
				doPlayerSendTextMessage(cid, 22, "Sua boots foi reparada.")
				doSendMagicEffect(getPlayerPosition(cid), 29)
			else
				doPlayerSendTextMessage(cid, 23, "Você não possui gps's suficiente para reparar sua armor, é necessario "..(price*charge_price).." gps.")
				return true
			end
		else	
			doPlayerSendTextMessage(cid, 23, "Seu slot de boots esta vazio.")
		end
	return true
	end

	if param == "helmet" then
	i = 1
		if slots[i].lib[getPlayerSlotItem(cid, i).itemid] then
			slots[i].slot = i
			if (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges") == "Broken") then
				price = (slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge)
			else
				price = ((slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")))
			end
			if doPlayerRemoveMoney(cid, price*charge_price) then	
				doItemSetAttribute(getPlayerSlotItem(cid, i).uid, "Charges", slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge)
				setItemName(getPlayerSlotItem(cid, i).uid, getItemNameById(getPlayerSlotItem(cid, i).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")) ..'/'.. slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge ..']')
				setItemArmor(getPlayerSlotItem(cid, i).uid, slots[i].lib[getPlayerSlotItem(cid, i).itemid].arm)
				doPlayerSendTextMessage(cid, 22, "Seu helmet foi reparado.")
				doSendMagicEffect(getPlayerPosition(cid), 29)
			else
				doPlayerSendTextMessage(cid, 23, "Você não possui gps's suficiente para reparar seu helmet, é necessario "..(price*charge_price).." gps.")
				return true
			end
		else	
			doPlayerSendTextMessage(cid, 23, "Seu slot de helmet esta vazio.")
		end
	return true
	end

	local pricetotal = 0
	for i=1, 8 do
		if slots[i] ~= nil then
			if slots[i].lib[getPlayerSlotItem(cid, i).itemid] then
				slots[i].slot = i	
				if (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges") == "Broken") then
					pricetotal = ((slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) + pricetotal)
				else
					pricetotal = (((slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges"))) + pricetotal)
				end
			end
		end
	end
	if slotWeapon ~= nil then
		if (getItemAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges") == "Broken") then
			pricetotal = ((weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge) + pricetotal)
		else
			pricetotal = (((weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges"))) + pricetotal)
		end			
	end

	if doPlayerRemoveMoney(cid, pricetotal*charge_price) then
		for i=1, 8 do
			if slots[i] ~= nil then
				if slots[i].lib[getPlayerSlotItem(cid, i).itemid] then
					slots[i].slot = i
					if isShield(getPlayerSlotItem(cid, i).uid) then
						setItemDefense(getPlayerSlotItem(cid, i).uid, slots[i].lib[getPlayerSlotItem(cid, i).itemid].def)
					elseif not isWeapon(getPlayerSlotItem(cid, i).uid) then
						setItemArmor(getPlayerSlotItem(cid, i).uid, slots[i].lib[getPlayerSlotItem(cid, i).itemid].arm)
					end
					doItemSetAttribute(getPlayerSlotItem(cid, i).uid, "Charges", slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge)
					setItemName(getPlayerSlotItem(cid, i).uid, getItemNameById(getPlayerSlotItem(cid, i).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")) ..'/'.. slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge ..']')
				end	
			end
		end
		if slotWeapon ~= nil then
			doItemSetAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges", weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge)
			setItemName(getPlayerSlotItem(cid, slotWeapon).uid, getItemNameById(getPlayerSlotItem(cid, slotWeapon).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges")) ..'/'.. weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge ..']')
		end
		doPlayerSendTextMessage(cid, 22, "Seus itens foram reparados.")
		doSendMagicEffect(getPlayerPosition(cid), 30)
	else
		doPlayerSendTextMessage(cid, 23, "Você não possui gps's suficiente para reparar todos os itens, é necessario "..(pricetotal*charge_price).." gps.")
	return true
	end

return TRUE
end

 

Link para o post
Compartilhar em outros sites
  • Solução
function onSay(cid, words, param)
	
	local charge_price = 1 -- quantidade por carga do item abaixo
	local item_id = 2159 -- id do item que será removido
	
	local slotShield = nil
	local slotArmor = nil
	local slotLegs = nil
	local slotHelmet = nil
	local slotBoots = nil	
	local slotWeapon = nil
	
	local slots = {
		[1] = {slot=slotHelmet, lib=helmets},	
		[4] = {slot=slotArmor, lib=armors},
		[5] = {slot=slotShield, lib=shields},
		[6] = {slot=slotShield, lib=shields},
		[7] = {slot=slotLegs, lib=legs},
		[8] = {slot=slotBoots, lib=boots}	
	}
	
	if weapons[getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid] then
		slotWeapon = CONST_SLOT_RIGHT					
	elseif weapons[getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid] then
		slotWeapon = CONST_SLOT_LEFT
	end
	
	if shields[getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid] then
		slotShield = CONST_SLOT_RIGHT					
	elseif shields[getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid] then
		slotShield = CONST_SLOT_LEFT
	end
	
	local price = 0
	if param == "weapon" then
		if slotWeapon ~= nil then
			if (getItemAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges") == "Broken") then
				price = (weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge)
			else
				price = ((weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges")))
			end
			if doPlayerRemoveItem(cid, item_id, price*charge_price) then
				doItemSetAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges", weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge)
				setItemName(getPlayerSlotItem(cid, slotWeapon).uid, getItemNameById(getPlayerSlotItem(cid, slotWeapon).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges")) ..'/'.. weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge ..']')
				doPlayerSendTextMessage(cid, 22, "Sua weapon foi reparada.")
				doSendMagicEffect(getPlayerPosition(cid), 29)
			else
				doPlayerSendTextMessage(cid, 23, "Desculpe mas você não tem "..(price*charge_price).."x "..getItemNameById(item_id).." para reparar sua weapon")
				return true
			end
		else
			doPlayerSendTextMessage(cid, 23, "Seu slot de weapon esta vazio.")
		end
		return true
	end
	if param == "shield" then
		if slotShield ~= nil then
			if (getItemAttribute(getPlayerSlotItem(cid, slotShield).uid, "Charges") == "Broken") then
				price = (shields[getPlayerSlotItem(cid, slotShield).itemid].charge)
			else
				price = ((shields[getPlayerSlotItem(cid, slotShield).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, slotShield).uid, "Charges")))
			end
			if doPlayerRemoveItem(cid, item_id, price*charge_price) then
				doItemSetAttribute(getPlayerSlotItem(cid, slotShield).uid, "Charges", shields[getPlayerSlotItem(cid, slotShield).itemid].charge)
				setItemName(getPlayerSlotItem(cid, slotShield).uid, getItemNameById(getPlayerSlotItem(cid, slotShield).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, slotShield).uid, "Charges")) ..'/'.. shields[getPlayerSlotItem(cid, slotShield).itemid].charge ..']')
				setItemDefense(getPlayerSlotItem(cid, slotShield).uid, shields[getPlayerSlotItem(cid, slotShield).itemid].def)
				doPlayerSendTextMessage(cid, 22, "Seu shield foi reparado.")
				doSendMagicEffect(getPlayerPosition(cid), 29)
			else
				doPlayerSendTextMessage(cid, 23, "Desculpe mas você não tem "..(price*charge_price).."x "..getItemNameById(item_id).." para reparar seu shield.")
				return true
			end
		else
			doPlayerSendTextMessage(cid, 23, "Seu slot de shield esta vazio.")
		end
		return true
	end
	
	if param == "armor" then
		i = 4
		if slots[i].lib[getPlayerSlotItem(cid, i).itemid] then
			slots[i].slot = i
			if (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges") == "Broken") then
				price = (slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge)
			else
				price = ((slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")))
			end
			if doPlayerRemoveItem(cid, item_id, price*charge_price) then				
				doItemSetAttribute(getPlayerSlotItem(cid, i).uid, "Charges", slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge)
				setItemName(getPlayerSlotItem(cid, i).uid, getItemNameById(getPlayerSlotItem(cid, i).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")) ..'/'.. slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge ..']')
				setItemArmor(getPlayerSlotItem(cid, i).uid, slots[i].lib[getPlayerSlotItem(cid, i).itemid].arm)
				doPlayerSendTextMessage(cid, 22, "Seu armor foi reparado.")
				doSendMagicEffect(getPlayerPosition(cid), 29)
			else
				doPlayerSendTextMessage(cid, 23, "Desculpe mas você não tem "..(price*charge_price).."x "..getItemNameById(item_id).." para reparar sua armor")
				return true
			end
		else	
			doPlayerSendTextMessage(cid, 23, "Seu slot de armor esta vazio.")
		end
		return true
	end
	
	if param == "legs" then
		i = 7
		if slots[i].lib[getPlayerSlotItem(cid, i).itemid] then
			slots[i].slot = i
			if (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges") == "Broken") then
				price = (slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge)
			else
				price = ((slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")))
			end
			if doPlayerRemoveItem(cid, item_id, price*charge_price) then	
				doItemSetAttribute(getPlayerSlotItem(cid, i).uid, "Charges", slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge)
				setItemName(getPlayerSlotItem(cid, i).uid, getItemNameById(getPlayerSlotItem(cid, i).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")) ..'/'.. slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge ..']')
				setItemArmor(getPlayerSlotItem(cid, i).uid, slots[i].lib[getPlayerSlotItem(cid, i).itemid].arm)
				doPlayerSendTextMessage(cid, 22, "Sua legs foi reparada.")
				doSendMagicEffect(getPlayerPosition(cid), 29)
			else
				doPlayerSendTextMessage(cid, 23, "Desculpe mas você não tem "..(price*charge_price).."x "..getItemNameById(item_id).." para reparar sua legs.")
				return true
			end
		else	
			doPlayerSendTextMessage(cid, 23, "Seu slot de legs esta vazio.")
		end
		return true
	end
	
	if param == "boots" then
		i = 8
		if slots[i].lib[getPlayerSlotItem(cid, i).itemid] then
			slots[i].slot = i
			if (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges") == "Broken") then
				price = (slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge)
			else
				price = ((slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")))
			end
			if doPlayerRemoveItem(cid, item_id, price*charge_price) then	
				doItemSetAttribute(getPlayerSlotItem(cid, i).uid, "Charges", slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge)
				setItemName(getPlayerSlotItem(cid, i).uid, getItemNameById(getPlayerSlotItem(cid, i).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")) ..'/'.. slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge ..']')
				setItemArmor(getPlayerSlotItem(cid, i).uid, slots[i].lib[getPlayerSlotItem(cid, i).itemid].arm)
				doPlayerSendTextMessage(cid, 22, "Sua boots foi reparada.")
				doSendMagicEffect(getPlayerPosition(cid), 29)
			else
				doPlayerSendTextMessage(cid, 23, "Desculpe mas você não tem "..(price*charge_price).."x "..getItemNameById(item_id).." para reparar sua bota.")
				return true
			end
		else	
			doPlayerSendTextMessage(cid, 23, "Seu slot de boots esta vazio.")
		end
		return true
	end
	
	if param == "helmet" then
		i = 1
		if slots[i].lib[getPlayerSlotItem(cid, i).itemid] then
			slots[i].slot = i
			if (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges") == "Broken") then
				price = (slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge)
			else
				price = ((slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")))
			end
			if doPlayerRemoveItem(cid, item_id, price*charge_price) then	
				doItemSetAttribute(getPlayerSlotItem(cid, i).uid, "Charges", slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge)
				setItemName(getPlayerSlotItem(cid, i).uid, getItemNameById(getPlayerSlotItem(cid, i).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")) ..'/'.. slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge ..']')
				setItemArmor(getPlayerSlotItem(cid, i).uid, slots[i].lib[getPlayerSlotItem(cid, i).itemid].arm)
				doPlayerSendTextMessage(cid, 22, "Seu helmet foi reparado.")
				doSendMagicEffect(getPlayerPosition(cid), 29)
			else
				doPlayerSendTextMessage(cid, 23, "Desculpe mas você não tem "..(price*charge_price).."x "..getItemNameById(item_id).." para reparar sua bota")
				return true
			end
		else	
			doPlayerSendTextMessage(cid, 23, "Seu slot de helmet esta vazio.")
		end
		return true
	end
	
	local pricetotal = 0
	for i=1, 8 do
		if slots[i] ~= nil then
			if slots[i].lib[getPlayerSlotItem(cid, i).itemid] then
				slots[i].slot = i	
				if (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges") == "Broken") then
					pricetotal = ((slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) + pricetotal)
				else
					pricetotal = (((slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges"))) + pricetotal)
				end
			end
		end
	end
	if slotWeapon ~= nil then
		if (getItemAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges") == "Broken") then
			pricetotal = ((weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge) + pricetotal)
		else
			pricetotal = (((weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges"))) + pricetotal)
		end			
	end
	
	if doPlayerRemoveItem(cid, item_id, pricetotal*charge_price) then
		for i=1, 8 do
			if slots[i] ~= nil then
				if slots[i].lib[getPlayerSlotItem(cid, i).itemid] then
					slots[i].slot = i
					if isShield(getPlayerSlotItem(cid, i).uid) then
						setItemDefense(getPlayerSlotItem(cid, i).uid, slots[i].lib[getPlayerSlotItem(cid, i).itemid].def)
					elseif not isWeapon(getPlayerSlotItem(cid, i).uid) then
						setItemArmor(getPlayerSlotItem(cid, i).uid, slots[i].lib[getPlayerSlotItem(cid, i).itemid].arm)
					end
					doItemSetAttribute(getPlayerSlotItem(cid, i).uid, "Charges", slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge)
					setItemName(getPlayerSlotItem(cid, i).uid, getItemNameById(getPlayerSlotItem(cid, i).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")) ..'/'.. slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge ..']')
				end	
			end
		end
		if slotWeapon ~= nil then
			doItemSetAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges", weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge)
			setItemName(getPlayerSlotItem(cid, slotWeapon).uid, getItemNameById(getPlayerSlotItem(cid, slotWeapon).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges")) ..'/'.. weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge ..']')
		end
		doPlayerSendTextMessage(cid, 22, "Seus itens foram reparados.")
		doSendMagicEffect(getPlayerPosition(cid), 30)
	else
		doPlayerSendTextMessage(cid, 23, "Desculpe, Você não possui "..(pricetotal*charge_price).."x "..getItemNameById(item_id).." para reparar todos os itens")
		return true
	end	
	return TRUE
end

 

vodkart_logo.png

[*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*]

 

DISCORDvodkart#6090

 

Link para o post
Compartilhar em outros sites
2 horas atrás, Vodkart disse:

function onSay(cid, words, param)
	
	local charge_price = 1 -- quantidade por carga do item abaixo
	local item_id = 2159 -- id do item que será removido
	
	local slotShield = nil
	local slotArmor = nil
	local slotLegs = nil
	local slotHelmet = nil
	local slotBoots = nil	
	local slotWeapon = nil
	
	local slots = {
		[1] = {slot=slotHelmet, lib=helmets},	
		[4] = {slot=slotArmor, lib=armors},
		[5] = {slot=slotShield, lib=shields},
		[6] = {slot=slotShield, lib=shields},
		[7] = {slot=slotLegs, lib=legs},
		[8] = {slot=slotBoots, lib=boots}	
	}
	
	if weapons[getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid] then
		slotWeapon = CONST_SLOT_RIGHT					
	elseif weapons[getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid] then
		slotWeapon = CONST_SLOT_LEFT
	end
	
	if shields[getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid] then
		slotShield = CONST_SLOT_RIGHT					
	elseif shields[getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid] then
		slotShield = CONST_SLOT_LEFT
	end
	
	local price = 0
	if param == "weapon" then
		if slotWeapon ~= nil then
			if (getItemAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges") == "Broken") then
				price = (weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge)
			else
				price = ((weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges")))
			end
			if doPlayerRemoveItem(cid, item_id, price*charge_price) then
				doItemSetAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges", weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge)
				setItemName(getPlayerSlotItem(cid, slotWeapon).uid, getItemNameById(getPlayerSlotItem(cid, slotWeapon).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges")) ..'/'.. weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge ..']')
				doPlayerSendTextMessage(cid, 22, "Sua weapon foi reparada.")
				doSendMagicEffect(getPlayerPosition(cid), 29)
			else
				doPlayerSendTextMessage(cid, 23, "Desculpe mas você não tem "..(price*charge_price).."x "..getItemNameById(item_id).." para reparar sua weapon")
				return true
			end
		else
			doPlayerSendTextMessage(cid, 23, "Seu slot de weapon esta vazio.")
		end
		return true
	end
	if param == "shield" then
		if slotShield ~= nil then
			if (getItemAttribute(getPlayerSlotItem(cid, slotShield).uid, "Charges") == "Broken") then
				price = (shields[getPlayerSlotItem(cid, slotShield).itemid].charge)
			else
				price = ((shields[getPlayerSlotItem(cid, slotShield).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, slotShield).uid, "Charges")))
			end
			if doPlayerRemoveItem(cid, item_id, price*charge_price) then
				doItemSetAttribute(getPlayerSlotItem(cid, slotShield).uid, "Charges", shields[getPlayerSlotItem(cid, slotShield).itemid].charge)
				setItemName(getPlayerSlotItem(cid, slotShield).uid, getItemNameById(getPlayerSlotItem(cid, slotShield).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, slotShield).uid, "Charges")) ..'/'.. shields[getPlayerSlotItem(cid, slotShield).itemid].charge ..']')
				setItemDefense(getPlayerSlotItem(cid, slotShield).uid, shields[getPlayerSlotItem(cid, slotShield).itemid].def)
				doPlayerSendTextMessage(cid, 22, "Seu shield foi reparado.")
				doSendMagicEffect(getPlayerPosition(cid), 29)
			else
				doPlayerSendTextMessage(cid, 23, "Desculpe mas você não tem "..(price*charge_price).."x "..getItemNameById(item_id).." para reparar seu shield.")
				return true
			end
		else
			doPlayerSendTextMessage(cid, 23, "Seu slot de shield esta vazio.")
		end
		return true
	end
	
	if param == "armor" then
		i = 4
		if slots[i].lib[getPlayerSlotItem(cid, i).itemid] then
			slots[i].slot = i
			if (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges") == "Broken") then
				price = (slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge)
			else
				price = ((slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")))
			end
			if doPlayerRemoveItem(cid, item_id, price*charge_price) then				
				doItemSetAttribute(getPlayerSlotItem(cid, i).uid, "Charges", slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge)
				setItemName(getPlayerSlotItem(cid, i).uid, getItemNameById(getPlayerSlotItem(cid, i).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")) ..'/'.. slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge ..']')
				setItemArmor(getPlayerSlotItem(cid, i).uid, slots[i].lib[getPlayerSlotItem(cid, i).itemid].arm)
				doPlayerSendTextMessage(cid, 22, "Seu armor foi reparado.")
				doSendMagicEffect(getPlayerPosition(cid), 29)
			else
				doPlayerSendTextMessage(cid, 23, "Desculpe mas você não tem "..(price*charge_price).."x "..getItemNameById(item_id).." para reparar sua armor")
				return true
			end
		else	
			doPlayerSendTextMessage(cid, 23, "Seu slot de armor esta vazio.")
		end
		return true
	end
	
	if param == "legs" then
		i = 7
		if slots[i].lib[getPlayerSlotItem(cid, i).itemid] then
			slots[i].slot = i
			if (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges") == "Broken") then
				price = (slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge)
			else
				price = ((slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")))
			end
			if doPlayerRemoveItem(cid, item_id, price*charge_price) then	
				doItemSetAttribute(getPlayerSlotItem(cid, i).uid, "Charges", slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge)
				setItemName(getPlayerSlotItem(cid, i).uid, getItemNameById(getPlayerSlotItem(cid, i).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")) ..'/'.. slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge ..']')
				setItemArmor(getPlayerSlotItem(cid, i).uid, slots[i].lib[getPlayerSlotItem(cid, i).itemid].arm)
				doPlayerSendTextMessage(cid, 22, "Sua legs foi reparada.")
				doSendMagicEffect(getPlayerPosition(cid), 29)
			else
				doPlayerSendTextMessage(cid, 23, "Desculpe mas você não tem "..(price*charge_price).."x "..getItemNameById(item_id).." para reparar sua legs.")
				return true
			end
		else	
			doPlayerSendTextMessage(cid, 23, "Seu slot de legs esta vazio.")
		end
		return true
	end
	
	if param == "boots" then
		i = 8
		if slots[i].lib[getPlayerSlotItem(cid, i).itemid] then
			slots[i].slot = i
			if (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges") == "Broken") then
				price = (slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge)
			else
				price = ((slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")))
			end
			if doPlayerRemoveItem(cid, item_id, price*charge_price) then	
				doItemSetAttribute(getPlayerSlotItem(cid, i).uid, "Charges", slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge)
				setItemName(getPlayerSlotItem(cid, i).uid, getItemNameById(getPlayerSlotItem(cid, i).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")) ..'/'.. slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge ..']')
				setItemArmor(getPlayerSlotItem(cid, i).uid, slots[i].lib[getPlayerSlotItem(cid, i).itemid].arm)
				doPlayerSendTextMessage(cid, 22, "Sua boots foi reparada.")
				doSendMagicEffect(getPlayerPosition(cid), 29)
			else
				doPlayerSendTextMessage(cid, 23, "Desculpe mas você não tem "..(price*charge_price).."x "..getItemNameById(item_id).." para reparar sua bota.")
				return true
			end
		else	
			doPlayerSendTextMessage(cid, 23, "Seu slot de boots esta vazio.")
		end
		return true
	end
	
	if param == "helmet" then
		i = 1
		if slots[i].lib[getPlayerSlotItem(cid, i).itemid] then
			slots[i].slot = i
			if (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges") == "Broken") then
				price = (slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge)
			else
				price = ((slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")))
			end
			if doPlayerRemoveItem(cid, item_id, price*charge_price) then	
				doItemSetAttribute(getPlayerSlotItem(cid, i).uid, "Charges", slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge)
				setItemName(getPlayerSlotItem(cid, i).uid, getItemNameById(getPlayerSlotItem(cid, i).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")) ..'/'.. slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge ..']')
				setItemArmor(getPlayerSlotItem(cid, i).uid, slots[i].lib[getPlayerSlotItem(cid, i).itemid].arm)
				doPlayerSendTextMessage(cid, 22, "Seu helmet foi reparado.")
				doSendMagicEffect(getPlayerPosition(cid), 29)
			else
				doPlayerSendTextMessage(cid, 23, "Desculpe mas você não tem "..(price*charge_price).."x "..getItemNameById(item_id).." para reparar sua bota")
				return true
			end
		else	
			doPlayerSendTextMessage(cid, 23, "Seu slot de helmet esta vazio.")
		end
		return true
	end
	
	local pricetotal = 0
	for i=1, 8 do
		if slots[i] ~= nil then
			if slots[i].lib[getPlayerSlotItem(cid, i).itemid] then
				slots[i].slot = i	
				if (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges") == "Broken") then
					pricetotal = ((slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) + pricetotal)
				else
					pricetotal = (((slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges"))) + pricetotal)
				end
			end
		end
	end
	if slotWeapon ~= nil then
		if (getItemAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges") == "Broken") then
			pricetotal = ((weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge) + pricetotal)
		else
			pricetotal = (((weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges"))) + pricetotal)
		end			
	end
	
	if doPlayerRemoveItem(cid, item_id, pricetotal*charge_price) then
		for i=1, 8 do
			if slots[i] ~= nil then
				if slots[i].lib[getPlayerSlotItem(cid, i).itemid] then
					slots[i].slot = i
					if isShield(getPlayerSlotItem(cid, i).uid) then
						setItemDefense(getPlayerSlotItem(cid, i).uid, slots[i].lib[getPlayerSlotItem(cid, i).itemid].def)
					elseif not isWeapon(getPlayerSlotItem(cid, i).uid) then
						setItemArmor(getPlayerSlotItem(cid, i).uid, slots[i].lib[getPlayerSlotItem(cid, i).itemid].arm)
					end
					doItemSetAttribute(getPlayerSlotItem(cid, i).uid, "Charges", slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge)
					setItemName(getPlayerSlotItem(cid, i).uid, getItemNameById(getPlayerSlotItem(cid, i).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")) ..'/'.. slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge ..']')
				end	
			end
		end
		if slotWeapon ~= nil then
			doItemSetAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges", weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge)
			setItemName(getPlayerSlotItem(cid, slotWeapon).uid, getItemNameById(getPlayerSlotItem(cid, slotWeapon).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges")) ..'/'.. weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge ..']')
		end
		doPlayerSendTextMessage(cid, 22, "Seus itens foram reparados.")
		doSendMagicEffect(getPlayerPosition(cid), 30)
	else
		doPlayerSendTextMessage(cid, 23, "Desculpe, Você não possui "..(pricetotal*charge_price).."x "..getItemNameById(item_id).." para reparar todos os itens")
		return true
	end	
	return TRUE
end

 

 

Muito obrigada, você é incrível!!

 

Dúvida sanada! Por fechar o tópico ;)

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.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo