View Single Post
  #12  
Old 01-10-2010, 09:43 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Yup, I tested the require as Derision posted it, and it works perfectly as far as I can tell. Here is an example one that I made and tested tonight:

/home/eqemu/server/quests/functions/script_functions.pl
(note I added a new folder named "functions" to my quests directory)
Code:
# Script file to hold various subroutines and functions for multiple scripts to use

sub NPCWhisper {
	my $TextColor = 315;	#Set the Text Color for the Message (this one is beige)
	my $MyMessage = $_[0];	#Use the Message Supplied to the Function - "$_[0]" means to use the first argument given
	
	if ($client) {
		$client->Message($TextColor, "-");	#Spacer between Text messages to make them easier to read
		my $NPCName = $npc->GetCleanName();	#Get the clean name of the NPC sending the message
		$client->Message($TextColor, "$NPCName whispers, '$MyMessage'");	#Send a message to the player simulating a whisper directly to them from the NPC
	}
}

return 1;	#always leave this line at the end of the script_function.pl file as it is needed by require()
And here is an example NPC script that makes use of that function:

TestNPC.pl:
Code:
require '/home/eqemu/server/quests/functions/script_functions.pl';

sub EVENT_SAY { 
	if ($text=~/Hail/i)
	{
		NPCWhisper("Hello, $name.  How do you like my whisper?);
	}
}
The cool part about this function is that you can open almost any script and do a find/replace and replace the words "quest::say" with "NPCWhipster" and it should automatically convert all say messages into whispers that no one else can hear.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote