Ir para conteúdo
  • 0

Ajuda Npc Que Compre Por Honor Points!


DavSciter

Pergunta

Boa noite a todos! Estou criando um servidor e estou usando o script do Vodkart em que o npc vende items por Pontos de Honra, não sei muito sobre a configuração dos npcs, tentei fazer com que ele também comprasse items mas foi um FRACASSO...se alguém puder me ajudar. Obrigado e fico grato pra quem puder ajudar ou pelo menos tentar. plink.gif

 

Segue o script abaixo:

 

]local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
local Honor_Storage = 90194
function getHonorPoints(cid)
local Honor = getPlayerStorageValue(cid, Honor_Storage)
return Honor < 0 and 0 or Honor
end
local shopWindow = {}
local t = {
			  [2195] = {price = 5}, -- [id do item] e em price qnto honor points vai custar
			  [2493] = {price = 25},
			  [2361] = {price = 30},
			  [8851] = {price = 20},
			  [8925] = {price = 30},
			  [2640] = {price = 50},
			  [2494] = {price = 100},
			  [9932] = {price = 50},
			  [2472] = {price = 70},
			  [8931] = {price = 100}
			  }
local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks)
			if  t[item] and getHonorPoints(cid) < t[item].price then
					 selfSay("You do not have "..t[item].price.." Honor Points.", cid)
							 else
							doPlayerAddItem(cid, item)
							setPlayerStorageValue(cid, Honor_Storage, getPlayerStorageValue(cid, Honor_Storage) - t[item].price)
							selfSay("Here is your item.", cid)
			   end
			return true
end
if (msgcontains(msg, 'trade') or msgcontains(msg, 'TRADE'))then
											for var, ret in pairs(t) do
																			table.insert(shopWindow, {id = var, subType = 0, buy = ret.price, sell = 0, name = getItemNameById(var)})
															end
											openShopWindow(cid, shopWindow, onBuy, onSell)
							end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Link para o comentário
Compartilhar em outros sites

3 respostass a esta questão

Posts Recomendados

  • 0

Assim:

 

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
local Honor_Storage = 90194
function getHonorPoints(cid)
local Honor = getPlayerStorageValue(cid, Honor_Storage)
return Honor < 0 and 0 or Honor
end
local shopWindow = {}
local t = {
							  [2195] = {price = 5}, -- [id do item] e em price qnto honor points vai custar
							  [2493] = {price = 25},
							  [2361] = {price = 30},
							  [8851] = {price = 20},
							  [8925] = {price = 30},
							  [2640] = {price = 50},
							  [2494] = {price = 100},
							  [9932] = {price = 50},
							  [2472] = {price = 70},
							  [8931] = {price = 100}
							  }

local w = {
							  [2195] = {price = 5}, -- [id do item] e em price qnto honor points vai dar
							  [2493] = {price = 25},
							  [2361] = {price = 30},
							  [8851] = {price = 20},
							  [8925] = {price = 30},
							  [2640] = {price = 50},
							  [2494] = {price = 100},
							  [9932] = {price = 50},
							  [2472] = {price = 70},
							  [8931] = {price = 100}
							  }

local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks)
						    if  t[item] and getHonorPoints(cid) < t[item].price then
											 selfSay("You do not have "..t[item].price.." Honor Points.", cid)
															 else
														    doPlayerAddItem(cid, item)
														    setPlayerStorageValue(cid, Honor_Storage, getPlayerStorageValue(cid, Honor_Storage) - t[item].price)
														    selfSay("Here is your item.", cid)
							   end
						    return true
end

local onSell = function(cid, item, subType, amount, ignoreCap, inBackpacks)
							 if w[item] then
							    doPlayerRemoveItem(cid, item, amount)
							    setPlayerStorageValue(cid, Honor_Storage, getPlayerStorageValue(cid, Honor_Storage) + w[item].price)
							    selfSay("Here is your Honor!", cid)
							    else
							    selfSay("You do not have "..getItemNameById(w[item])..".", cid)
							 end
							 return true
end
if (msgcontains(msg, 'trade') or msgcontains(msg, 'TRADE'))then
																						    for var, ret in pairs(t) do
																																						    table.insert(shopWindow, {id = var, subType = 0, buy = ret.price, sell = 0, name = getItemNameById(var)})
																														    end
																						    for i, k in pairs(w) do

		  table.insert(shopWindow, {id = i, subType = 0, buy = 0, sell = k.price, name = getItemNameById(i)})
																			   end
openShopWindow(cid, shopWindow, onBuy, onSell)
														    end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

É só configurar em:

local w = {

[2195] = {price = 5}, -- [id do item] e em price qnto honor points vai dar

[2493] = {price = 25},

[2361] = {price = 30},

[8851] = {price = 20},

[8925] = {price = 30},

[2640] = {price = 50},

[2494] = {price = 100},

[9932] = {price = 50},

[2472] = {price = 70},

[8931] = {price = 100}

}

 

Não testado, estou com pressa. Qualquer coisa só falar.

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...