Ir para conteúdo

[100%] Auction House


537438

Posts Recomendados

Hello "..getCreatureName()..", estou aqui pra te ensinar um script bem útil, porém simples.

 

Nome: Auction House with NPC

Créditos : Gesior.pl da OTLand

Categoria: Fácil

Descrição: Vocês ja viram em alguns MMORPG's que existe o sistema de Auction House, voce quer vender um item, mas esta sem tempo? Isso terminou, deixe seu item com o Auctioner e ele venderá para voce.

 

offer of Player name mostra as ofertas de um player em uma janela de trade

search Item name mostra as 5 melhores ofertas de um item

Não sabe usar? Digite how to use.

Vamos ao tutorial?

 

 

1. Crie um arquivo LUA em data/npc/scripts com o nome de Auctioner.lua e adicione o seguinte código:

-- shop system
function getOfferOfPlayer(name)
local offer = {}
local result_items = db.getResult("SELECT `id`, `name`, `item_name`, `itemid`, `subType`, `count`, `price` FROM `ots_playersshopsystem` WHERE `name` = " .. db.escapeString(name) .. " AND `count` > '0' AND `itemid` != '66'")
if(result_items:getID() ~= -1) then
	while(true) do
		table.insert(offer, {id = result_items:getDataInt("id"), name = result_items:getDataString("name"), item_name = result_items:getDataString("item_name"), itemid = result_items:getDataInt("itemid"), subType = result_items:getDataInt("subType"), count = result_items:getDataInt("count"), price = result_items:getDataInt("price")})
			if not(result_items:next()) then
				break
			end
	end
	result_items:free()
end
return offer
end

function getOfferOfItem(item_name)
local offer = {}
result_items = db.getResult("SELECT `id`, `name`, `item_name`, `itemid`, `subType`, `count`, `price` FROM `ots_playersshopsystem` WHERE `item_name` = " .. db.escapeString(item_name) .. " AND `count` > '0' AND `itemid` != '66' ORDER BY `price` ASC LIMIT 5")
if(result_items:getID() ~= -1) then
	while(true) do
		table.insert(offer, {id = result_items:getDataInt("id"), name = result_items:getDataString("name"), item_name = result_items:getDataString("item_name"), itemid = result_items:getDataInt("itemid"), subType = result_items:getDataInt("subType"), count = result_items:getDataInt("count"), price = result_items:getDataInt("price")})
			if not(result_items:next()) then
				break
			end
	end
	result_items:free()
end
return offer
end

function addItemToOffer(name, itemid, subType, count)
local inDB_id = 0
local result_offers = db.getResult("SELECT `id`, `count` FROM `ots_playersshopsystem` WHERE `name` = " .. db.escapeString(name) .. " AND `itemid` = '" .. itemid .. "' AND `subType` = '" .. subType .. "' AND `itemid` != '66'")
if(result_offers:getID() ~= -1) then
	inDB_id = result_offers:getDataInt("id")
	result_offers:free()
end
if inDB_id ~= 0 then
	db.executeQuery("UPDATE `ots_playersshopsystem` SET `count` = `ots_playersshopsystem`.`count` + " .. count .." WHERE `id` = '" .. inDB_id .. "' AND `subType` = '" .. subType .. "' AND `itemid` != '66'")
else
	db.executeQuery("INSERT INTO `ots_playersshopsystem` (`id`, `name`, `item_name`, `itemid`, `subType`, `count`, `price`) VALUES (NULL, " .. db.escapeString(name) .. ", " .. db.escapeString(getItemNameById(itemid)) .. ", '" .. itemid .. "', '" .. subType .. "', '" .. count .. "', 1000000)")
end
return true
end

function removeItemsFromOffer(name, itemid, subType, count)
db.executeQuery("UPDATE `ots_playersshopsystem` SET `count` = `ots_playersshopsystem`.`count` - " .. count .." WHERE `name` = " .. db.escapeString(name) .. " AND `itemid` = '" .. itemid .. "' AND `subType` = '" .. subType .. "' AND `itemid` != '66'")
return true
end

