Page 1 of 1

ContextMenu on POL97 (Working!!)

Posted: Mon Nov 24, 2008 7:33 am
by Hannibal29
Hi guys, this is my first post on the PolServer community.
Sorry by my bad english, i am brazilian and i still learning the english language.
I will post the steps to make contextmenus works on your POL97 shard.

Image

Step 1 - servspecopt.cfg

Code: Select all

UOFeatureEnable=0x28
Step 2 - uopackets.cfg

Code: Select all

Packet 0xBF
{
  Length           variable
  SubCommandOffset 4
  SubCommandLength 1
}  

SubPacket 0xBF     
{
  SubCommandID     0x13
  ReceiveFunction  handlePopups:HandlePopupRequest
}

SubPacket 0xBF
{                     
  SubCommandID     0x15
  ReceiveFunction  handlePopups:HandlePopupResponse
}
Step 3 - handlePopups.src

Code: Select all

use uo;
use polsys;        
                                                
program Install()
  Print("INSTALLING: PopupMenus system handler..");
  return 1;
endprogram
                        
exported function HandlePopupRequest(Who, byref Packet)
  var WhatSerial := Packet.GetInt32(5);
  var WhatObject := SystemFindObjectBySerial(WhatSerial, SYSFIND_SEARCH_OFFLINE_MOBILES);
  // Define the target for the context menu
  if(WhatObject == Who)
    ShowMenuSelf(Who, Packet, WhatSerial);  
  endif
  return 0;                 
endfunction                   

exported function HandlePopupResponse(Who, byref Packet)
  var WhatSerial   := Packet.GetInt32(5);
  var WhatObject   := SystemFindObjectBySerial(WhatSerial, SYSFIND_SEARCH_OFFLINE_MOBILES);
  var ResultPrefix := Packet.GetInt8(9);
  var ResultSuffix := Packet.GetInt8(10);
  case(ResultPrefix)                              
    0x00: ReceiveMenuSelf(Who, WhatObject, ResultSuffix);
  endcase
  return 0;
endfunction

function ShowMenuSelf(Who, byref Packet, AboveObject)
  var Menu := CreateNewMenu();
  MenuAddItem(Menu, 0x0001, 6123); 
  SendContextMenu(Who, Menu, AboveObject, Packet);
endfunction 

function ReceiveMenuSelf(Who, Object, Result)
  case(Result)             
    0x01: OpenPaperdoll(Who, Who);
  endcase          
endfunction

function CreateNewMenu()  
  return array;     
endfunction      

function MenuAddItem(byref Menu, Result, Text, Flags := 0x20, Color := 0xFFFF)
  Menu.append({Result, Text, Flags, Color}); 
endfunction  

function SendContextMenu(Who, byref Menu, AboveObject, byref Packet)
  if(!Len(Menu))
    return;                
  endif
  Packet.SetSize(12 + (Len(Menu) * 8));
  Packet.SetInt16(03, 0x14);
  Packet.SetInt8(05, 0x00);
  Packet.SetInt8(06, 0x01);
  Packet.SetInt32(07, AboveObject); 
  Packet.SetInt8(11, Len(Menu));
  var Index := 12;
  foreach Item in Menu                                    
    Packet.SetInt16(Index, Item[1]);
    Index := Index + 2;             
    Packet.SetInt16(Index, Item[2]);
    Index := Index + 2;               
    Packet.SetInt16(Index, Item[3]);
    Index := Index + 2;             
    Packet.SetInt16(Index, Item[4]);
    Index := Index + 2;             
  endforeach
  Packet.SendPacket(Who);
endfunction
This is my first work with packets :)
I spend many hours to make this pkg works!!

Re: ContextMenu on POL97 (Working!!)

Posted: Mon Nov 24, 2008 11:48 am
by *Edwards
Welcome :)

Re: ContextMenu on POL97 (Working!!)

Posted: Mon Nov 24, 2008 1:02 pm
by Austin
Awesome!

Re: ContextMenu on POL97 (Working!!)

Posted: Thu Nov 27, 2008 1:06 am
by Yukiko
Very nice!
And we are truly happy you've joined the POL Community.

Re: ContextMenu on POL97 (Working!!)

Posted: Thu Nov 27, 2008 8:52 pm
by Luth
Great work. I was able to integrate this into my game pretty easily. Much obliged! :D

I've attached my implementation of the ContextMenu system here. The CMR numbers are indexes into cliloc.enu at offset 3000000 + CMR. So CMR 6122 will display cliloc index 6122, or "Open".

Re: ContextMenu on POL97 (Working!!)

Posted: Thu Mar 12, 2009 2:11 am
by OldnGrey
Hmm.
When I use this I get the menus appearing over the top of the name of the npc.
The screencap in the first post in this topic shows the name in yellow NEXT to the popupmenus.
On mine they are printed over the top of each other.

The curious thing is that if I click on the npc a second time they appear next to each other as they should.

Turning off the megacliloc makes no difference.

Client 5.0.9.1, core 097.3, UOFeatureEnable=0x1a8

Re: ContextMenu on POL97 (Working!!)

Posted: Fri Jun 09, 2017 11:01 pm
by Yukiko
Reviving an old thread here.
I get a server crash at character log-in with this package enabled. I'll have to build a debug version of the Core and submit the mini-dump file I guess to get more help.

Re: ContextMenu on POL97 (Working!!)

Posted: Fri Jun 09, 2017 11:11 pm
by Yukiko
Well, I think I fixed my problem. I had put uopacket.cfg in the config folder for the contextmenu phg and was getting the crash. I moved it out of the config folder into contextmenu proper and didn't get a crash...yet. So I guess uopacket.cfg is like pkg.cfg. It needs to be in the main folder for the package. Good to know.

Re: ContextMenu on POL97 (Working!!)

Posted: Fri Jun 09, 2017 11:42 pm
by Yukiko
Nope. Not fixed. I had disabled the pkg temporarily and forgot about it. Still getting crash on character login.