PenUltima Online

It is currently Sat Sep 06, 2008 5:08 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: All Name PacketHook (0x98)
PostPosted: Mon Mar 13, 2006 4:48 pm 
Offline

Joined: Tue Feb 07, 2006 3:32 pm
Posts: 97
Location: Pittsburgh, Pennsylvania
Not sure when this was added to the 2D client, but it exists in at least version 4.0.6a.

Here is the code (you can download it below as well)

NOTE: This feature is now built into all POL versions/builds after "097-2007-01-04-RC2-Coregina". For previous versions/builds you'll still need this packet hook. Regardless though, using the packet hook will allow you greater customization on how this feature is handled. You decide.

Code:
////////////////////////////////////////////////////////////////////////////////////////////////////
//
//  Name:    All Names Hook
//  Version: 1.0
//  Author:  Danielle Elora
//
//  Purpose: Responds to the "all names" packet (0x98) sent by the client when pressing Ctrl+Shift.
//
//   PACKET DETAILS:
//
//   BYTE[1] cmd
//   BYTE[2] blocksize
//   BYTE[4] ID
//   If (server-reply)
//   BYTE[30] name (0 terminated)
//
//   Client request has 7 bytes, server-reply 37. Client already knows item names, and only
//   askes for mobiles names, hence ID is always a mobile serial.
//
////////////////////////////////////////////////////////////////////////////////////////////////////

use uo;
use polsys;

const OFFSET_MSGTYPE := 0;
const OFFSET_MSGLEN := 1;
const OFFSET_ID := 3;
const OFFSET_NAME := 7;

program all_names()
  Print("PacketHook: Hooking Incoming All Names Shortcut...");
  return 1;
endprogram

exported function handle_allnames(who, byref packet)

   // Pull the mobile id from the incoming packet.
   var mobile_id := packet.GetInt32(OFFSET_ID);

   // Lookup the mobile referenced in the packet...
   var mobile := SystemFindObjectBySerial(mobile_id);

   // Initialize the packet
   var new_packet := CreatePacket(0x98, 37);
   
   // Set the packet length
   new_packet.SetInt16(OFFSET_MSGLEN, 37);

   // Set the mobile id
   new_packet.SetInt32(OFFSET_ID, mobile_id);

   // Set the mobile name
   new_packet.SetString(OFFSET_NAME, mobile.name, 1);

   // Send the packet back to the player
   new_packet.SendPacket(who);

  // Since the core doesn't understand this packet, might as well block it from the core anyway.
  return 1;

endfunction


Attachments:
File comment: All Names Packethook (0x98) -- POL 96 REQUIRED!
all_names.rar [1.51 KiB]
Downloaded 102 times

_________________
Image
Image <-- 50% off setup fees! Use PromoCode "NIGHTSCAPE"
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl