Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Plugins & Mods

Quests::Plugins & Mods Completed plugins for public use as well as modifications.

Reply
 
Thread Tools Display Modes
  #1  
Old 01-27-2010, 06:07 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default Plugin::RandomRange()

Here is another very simple plugin I made that others might find useful. It works similar to the quest::ChooseRandom() command, accept this selects randomly from a range of numbers instead of a list. It is useful if you want to select a random from 1-100 or something. You can easily do exactly what this script does just by using the perl rand() command, but I think this make selecting a range a tad bit easier.

Here are the steps to add this plugin to your server:

1. Open notepad, or whatever text editor you prefer.

2. Copy and paste the following code into Notepad:
(Note: Edited in the updated version)
Code:
#Usage: plugin::RandomRange(minvalue, maxvalue);

sub RandomRange {

	my $MinRandom = $_[0];
	my $MaxRandom = $_[1];

	my $RandomResult = int(rand(($MaxRandom + 1) - $MinRandom)) + $MinRandom;
	if ($RandomResult > $MaxRandom)
	{
		return $MaxRandom;
	}
	return $RandomResult;

}

return 1;	#This line is required at the end of every plugin file in order to use it
3. Save that file to your server /plugins/ folder and name it "randomrange.pl".

4. Do a #questreload and the new plugin should be ready for use

To use it, just do something like this in your script:
Code:
my $randomnumber = plugin::RandomRange(10, 100);
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!

Last edited by trevius; 11-29-2010 at 08:20 AM..
Reply With Quote
  #2  
Old 01-27-2010, 01:30 PM
Secrets's Avatar
Secrets
Demi-God
 
Join Date: May 2007
Location: b
Posts: 1,447
Default

I think I love you trevius.

I've wanted something like this forever, thanks!
Reply With Quote
  #3  
Old 07-11-2010, 06:23 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Minor correction for this plugin, since it always rounds down:

Code:
#Usage: plugin::RandomRange(minvalue, maxvalue);

sub RandomRange {

	my $MinRandom = $_[0];
	my $MaxRandom = $_[1];

	my $RandomResult = int(rand(($MaxRandom + 1) - $MinRandom)) + $MinRandom;
	if ($RandomResult > $MaxRandom)
	{
		return $MaxRandom;
	}
	return $RandomResult;

}
Without the + 1 there, the old way wasn't able to reach the max random number.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!

Last edited by trevius; 11-29-2010 at 08:19 AM..
Reply With Quote
  #4  
Old 11-08-2010, 03:06 PM
revloc02c's Avatar
revloc02c
Hill Giant
 
Join Date: Aug 2010
Location: UT
Posts: 215
Default

Quote:
Originally Posted by trevius View Post
4. Do a #questreload and the new plugin should be ready for use
Hey, I am new and learning the ropes here. Just wondering if the command "#questreload" is a GM command that you use in game (instead of shutting down EQEmu and then restarting it again, which is what I always do to test changes I made), or have I misunderstood?

Thanks
Reply With Quote
  #5  
Old 11-09-2010, 04:16 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Yeah, that is a GM command you use from in-game. You can always do a #help to see a list of all of the commands your account has access to. In order to get access to all commands, your account status should be 250. You can do "#help quest" to see all of the commands that contain "quest" in them as well.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #6  
Old 12-13-2010, 06:41 AM
revloc02c's Avatar
revloc02c
Hill Giant
 
Join Date: Aug 2010
Location: UT
Posts: 215
Default

Wow. Works like a charm. Thank you, I am rolling now.
Reply With Quote
  #7  
Old 12-13-2010, 07:09 AM
Akkadius's Avatar
Akkadius
Administrator
 
Join Date: Feb 2009
Location: MN
Posts: 2,071
Default

Quote:
Originally Posted by revloc02c View Post
Wow. Works like a charm. Thank you, I am rolling now.

Just a little delayed response I think.
Reply With Quote
Reply


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 11:59 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 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3