Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Q&A

Quests::Q&A This is the quest support section

Reply
 
Thread Tools Display Modes
  #1  
Old 01-10-2010, 04:45 AM
KLS
Administrator
 
Join Date: Sep 2006
Posts: 1,348
Default

Yeah plugins basically work like this. It's plugin not pluggin though.
Reply With Quote
  #2  
Old 01-10-2010, 05:13 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Oops, typo. I fixed it, thanks.

So, I am guessing that plugins get loaded into memory when the server starts? That would probably explain why they only update when the server is restarted. Any possibility of a way to make them update without a restart? If not, no biggie, but it would be helpful for testing purposes. I plan to add a decent number of plugins now that I know how to use them somewhat.

I will still need to figure out how the "shift" works for using the arguments, but it doesn't seem too hard. I also need to to play around with it and see how well it works for returning data. I have read that for certain perl features similar to this to work, the result of the file must always be true. That is why the files all end with "1;" as the last line. I am not sure that this is required for our plugin system yet, but some testing can probably determine that.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #3  
Old 01-10-2010, 05:24 AM
Derision
Developer
 
Join Date: Feb 2004
Location: UK
Posts: 1,540
Default

require does work.

If I put this in /tmp/myfunc.pl
Code:
sub MyFunc {
        quest::say("This is MyFunc().");
}

return 1;
And this in Guard_Bixby.pl

Code:
require ("/tmp/myfunc.pl");

sub EVENT_SAY {
        quest::say("Before call to MyFunc().");
        MyFunc();
        quest::say("After call to MyFunc().");
}
It works fine. Apparently you need the 'return 1' at the end of the required .pl file to tell Perl any initialisation code in that file executed OK, otherwise it returns this error:

Code:
/tmp/myfunc.pl did not return a true value at Guard_Bixby.pl line 1.
Reply With Quote
  #4  
Old 01-10-2010, 05:41 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Ahh sweet! Thanks Derision!

I kept messing with it, and did try returning a 1 result a couple of times, but I don't think I hit the right combo of how to get it to work. It may just have been that I didn't put a full path in the require and assumed that it would look for the file in the same directory as the NPC script was running from. That was on my list of things to try still, but hadn't gotten that far yet and not at home to test it out.

At the very least, using require should be a perfect way to test out plugins without having to reload the server to do so. Then, you just test them out with require and adjust the needed stuff afterward to use it as a plugin instead for the next restart.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #5  
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
  #6  
Old 01-10-2010, 02:42 PM
KLS
Administrator
 
Join Date: Sep 2006
Posts: 1,348
Default

Plugins should be reloading when you do a #reloadqst.
Reply With Quote
  #7  
Old 01-28-2010, 05:39 PM
joligario's Avatar
joligario
Developer
 
Join Date: Mar 2003
Posts: 1,498
Default

Quote:
Originally Posted by KLS View Post
Plugins should be reloading when you do a #reloadqst.
FYI: Yes, plugins reload fine from what I tested.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 07:46 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3