Jump to content

Digest October-December

We talk about what was done and updated in the past month. We help keep abreast of events.

December November October

Servers monitoring and the Addons Editor

We present you two legends. All dreams come true.

Servers monitoring The Addons Editor

A statistics bot for Telegram

Convenient analytics right on your phone.

Read more

Game tooltips

Tooltips provide a way for 3rd party fansites and extensions to display detailed information on mouseover.

Read more

The Addons Updater

Let us to introduce the addons updating software and to share the details

Read more Download

Модернизация AutoSellGrey


Ramzesgool

Recommended Posts

Существует такой аддон AutoSellGrey(продажа серого лута вендору).

Вот его код:

--------------------------------------------------------------------------------
-- EVENT HANDLERS
--------------------------------------------------------------------------------

-- Событие обновления списка вещей у тогровца, список обновляется в том числе при выкупе серых вещей:
function OnVendorListUpdated()
local currentBagSize = avatar.InventoryGetBaseBagSlotCount()
for slotIndex = 0, currentBagSize - 1 do
local itemId = avatar.GetInventoryItemId( slotIndex )
if itemId then
local itemQuality = itemLib.GetQuality( itemId )
local quality = itemQuality and itemQuality.quality
if quality and quality == ITEM_QUALITY_JUNK and avatar.SellItemToVendor then
avatar.SellItemToVendor( itemId ) -- for AO 2.0.09+
end
end
end
-- Повторный вызов не нужен, иначе не получится выкупить нужные серые вещи:
common.UnRegisterEventHandler(OnVendorListUpdated, "EVENT_VENDOR_LIST_UPDATED")
end

-- Событие начала разговора с NPC, который может быть торговцем:
function OnTalkStarted()
-- common.LogInfo( "common", common.FormatInt( guild.GetEnableTime( ).d, "%d" ) )
-- common.LogInfo( "common", common.FormatInt( guild.GetEnableTime( ).m, "%d" ) )
-- common.LogInfo( "common", common.FormatInt( guild.GetEnableTime( ).y, "%d" ) )
-- Теперь можно начать следить за обновлением списка вещей у торговца:
common.RegisterEventHandler(OnVendorListUpdated, "EVENT_VENDOR_LIST_UPDATED")
end

-- Событие окончания разговора с NPC, который может быть торговцем:
function OnTalkStopped()
-- Теперь нужно прекратить следить за обновлением списка вещей у торговца, на всякий случай:
common.UnRegisterEventHandler(OnVendorListUpdated, "EVENT_VENDOR_LIST_UPDATED")
end

--------------------------------------------------------------------------------
-- INITIALIZATION
--------------------------------------------------------------------------------
function Init()
-- События:
common.RegisterEventHandler(OnTalkStarted, "EVENT_TALK_STARTED")
common.RegisterEventHandler(OnTalkStopped, "EVENT_TALK_STOPPED")
end
--------------------------------------------------------------------------------
Init()
--------------------------------------------------------------------------------

Как я полный дуб в Lua, мне требуется помощь). У автора аддона нет свободного времени и он не может помочь. Что мне бы хотелось увидеть:

например: открыт у меня диалог с вендором, в сумке появляется серый лут, он тут же продается, т.е. мне не придется закрыть и открыть диалог заново. Автор сказал, что это возможно. Жду помощи, заранее премного благодарен! :)

Link to comment
Share on other sites

Надо OnVendorListUpdated() делать при EVENT_CONTAINER_ITEM_ADDED если контейнер ITEM_CONT_INVENTORY.

Link to comment
Share on other sites

Огромное спасибо). Если надо, темку можете закрыть.

Я бы советовал еще проверять ведется ли взаимодействие с НПЦ (т.е. в начало функции вставить проверку) чтобы она не отрабатывала с ошибками когда ты просто бегаешь и подбираешь лут не торгуя с НПЦ.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using our site you agree to the Terms of Use