function changePriceOfItem(name, itemid, subType, price)
db.executeQuery("UPDATE `ots_playersshopsystem` SET `price` = " .. price .." WHERE `name` = " .. db.escapeString(name) .. " AND `itemid` = '" .. itemid .. "' AND `subType` = '" .. subType .. "' AND `itemid` != '66'")
return true
end

function getItemWithId(id)
local item = {id=0}
local result_items = db.getResult("SELECT `id`, `name`, `item_name`, `itemid`, `subType`, `count`, `price` FROM `ots_playersshopsystem` WHERE `id` = '" .. id .. "' AND `count` > 0 AND `itemid` != '66'")
if (result_items:getID() ~= -1) then
	item = {id = result_items:getDataInt("id"), name = result_items:getDataString("name"), item_name = result_items:getDataString("item_name"), itemid = result_items:getDataInt("itemid"), subType = result_items:getDataInt("subType"), count = result_items:getDataInt("count"), price = result_items:getDataInt("price")}
	result_items:free()
end
return item
end

function getItemWithItemId(name, itemid, subType)
local item = {id=0, subType=0}
local result_items = db.getResult("SELECT `id`, `name`, `item_name`, `itemid`, `subType`, `count`, `price` FROM `ots_playersshopsystem` WHERE `name` = " .. db.escapeString(name) .. " AND `itemid` = '" .. itemid .. "' AND `subType` = '" .. subType .. "' AND `count` > 0 AND `itemid` != '66'")
if(result_items:getID() ~= -1) then
	item = {id = result_items:getDataInt("id"), name = result_items:getDataString("name"), item_name = result_items:getDataString("item_name"), itemid = result_items:getDataInt("itemid"), subType = result_items:getDataInt("subType"), count = result_items:getDataInt("count"), price = result_items:getDataInt("price")}
	result_items:free()
end
return item
end

function getCash(name)
local cash = 0
local result_items = db.getResult("SELECT `id`, `count` FROM `ots_playersshopsystem` WHERE `name` = " .. db.escapeString(name) .. " AND `itemid` = '66'")
if(result_items:getID() ~= -1) then
	cash = result_items:getDataInt("count")
	result_items:free()
else
	db.executeQuery("INSERT INTO `ots_playersshopsystem` (`id`, `name`, `item_name`, `itemid`, `count`, `price`) VALUES ('', " .. db.escapeString(name) .. ", 'Player Cash', '66', '0', '0')")
end
return cash
end

function setCash(name, count)
db.executeQuery("UPDATE `ots_playersshopsystem` SET `count` = " .. count ..", `price` = " .. count .." WHERE `name` = " .. db.escapeString(name) .. " AND `itemid` = '66'")
return true
end

function addPlayerItemFromShop(cid, itemid, amount, subType)
local amount = amount or 1
local subType = subType or 0
if(isItemStackable(itemid) == TRUE) then
	local item = doCreateItemEx(itemid, amount)
	local ret = doPlayerAddItemEx(cid, item)
	if(ret ~= RETURNVALUE_NOERROR) then
		return {}, 0
	end
	return {item}, amount
end
local items = {}
local ret = 0
local a = 0
for i = 1, amount do
	items[i] = doCreateItemEx(itemid, subType)
	ret = doPlayerAddItemEx(cid, items[i])
	if(ret ~= RETURNVALUE_NOERROR) then
		break
	end
	a = a + 1
end
return items, a
end


local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
shop_offers = {}
shop_last_item = {}
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
npcHandler:say('I don\'t understand. Ask me for {how to use} to get available actions.', cid)
end

function onBuyItemNPC(cid, itemid, subType, amount)
if(isItemRune(itemid) ~= TRUE and isItemStackable(itemid) ~= TRUE) then
	subType = 0
