Ir para conteúdo

Featured Replies

Postado
  • Este é um post popular.

Script feito para TFS 1.x

 

Esse script foi feito para ajudar os mappers a fazerem quests sem precisar saber scriptwriting. Basta criar um bau, por actionid 15000 e um uniqueid que não coincida com outras storages usadas. Dentro do baú é só por quantos itens quiser.

Em data/actions/scripts crie um script chamado reward_system.lua e cole o seguinte código:

 

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
	local chest = Container(item.uid)

	if not chest then
		return true
	end

	local uniqueid = chest:getUniqueId()
	if player:getStorageValue(uniqueid) == -2 then
		player:sendTextMessage(MESSAGE_INFO_DESCR, "It is empty.")
		return true
	end

	local size = chest:getSize()
	local reward = nil

	local start = player:getStorageValue(uniqueid) == -1 and 0 or player:getStorageValue(uniqueid)

	for i = start, size do
		reward = chest:getItem(i)
		if not reward then
			break
		end

		if reward:getWeight() > player:getFreeCapacity() then
			player:sendTextMessage(MESSAGE_INFO_DESCR, 'You have found a ' .. reward:getName() .. ' weighing ' .. reward:getWeight()/100 .. ' oz it\'s too heavy.')
			player:setStorageValue(uniqueid, i)
			break
		else
			local reward_container = Container(reward:getUniqueId())
			if reward_container then
				reward_container = reward_container:clone()
				reward_container:moveTo(player)
			else
				player:addItem(reward:getId(), 1)
			end
			local reward_msg = reward:getArticle() .. ' ' .. reward:getName()
			if reward:getCount() > 1 then
				reward_msg = reward:getCount() .. ' ' .. reward:getPluralName()
			end

			player:sendTextMessage(MESSAGE_INFO_DESCR, 'You have found ' .. reward_msg .. '.')

			player:setStorageValue(uniqueid, -2)
		end
	end

	return true
end

 

E em actions.xml cole a seguinte tag:

    <!-- Reward System -->
    <action actionid="15000" script="reward_system.lua"/>

E pronto.

 

Edit: Atualizado, agora o baú pode conter bags/backpacks/containers que contém itens.

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

  • Respostas 5
  • Visualizações 1.1k
  • Created
  • Última resposta

Top Posters In This Topic

Postado

:accept: Seu tutorial foi aprovado, você recebeu um ponto de reputação e o tópico será movido para a área correta.

Te ajudei?? REP + e ficamos quites... <ahttp://www.tibiaking.com/forum/uploads/emoticons/default_happyy.png' alt=';D'>

Atenciosamente,

Daniel.

Abraços!

Postado

Esse script foi feito para ajudar os mappers a fazerem quests sem precisar saber scriptwriting. Basta criar um bau, por actionid 15000 e um uniqueid que não coincida com outras storages usadas. Dentro do baú é só por quantos itens quiser.

Em data/actions/scripts crie um script chamado reward_system.lua e cole o seguinte código:

 

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
	local chest = Container(item.uid)

	if not chest then
		return true
	end

	local uniqueid = chest:getUniqueId()
	if player:getStorageValue(uniqueid) == -2 then
		player:sendTextMessage(MESSAGE_INFO_DESCR, "It is empty.")
		return true
	end

	local size = chest:getSize()
	local reward = nil

	local start = player:getStorageValue(uniqueid) == -1 and 0 or player:getStorageValue(uniqueid)

	for i = start, size do
		reward = chest:getItem(i)
		if not reward then
			break
		end

		if reward:getWeight() > player:getFreeCapacity() then
			player:sendTextMessage(MESSAGE_INFO_DESCR, 'You have found a ' .. reward:getName() .. ' weighing ' .. reward:getWeight()/100 .. ' oz it\'s too heavy.')
			player:setStorageValue(uniqueid, i)
			break
		else
			local reward_container = Container(reward:getUniqueId())
			if reward_container then
				reward_container = reward_container:clone()
				reward_container:moveTo(player)
			else
				player:addItem(reward:getId(), 1)
			end
			local reward_msg = reward:getArticle() .. ' ' .. reward:getName()
			if reward:getCount() > 1 then
				reward_msg = reward:getCount() .. ' ' .. reward:getPluralName()
			end

			player:sendTextMessage(MESSAGE_INFO_DESCR, 'You have found ' .. reward_msg .. '.')

			player:setStorageValue(uniqueid, -2)
		end
	end

	return true
end

 

E em actions.xml cole a seguinte tag:

    <!-- Reward System -->
    <action actionid="15000" script="reward_system.lua"/>

E pronto.

 

Edit: Atualizado, agora o baú pode conter bags/backpacks/containers que contém itens.

 

Aqui não funcionou... quando clico no baú, o baú é "aberto" e é mostrado os itens lá dentro, daí o player puxa para ele e outros que vinhem fazê-la, não existirá mais itens.

 

ERRO:

 

Z3z0XwE.png?1

Editado por ScythePhantom (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.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo