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: Select all
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// 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