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 09-26-2015, 01:12 AM
Trackye
Sarnak
 
Join Date: Feb 2008
Posts: 87
Default Large SQL statements in a quest?

Is it possible to do something like this

Code:
use DBI;
#database configuration information
$db="DATABASECORRECT";
$host="localhost";
$user="USERCORRECT";
$password="PASSWORDCORRECT"; 

#connect to MySQL database
my $dbh = DBI->connect ("DBI:mysql:database=$db:host=$host", $user, $password);



sub EVENT_SAY 
{ 
	my $wares = quest::saylink("wares", 1);
	if($text=~/Hail/i)
	{
		plugin::Whisper("Would you like me to reset my $wares ?") ;
	}
	if($text=~/wares/i)
	{
	plugin::Whisper("Restocking now!") ;
	my $Sql1 = $dbh->prepare("Delete from Merchantlist_temp where npcid =999260;");
	$Sql1->execute( );
	plugin::Whisper("Restock complete!") ;
	}
}
But I need it to run approximately 60 Sql statements?
Eventually on a timer like every 2 hours? I only set it up as a manual Hail so i could test it.

Everything works up until clicking Wares. The NPC says restocking now and then nothing

Questerrors command shows the Npc then a number of Boxes or something after that...

Any help with this would be greatly appreciated.
Reply With Quote
  #2  
Old 09-26-2015, 01:25 AM
demonstar55
Demi-God
 
Join Date: Apr 2008
Location: MA
Posts: 1,165
Default

PEQ had some quests at some point in time that did SQL stuff, it was HORRIBLE for performance and would lock the zone for a bit.
Reply With Quote
  #3  
Old 09-28-2015, 11:38 AM
N0ctrnl's Avatar
N0ctrnl
Discordant
 
Join Date: Jan 2007
Posts: 443
Default

The MySQL plugin allows for direct DB access, if that's the way you wanna go.
Reply With Quote
  #4  
Old 09-28-2015, 11:42 AM
Akkadius's Avatar
Akkadius
Administrator
 
Join Date: Feb 2009
Location: MN
Posts: 2,071
Default

Quote:
Originally Posted by demonstar55 View Post
PEQ had some quests at some point in time that did SQL stuff, it was HORRIBLE for performance and would lock the zone for a bit.
DBI can be just fine if its used right.
Reply With Quote
  #5  
Old 09-28-2015, 01:22 PM
Trackye
Sarnak
 
Join Date: Feb 2008
Posts: 87
Default

Could you possibly give me some more information as to how I would do that correctly please? lol

I do not seem to be able to get the above code to work although it gives no errors in a Pearl check for Syntax.
Reply With Quote
  #6  
Old 09-28-2015, 03:10 PM
N0ctrnl's Avatar
N0ctrnl
Discordant
 
Join Date: Jan 2007
Posts: 443
Default

I looked at Akkadius' leaderboard plugin. It makes plenty of database calls to use as a reference.

http://www.eqemulator.org/forums/showthread.php?t=37650
Reply With Quote
  #7  
Old 09-28-2015, 03:36 PM
Kingly_Krab
Administrator
 
Join Date: May 2013
Location: United States
Posts: 1,589
Default

Do you have Perl DBI and Perl DBD-MySQL installed?

http://www.eqemulator.org/forums/showthread.php?t=37955
Reply With Quote
  #8  
Old 09-28-2015, 04:26 PM
Trackye
Sarnak
 
Join Date: Feb 2008
Posts: 87
Default

Thank you I will read up and look into both of those.


-------EDIT----------

So having looked into both of those.

Im still stuck.

The download links for DBD-MYSQL are not working I found a copy of DBD-mysql.4.0.32 but cannot seem to get it to install correctly.

If i try to install DBI using PPM install DBI it says no packages missing So it seems I have that installed.
But the code still returns #questerrors with a number of squares as the subject.

I do also have the mysql plugin and the DB is configured correctly there.

What im currently working with...
Code:
sub EVENT_SAY 
{ 
	my $wares = quest::saylink("wares", 1);
	if($text=~/Hail/i)
	{
		plugin::Whisper("Would you like me to reset my $wares ?") ;
	}
	if($text=~/wares/i)
	{
	plugin::Whisper("Restocking now!") ;
	$connect = plugin::LoadMysql();
	$query = "Delete from Merchantlist_temp where npcid =999260;";
        $query_handle->execute;
	plugin::Whisper("Restock complete!") ;
	}
	    quest::debug("$DBI::errstr") if $DBI::errstr;
}
For this type of code would DBD-mysql be required or is DBI enough?
Or am I doing something foolish incorrectly?
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 12:20 PM.


 

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