end
if(NPCHANDLER_CONVBEHAVIOR ~= CONVERSATION_DEFAULT) then
	npcHandler.talkStart[cid] = os.time()
else
	npcHandler.talkStart = os.time()
end
local offers = shop_offers[cid]
local item = {id=0}
for i = 1, #offers do
	if itemid == offers[i].itemid and subType == offers[i].subType then
		item = getItemWithId(offers[i].id)
		break
	end
end
if (not (item.id > 0)) then
	npcHandler:say('This item is not available in this player offer.', cid)
	closeShopWindow(cid)
	return true
end
local amount2 = amount
if amount2 > item.count then
	amount2 = item.count
end
if item.name == getCreatureName(cid) then
	local boughtItems, i = addPlayerItemFromShop(cid, item.itemid, amount2, item.subType)
	if i == item.count then
		closeShopWindow(cid)
	end
	if(i < amount) then
		if(i > 0) then
			removeItemsFromOffer(item.name, item.itemid, item.subType, i)
			if amount == amount2 then
				npcHandler:say('Here you are your ' .. i .. ' of requested ' .. amount .. ' ' .. item.item_name .. ', because you do not have enought capacity for all.', cid)
			else
				npcHandler:say('Here you are your ' .. i .. ' of requested ' .. amount .. ' ' .. item.item_name .. ', because I do not have more your items of this type.', cid)
			end
		else
			npcHandler:say('You do not have capacity for this item.', cid)
		end
	else
		removeItemsFromOffer(item.name, item.itemid, item.subType, i)
		npcHandler:say('Here you are your ' .. amount .. ' ' .. item.item_name .. '.', cid)
	end
else
	if (getPlayerMoney(cid) < amount * item.price) then
		if(amount == 1) then
			npcHandler:say(item.item_name .. ' cost ' .. item.price .. ' gp, you got only ' .. getPlayerMoney(cid) .. ' gp.', cid)
		else
			npcHandler:say(amount .. ' ' .. item.item_name ..'s cost ' .. amount * item.price .. ' gp, you got only ' .. getPlayerMoney(cid) .. ' gp.', cid)
		end
		return true
	end
	local boughtItems, i = addPlayerItemFromShop(cid, item.itemid, amount2, item.subType)
	if i == item.count then
		closeShopWindow(cid)
	end
	if(i < amount) then
		if(i > 0) then
			removeItemsFromOffer(item.name, item.itemid, item.subType, i)
			doPlayerRemoveMoney(cid, i * item.price)
			setCash(item.name, getCash(item.name)+i * item.price)
			if amount == amount2 then
				npcHandler:say('Here you are ' .. i .. ' of requested ' .. amount .. ' ' .. item.item_name .. ' for ' .. i * item.price .. ' gp, because you do not have enought capacity for all.', cid)
			else
				npcHandler:say('Here you are ' .. i .. ' of requested ' .. amount .. ' ' .. item.item_name .. ' for ' .. i * item.price .. ' gp, because I do not have more for sell.', cid)
			end
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You bought " .. i .. "x " .. item.item_name .. ".")
		else
			npcHandler:say('You do not have capacity for this item.', cid)
		end
	else
		removeItemsFromOffer(item.name, item.itemid, item.subType, i)
		doPlayerRemoveMoney(cid, i * item.price)
		setCash(item.name, getCash(item.name)+i * item.price)
		npcHandler:say('Here you are ' .. amount .. ' ' .. item.item_name .. ' for ' .. i * item.price .. ' gp.', cid)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You bought " .. i .. "x " .. item.item_name .. ".")
	end
end
return true
end

function onSellItemNPC(cid, itemid, subType, amount)
return true
end

