View Single Post
08/30/15, 07:46 PM   #3
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,019
1) NetCode, ZOS problem since beta.


2) NetCode, Zos and Addons dev problem.

Splitting a stack from GBank require a local transfer, Baetram, just look at roomba code!

in fact , I guess there is a quota and a queue for whole megaserver transactions after the gbank you are in.

let's say a friend move items in gbank, so yes, you'll wait, but on a guild where is nobody, you can also got this message, why ? because zos queue it with something else. maybe whole gbanks ! so let's test at 4AM (i often play at 4AM and i'm in euro). you can still have this problem. so its maybe queued with all "message"s, after all too many moves result in a "spam" ejection. that's purely zos problem.

but we need to handle it !



You init listeners at OPEN_GBANK, you unregisters at CLOSE_GBANK.
You set flag of gbankId at GBANK SELECTED
You set flag at ITEMS_READY, protect with a flag to avoid 3 times code runs.
at ITEMS_READY + 1.5s, you check if user got right to deposit/withdraw, if yes you add your hooks -- addmenu() to context menu items
callback of the addmenu :
need to check space left in your bag and in guild bank
if keybinding, protect against it cause to permissions.
store the slotindex of the item
register an EVENT_INVENTORY_SINGLE_SLOT_UPDATE to listen the coming of the item
set a flag "i will transfer things !" iteminstanceid is XXXXX (available in SHARED_INVENTORY data.itemInstanceId)
TransferFromGuildBank(slotindexinGBank)

then the function which listens with EVENT_INVENTORY_SINGLE_SLOT_UPDATE :

check if inventory, check if flag "i will transfer things" is activated, if yes, and not a newItem, check the itemInstanceId
if it's this one, you got it ! grab the slotIndex1, split it with RequestMoveItem().

You'll get a new EVENT_INVENTORY_SINGLE_SLOT_UPDATE, recheck itemInstanceId, if it's the same, it's your item, grab the slotIndex2 !
then register an EVENT_GUILD_BANK_ITEM_ADDED and a EVENT_GUILD_BANK_TRANSFER_ERROR

then TransferFromGuildBank(slotIndex1) !

then function of events should trigger :

if it's success :
check itemInstanceId again : if it's the good item, initiate the transfer of slotIndex2 if space is still ok

another event should pop !

if it's success :
check itemInstanceId again : if it's the good item, just unregisters everything.

in case of errors with EVENT_GUILD_BANK_TRANSFER_ERROR !

GUILD_BANK_NO_SPACE_LEFT : pooooommpp : someone else was quicker than you. stop everything, blame guildmate !
GUILD_BANK_ITEM_NOT_FOUND : damnit ! item was destroyed in bag, can be another miscoded addon !
GUILD_BANK_TRANSFER_PENDING : this error comes when you get the message I don't remember well playing in french .. "Waiting from previous transfer" or "Waiting from another transfer, move". Just wait and zo_callLater another move ! call transfermy1ststack() or transfermy2ndstack, depending on your flag + add a flag to do not retry indefinitely.

it should work, thts how I do in roomba
  Reply With Quote