ContextMenu on POL97 (Working!!)

Post your Custom Scripts or Packages.

Moderator: POL Developer

Post Reply
User avatar
Hannibal29
New User
Posts: 6
Joined: Mon Nov 24, 2008 7:08 am
Location: Gravataí - RS - Brazil

ContextMenu on POL97 (Working!!)

Post by Hannibal29 » Mon Nov 24, 2008 7:33 am

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!!

User avatar
*Edwards
Forum Regular
Posts: 301
Joined: Fri Dec 28, 2007 11:19 pm
Location: Montreal, Canada
Contact:

Re: ContextMenu on POL97 (Working!!)

Post by *Edwards » Mon Nov 24, 2008 11:48 am

Welcome :)

User avatar
Austin
Former Developer
Posts: 615
Joined: Wed Jan 25, 2006 2:30 am
Contact:

Re: ContextMenu on POL97 (Working!!)

Post by Austin » Mon Nov 24, 2008 1:02 pm

Awesome!
-Austin

Yukiko
Distro Developer
Posts: 2524
Joined: Thu Feb 02, 2006 1:41 pm
Location: San Antonio, Texas
Contact:

Re: ContextMenu on POL97 (Working!!)

Post by Yukiko » Thu Nov 27, 2008 1:06 am

Very nice!
And we are truly happy you've joined the POL Community.
Sincerely,
Yukiko

I would tell you a UDP joke but you might not get it.

Titus 2:13

Luth
Grandmaster Poster
Posts: 200
Joined: Mon Jan 30, 2006 8:10 am
Contact:

Re: ContextMenu on POL97 (Working!!)

Post by Luth » Thu Nov 27, 2008 8:52 pm

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".
Attachments
contextMenus.zip
(1.72 KiB) Downloaded 158 times

User avatar
OldnGrey
POL Expert
Posts: 657
Joined: Sat Feb 04, 2006 6:26 pm
Contact:

Re: ContextMenu on POL97 (Working!!)

Post by OldnGrey » Thu Mar 12, 2009 2:11 am

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

Yukiko
Distro Developer
Posts: 2524
Joined: Thu Feb 02, 2006 1:41 pm
Location: San Antonio, Texas
Contact:

Re: ContextMenu on POL97 (Working!!)

Post by Yukiko » Fri Jun 09, 2017 11:01 pm

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.
Sincerely,
Yukiko

I would tell you a UDP joke but you might not get it.

Titus 2:13

Yukiko
Distro Developer
Posts: 2524
Joined: Thu Feb 02, 2006 1:41 pm
Location: San Antonio, Texas
Contact:

Re: ContextMenu on POL97 (Working!!)

Post by Yukiko » Fri Jun 09, 2017 11:11 pm

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.
Sincerely,
Yukiko

I would tell you a UDP joke but you might not get it.

Titus 2:13

Yukiko
Distro Developer
Posts: 2524
Joined: Thu Feb 02, 2006 1:41 pm
Location: San Antonio, Texas
Contact:

Re: ContextMenu on POL97 (Working!!)

Post by Yukiko » Fri Jun 09, 2017 11:42 pm

Nope. Not fixed. I had disabled the pkg temporarily and forgot about it. Still getting crash on character login.
Sincerely,
Yukiko

I would tell you a UDP joke but you might not get it.

Titus 2:13

Post Reply