function showOfferOfPlayerNPC(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
	return false
end
local name = ''
if keywords[1] == 'my offer' or keywords[1] == 'get item' then
	name = getCreatureName(cid)
	npcHandler:say('You can take your items if you don\'t want sell them.', cid)
else
	name = string.sub(message, 10)
	npcHandler:say('Offer of ' .. name .. '.', cid)
end
local offer = getOfferOfPlayer(name)
shop_offers[cid] = offer
local itemWindow = {}
local item = {}
for i = 1, #offer do
	if keywords[1] == 'my offer' or keywords[1] == 'get item' then
		item = {id = offer[i].itemid, buy = 1, sell = 0, subType = offer[i].subType, name = offer[i].item_name .. "(" .. offer[i].count .. ")"}
	else
		item = {id = offer[i].itemid, buy = offer[i].price, sell = 0, subType = offer[i].subType, name = offer[i].item_name .. "(" .. offer[i].count .. ")"}
	end
	table.insert(itemWindow, item)
end
closeShopWindow(cid)
openShopWindow(cid, itemWindow, function(cid, itemid, subType, amount) onBuyItemNPC(cid, itemid, subType, amount) end, function(cid, itemid, subType, amount) onSellItemNPC(cid, itemid, subType, amount) end)
npcHandler:resetNpc()
return true
end

function showOfferOfItemNPC(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
	return false
end
local item_name = string.sub(message, 8)
local offer = getOfferOfItem(item_name)
local msg = ''
if #offer == 0 then
	msg = "Can\'t find offer of item with name >" .. item_name .. "<"
else
	msg = "Cheapest offers of " .. item_name .. ":\n"
	for i = 1, #offer do
		if offer[i].subType > 0 then
			msg = msg .. offer[i].price .. " gp (charges: " .. offer[i].subType .. ") - " .. offer[i].name
		else
			msg = msg .. offer[i].price .. " gp - " .. offer[i].name
		end
		if #offer ~= i then
			msg = msg .. "\n"
		end
	end
end
selfSay(msg, cid)
npcHandler:resetNpc()
return true
end

function addItemToOfferNPC(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
	return false
end
local number = 0
for word in string.gmatch(tostring(message), "(%w+)") do
	if tostring(tonumber(word)) == word then
		number = tonumber(word)
	end
end
if (parameters.setprice == true) then
	local item_db = getItemWithItemId(getCreatureName(cid), shop_last_item[cid].itemid, shop_last_item[cid].subType)
	if number < 1 then
		number = 1
	end
	changePriceOfItem(getCreatureName(cid), shop_last_item[cid].itemid, shop_last_item[cid].subType, number)
	item_db = getItemWithItemId(getCreatureName(cid), shop_last_item[cid].itemid, shop_last_item[cid].subType)
	if tonumber(item_db.subType) > 0 then
		npcHandler:say('Actually you have ' .. item_db.count ..' ' .. item_db.item_name .. ' (charges: ' .. item_db.subType .. ') in offer, price for each is now ' .. item_db.price .. ' gp. Say {set price} to change price of items.', cid)
	else
		npcHandler:say('Actually you have ' .. item_db.count ..' ' .. item_db.item_name .. ' in offer, price for each is now ' .. item_db.price .. ' gp. Say {set price} to change price of items.', cid)
	end
	shop_last_item[cid] = {}
	npcHandler:resetNpc()
elseif (parameters.setprice == false) then
	item_db = getItemWithItemId(getCreatureName(cid), shop_last_item[cid].itemid, shop_last_item[cid].subType)
	npcHandler:say('Ok. I do not change price for ' .. getItemNameById(shop_last_item[cid].itemid) ..'. It is ' .. item_db.price .. ' gp/each now.', cid)
	shop_last_item[cid] = {}
	npcHandler:resetNpc()
else
	local item = getPlayerSlotItem(cid, 5)
	if (item.itemid == 0) then
		npcHandler:say('Your left hand (under BP slot) is empty.', cid)
		npcHandler:resetNpc()
		return true
	end
	if (isItemContainer(item.itemid) == TRUE and getContainerItem(uid, 0).uid > 0) then
		npcHandler:say('In your left hand (under BP slot) is not empty container. You can add to offer only items and empty containers.', cid)
		npcHandler:resetNpc()
		return true
	end
	if number < 1 then
		number = 1
	end
	if (item.type > 0 and not(isItemStackable(item.itemid) == TRUE)) then
		number = 1
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You can\'t sell more then one ' .. getItemNameById(item.itemid) .. ' (charges: ' .. item.type .. '). Sorry.')
	end
	local to_remove = number
	if (number > getPlayerItemCount(cid, item.itemid)) then
		number = getPlayerItemCount(cid, item.itemid)
	end
	if (isItemStackable(item.itemid) == TRUE) then
		item.type = 0
	end
	if (number == 1) and (isItemStackable(item.itemid) == TRUE) then
		doRemoveItem(item.uid, number)
	elseif (number == 1) and not(isItemStackable(item.itemid) == TRUE) then
		doRemoveItem(item.uid, 1)
	else
		doPlayerRemoveItem(cid, item.itemid, number)
	end
	addItemToOffer(getCreatureName(cid), item.itemid, item.type, number)
	item_db = getItemWithItemId(getCreatureName(cid), item.itemid, item.type)
	shop_last_item[cid] = {itemid = item.itemid, subType = item.type}
	if item.type > 0 then
		npcHandler:say('Added ' .. number .. ' ' .. getItemNameById(item.itemid) .. ' (charges: ' .. item.type .. ') to your offer. Actually you have ' .. item_db.count ..' ' .. item_db.item_name .. ' (charges: ' .. item_db.subType .. ') in offer, price for each is ' .. item_db.price .. '. Do you want to change price? Say {no} or {price xxx}, where xxx is number of gp.', cid)
	else
		npcHandler:say('Added ' .. number .. ' ' .. getItemNameById(item.itemid) .. ' to your offer. Actually you have ' .. item_db.count ..' ' .. item_db.item_name .. ' in offer, price for each is ' .. item_db.price .. '. Do you want to change price? Say {no} or {price xxx}, where xxx is number of gp.', cid)
	end
end
return true
end

function setItemPriceNPC(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
	return false
end
local number = 0
for word in string.gmatch(tostring(message), "(%w+)") do
	if tostring(tonumber(word)) == word then
		number = tonumber(word)
	end
end
if (parameters.setprice == true) then
	local item_db = getItemWithItemId(getCreatureName(cid), shop_last_item[cid].itemid, shop_last_item[cid].subType)
	if number < 1 then
		number = 1
	end
	changePriceOfItem(getCreatureName(cid), shop_last_item[cid].itemid, shop_last_item[cid].subType, number)
	item_db = getItemWithItemId(getCreatureName(cid), shop_last_item[cid].itemid, shop_last_item[cid].subType)
	if item_db.subType > 0 then
		npcHandler:say('Actually you have ' .. item_db.count ..' ' .. item_db.item_name .. ' (charges: ' .. item_db.subType .. ') in offer, price for each is now ' .. item_db.price .. ' gp. Say {set price} to change price of items.', cid)
	else
		npcHandler:say('Actually you have ' .. item_db.count ..' ' .. item_db.item_name .. ' in offer, price for each is now ' .. item_db.price .. ' gp. Say {set price} to change price of items.', cid)
	end
	shop_last_item[cid] = {}
	npcHandler:resetNpc()
else
	if number > 0 then -- player said offer ID
		local item_db = getItemWithId(number)
		if item_db.id == 0 then
			npcHandler:say('I don\'t know offer with ID >' .. number .. '<, say {set price} to view list of your items IDs.', cid)
			npcHandler:resetNpc()
			return true
		end
		if item_db.name ~= getCreatureName(cid) then
			npcHandler:say('It\'s not offer of your item, say {set price} to view list of your items IDs.', cid)
			npcHandler:resetNpc()
			return true
		end
		if item_db.subType > 0 then
			npcHandler:say('Actually you have ' .. item_db.count ..' ' .. item_db.item_name .. ' (charges: ' .. item_db.subType .. ') in offer, price for each is ' .. item_db.price .. ' gp. Do you want to change price? Say {no} or {price xxx}, where xxx is number of gp.', cid)
		else
			npcHandler:say('Actually you have ' .. item_db.count ..' ' .. item_db.item_name .. ' in offer, price for each is ' .. item_db.price .. ' gp. Do you want to change price? Say {no} or {price xxx}, where xxx is number of gp.', cid)
		end
		shop_last_item[cid] = {itemid = item_db.itemid, subType = item_db.subType}
	else -- player ask for ID
		local offer = getOfferOfPlayer(getCreatureName(cid))
		if #offer == 0 then
			npcHandler:say('You don\'t have any item in offer. You can\'t change price.', cid)
		else
			selfSay("Your offers info:\n", cid)
			for i = 1, #offer do
				if offer[i].subType > 0 then
					selfSay(offer[i].count .. "x " .. offer[i].item_name .. " (charges: " .. offer[i].subType .. ") - price: " .. offer[i].price .. " gp/each - offer ID: " .. offer[i].id, cid)
				else
					selfSay(offer[i].count .. "x " .. offer[i].item_name .. " - price: " .. offer[i].price .. " gp/each - offer ID: " .. offer[i].id, cid)
				end
			end
			npcHandler:say('To change price of item say {set price xx}. Where xx is ID of item.', cid)
		end
		npcHandler:resetNpc()
	end
end
return true
end

function getCashBalanceFromItemsNPC(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
	return false
end
npcHandler:say('I have ' .. getCash(getCreatureName(cid)) .. ' gp for you.', cid)
return true
end

function getCashFromItemsNPC(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
	return false
end
local player_cash = getCash(getCreatureName(cid))
if player_cash > 0 then
	if doPlayerAddMoney(cid, player_cash) ~= TRUE then
		npcHandler:say('I can\'t give you cash. Try again.', cid)
	else
		setCash(getCreatureName(cid), 0)
		npcHandler:say(player_cash ..' for you. It was a pleasure doing business with you.', cid)
	end
else
	npcHandler:say('I don\'t have cash for you.', cid)
end
return true
end


local sellitemprice1 = KeywordNode:new({'no'}, addItemToOfferNPC, {setprice = false})
local sellitemprice2 = KeywordNode:new({'price'}, addItemToOfferNPC, {setprice = true})
local sellitemprice3 = KeywordNode:new({'gp'}, addItemToOfferNPC, {setprice = true})

local setitemprice1 = KeywordNode:new({'no'}, setItemPriceNPC, {setprice = false})
local setitemprice2 = KeywordNode:new({'price'}, setItemPriceNPC, {setprice = true})
local setitemprice3 = KeywordNode:new({'gp'}, setItemPriceNPC, {setprice = true})

keywordHandler:addKeyword({'offer of'}, showOfferOfPlayerNPC, {})
keywordHandler:addKeyword({'search'}, showOfferOfItemNPC, {})
local node = keywordHandler:addKeyword({'add item'}, addItemToOfferNPC, {})
node:addChildKeywordNode(sellitemprice1)
node:addChildKeywordNode(sellitemprice2)
node:addChildKeywordNode(sellitemprice3)
local node = keywordHandler:addKeyword({'set price'}, setItemPriceNPC, {setprice = false})
node:addChildKeywordNode(setitemprice1)
node:addChildKeywordNode(setitemprice2)
node:addChildKeywordNode(setitemprice3)
local node = keywordHandler:addKeyword({'change price'}, setItemPriceNPC, {setprice = false})
node:addChildKeywordNode(setitemprice1)
node:addChildKeywordNode(setitemprice2)
node:addChildKeywordNode(setitemprice3)
keywordHandler:addKeyword({'my offer'}, showOfferOfPlayerNPC, {})
keywordHandler:addKeyword({'get item'}, showOfferOfPlayerNPC, {})
keywordHandler:addKeyword({'balance'}, getCashBalanceFromItemsNPC, {})
keywordHandler:addKeyword({'get cash'}, getCashFromItemsNPC, {})
keywordHandler:addKeyword({'withdraw'}, getCashFromItemsNPC, {})
local node = keywordHandler:addKeyword({'how to use'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'What you want to do? Say {add my item to offer}, {get my item from offer}, {check how much money from items I have}, {get my cash from items}, {change price of item in offer}, {buy item of other player} or {search item}.'})
node:addChildKeyword({'add my item to offer'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'First put your item in left hand (under BP slot), then say {add item xx} where xx is number of items that you want add to offer, then NPC will ask you for price, say {price yy}, where yy is price for 1 item.'})
node:addChildKeyword({'get my item from offer'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Say {my offer} or {get item} to view list of your items, all items will have price 1 gp, but when you press "Buy" you will get your item for free.'})
node:addChildKeyword({'check how mu'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Say {balance} to view how much money NPC has for you.'})
node:addChildKeyword({'get my cash'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Say {get cash} or {withdraw} to get your cash from NPC.'})
node:addChildKeyword({'change price of item in offer'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Say {change price} or {set price} to view list of your items, prices and offer IDs. Say {change price xx} or {set price xx}, where xx is item offer ID, then NPC will show you item name and ask for new price, say {price yy}, where yy is new price.'})
node:addChildKeyword({'buy item of other player'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Say {offer of Xx Yy}, where Xx Yy is name of player. NPC will show you offer of this player in trade window.'})
node:addChildKeyword({'search item'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Say {search Xxx Yyy}, where Xxx Yyy is name of item. Npc will show you few cheapest offers and names of players. That say {offer of Xxx}, where Xxx is name of player to view his offer and buy item.'})
npcHandler:setMessage(MESSAGE_GREET, "Greetings |PLAYERNAME|. I can trade your items with other players. Say {how to use} if you don\'t know commands.")

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())  

 

2. Agora vá em data/npc e crie um arquivo LUA com o nome de Auctioner.lua, apague tudo que tem dentro e coloque isso:

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Auctioner" script="data/npc/scripts/Auctioner.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="290" head="39" body="122" legs="125" feet="57" addons="0"/>
<parameters />
</npc>

 

3. Vá em sua database, e crie a tabela a seguir:

CREATE TABLE `ots_playersshopsystem` (
 `id` int(11) NOT NULL auto_increment,
 `name` varchar(255) NOT NULL,
 `item_name` varchar(255) NOT NULL,
 `itemid` int(11) NOT NULL,
 `subType` int(11) NOT NULL,
 `count` int(11) NOT NULL,
 `price` int(11) NOT NULL,
 PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;  

 

 

 

Feito isso, seu Auctioner estará pronto.

Lembrando que os créditos são do usuário Gesior.pl do fórum OTLand.

Te ajudei? REP+

Qualquer dúvida poste aqui.

 

 

Abraços.

Editado por DaviBRDeaTh
Link para o comentário
Compartilhar em outros sites

Uau, ja vi 2 Auction house por talk aqui, mas 1 n funciono, e o outro n testei, mas por npc me surpreendeu, achei a idéia bem melhor =)

 

Quandi vi isso na OTLand me desesperei, eu tava doidinho atras de um desse, se funciono da REP+ ai :D

Link para o comentário
Compartilhar em outros sites

  • 3 weeks later...
  • 4 weeks later...

é um idiota mesmo esse cara,só ir direto no tópico pegar o contéudo e postar novamente aqui.

Quer ganhar reputação ou sei lá quer ser adorado por todos só porque copio um sistema,criança é foda

Editado por LordJoker
Link para o comentário
Compartilhar em outros sites

  • 1 year later...
  • 8 months later...
×
×
  • Criar Novo...