Page 1 of 1

ContextMenu without SetContextMenuHook

Posted: 13.01.2017 9:25
by Oct
On my shard we have a NPC that has a random ContextMenu (random Entries, random Positions).
I get the "bad" context-Menu in 50% of the time. Clicking "Crime and Punishment" will send my char to Jail.
  • Good:

    Code: Select all

    ContexMenu! MenuID $0002AF30 EntriesNumber: 04
    Entry0: Tag $0000 Flags: 0000 Text: Open Paperdoll
    Entry1: Tag $0001 Flags: 0000 Text: Quest Conversation
    Entry2: Tag $0002 Flags: 0000 Text: Buy
    Entry3: Tag $0003 Flags: 0000 Text: Sell
  • Good:

    Code: Select all

    ContexMenu! MenuID $0002AF30 EntriesNumber: 04
    Entry0: Tag $0000 Flags: 0000 Text: Open Paperdoll
    Entry1: Tag $0001 Flags: 0000 Text: Buy
    Entry2: Tag $0002 Flags: 0000 Text: Quest Conversation
    Entry3: Tag $0003 Flags: 0000 Text: Sell
  • Bad:

    Code: Select all

    ContexMenu! MenuID $0002AF30 EntriesNumber: 04
    Entry0: Tag $0000 Flags: 0000 Text: Open Paperdoll
    Entry1: Tag $0001 Flags: 0000 Text: Crime and Punishment
    Entry2: Tag $0002 Flags: 0000 Text: Buy
    Entry3: Tag $0003 Flags: 0000 Text: Sell
  • Bad:

    Code: Select all

    ContexMenu! MenuID $0002AF30 EntriesNumber: 04
    Entry0: Tag $0000 Flags: 0000 Text: Crime and Punishment
    Entry1: Tag $0001 Flags: 0000 Text: Open Paperdoll
    Entry2: Tag $0002 Flags: 0000 Text: Buy
    Entry3: Tag $0003 Flags: 0000 Text: Sell
How do I click "Quest Conversation" without re-opening the ContextMenu?

Re: ContextMenu without SetContextMenuHook

Posted: 13.01.2017 10:01
by drabadan
Oct wrote:On my shard we have a NPC that has a random ContextMenu (random Entries, random Positions).
I get the "bad" context-Menu in 50% of the time. Clicking "Crime and Punishment" will send my char to Jail.
How do I click "Quest Conversation" without re-opening the ContextMenu?
Hi! You should dynamically handle that, so the algorithm should be like:

Code: Select all

ClearContextMenu;
RequestContextMenu(VendorID : Cardinal);
GetContextMenu(var list : TStringList);

for i := 0 to list.Count-1 do
  if Pos('HERE WRITE WHAT YOU WANT, like Buy', list[i]) then
    begin
      SetContextMenuHook(VendorID : Cardinal; i);
      Break; 
    end;
i wrote the algotihm not the exact so code, so you should edit it before with all your values.

Re: ContextMenu without SetContextMenuHook

Posted: 13.01.2017 10:04
by Oct

Code: Select all

ClearContextMenu;
RequestContextMenu(VendorID : Cardinal);
GetContextMenu(var list : TStringList);

for i := 0 to list.Count-1 do
  if Pos('Quest Conversation', list[i]) then
    begin
      SetContextMenuHook(VendorID : Cardinal; i);
      Break;
    end;
"SetContextMenuHook" requests a new Context-Menu. The Entries in this (new) ContextMenu aren't the same as in the one before.
As You can see in my examples, this would sometimes let me activate "Crime and Punishment" by chance.

That's because all the above-mentioned ContextMenues where generated by 1 Vendor.

Re: ContextMenu without SetContextMenuHook

Posted: 13.01.2017 10:20
by drabadan
Oct wrote:

Code: Select all

ClearContextMenu;
RequestContextMenu(VendorID : Cardinal);
GetContextMenu(var list : TStringList);

for i := 0 to list.Count-1 do
  if Pos('Quest Conversation', list[i]) then
    begin
      SetContextMenuHook(VendorID : Cardinal; i);
      Break;
    end;
"SetContextMenuHook" requests a new Context-Menu. The Entries in this (new) ContextMenu aren't the same as in the one before.
As You can see in my examples, this would sometimes let me activate "Crime and Punishment" by chance.

That's because all the above-mentioned ContextMenues where generated by 1 Vendor.
if so - developer should add a command that not makes hook but sends context menu answer solo.

Re: ContextMenu without SetContextMenuHook

Posted: 13.01.2017 11:20
by Vizit0r
Oct wrote:"SetContextMenuHook" requests a new Context-Menu.
negative, it's hook for future incoming menu, and for pending menu as well.

Re: ContextMenu without SetContextMenuHook

Posted: 13.01.2017 18:28
by Oct
I found my error:
SetContextMenuHook(ID, EntryNumber) has to be SetContextMenuHook(ID, EntryNumber + 1)

To activate Entry0 you have to do SetContextMenuHook(ID, 1)...
A simple index offset :oops: