Ir para conteúdo

Featured Replies

Postado
  • Solução

@leozincorsair 

Para source 0.4

Para source 0.3.6 vou passar como esta no meu

Data/Npc/Lib/npcsystem/npchandler.lua
Procure por:

-- Handles onBuy events. If you wish to handle this yourself, use the CALLBACK_ONBUY callback.

logo abaixo vai ter as funções de compra e venda gerais de todo o sistema ai eu adicionei um cooldown nas duas código completo V

Spoiler



	function NpcHandler:onBuy(cid, itemid, subType, amount, ignoreCap, inBackpacks)
	local config = { 
	cooldown = 3,  --- tempo entre um uso e outro
	}
	if os.time() - getPlayerStorageValue(cid, 11246) >= config.cooldown then
	setPlayerStorageValue(cid, 11246, os.time())
		local callback = self:getCallback(CALLBACK_ONBUY)
		if(callback == nil or callback(cid, itemid, subType, amount, ignoreCap, inBackpacks)) then
			if(self:processModuleCallback(CALLBACK_ONBUY, cid, itemid, subType, amount, ignoreCap, inBackpacks)) then
				--
			end
		end
		else
		doPlayerSendCancel(cid, "Espere "..(config.cooldown - (os.time() - getPlayerStorageValue(cid, 11246))).." segundo para comprar novamente.")
	end
end	

	-- Handles onSell events. If you wish to handle this yourself, use the CALLBACK_ONSELL callback.
	function NpcHandler:onSell(cid, itemid, subType, amount, ignoreCap, inBackpacks)
	local config = { 
	cooldown = 3,  --- tempo entre um uso e outro
	}
	if os.time() - getPlayerStorageValue(cid, 11246) >= config.cooldown then
	setPlayerStorageValue(cid, 11246, os.time())
		local callback = self:getCallback(CALLBACK_ONSELL)
		if(callback == nil or callback(cid, itemid, subType, amount, ignoreCap, inBackpacks)) then
			if(self:processModuleCallback(CALLBACK_ONSELL, cid, itemid, subType, amount, ignoreCap, inBackpacks)) then
				--
			end
		end
		else
		doPlayerSendCancel(cid, "Espere "..(config.cooldown - (os.time() - getPlayerStorageValue(cid, 11246))).." segundo para vender novamente.")		
	end
end	


 

 

Projeto ATS (Naruto)

Informações Abaixo

Facebook

Youtube
Discord

 

Tutoriais / Conteúdos

Clique Aqui

  • Respostas 6
  • Visualizações 753
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • @leozincorsair  Para source 0.4 Para source 0.3.6 vou passar como esta no meu Data/Npc/Lib/npcsystem/npchandler.lua Procure por: -- Handles onBuy events. If you wish to handle th

Postado
  • Autor
20 minutos atrás, LeoTK disse:

@leozincorsair 

Para source 0.4

Para source 0.3.6 vou passar como esta no meu

Data/Npc/Lib/npcsystem/npchandler.lua
Procure por:


-- Handles onBuy events. If you wish to handle this yourself, use the CALLBACK_ONBUY callback.

logo abaixo vai ter as funções de compra e venda gerais de todo o sistema ai eu adicionei um cooldown nas duas código completo V

  Mostrar conteúdo oculto

 



	function NpcHandler:onBuy(cid, itemid, subType, amount, ignoreCap, inBackpacks)
	local config = { 
	cooldown = 3,  --- tempo entre um uso e outro
	}
	if os.time() - getPlayerStorageValue(cid, 11246) >= config.cooldown then
	setPlayerStorageValue(cid, 11246, os.time())
		local callback = self:getCallback(CALLBACK_ONBUY)
		if(callback == nil or callback(cid, itemid, subType, amount, ignoreCap, inBackpacks)) then
			if(self:processModuleCallback(CALLBACK_ONBUY, cid, itemid, subType, amount, ignoreCap, inBackpacks)) then
				--
			end
		end
		else
		doPlayerSendCancel(cid, "Espere "..(config.cooldown - (os.time() - getPlayerStorageValue(cid, 11246))).." segundo para comprar novamente.")
	end
end	

	-- Handles onSell events. If you wish to handle this yourself, use the CALLBACK_ONSELL callback.
	function NpcHandler:onSell(cid, itemid, subType, amount, ignoreCap, inBackpacks)
	local config = { 
	cooldown = 3,  --- tempo entre um uso e outro
	}
	if os.time() - getPlayerStorageValue(cid, 11246) >= config.cooldown then
	setPlayerStorageValue(cid, 11246, os.time())
		local callback = self:getCallback(CALLBACK_ONSELL)
		if(callback == nil or callback(cid, itemid, subType, amount, ignoreCap, inBackpacks)) then
			if(self:processModuleCallback(CALLBACK_ONSELL, cid, itemid, subType, amount, ignoreCap, inBackpacks)) then
				--
			end
		end
		else
		doPlayerSendCancel(cid, "Espere "..(config.cooldown - (os.time() - getPlayerStorageValue(cid, 11246))).." segundo para vender novamente.")		
	end
end	

 

 

 

 

 

Me ajudou muito man, obrigado !!!

o meu so tinha exausted na onbuy.

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

Informação Importante

Confirmação de Termo