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 06-21-2016, 02:44 PM
DanCanDo's Avatar
DanCanDo
Discordant
 
Join Date: May 2016
Location: Above Hell
Posts: 400
Default Setting Status ?

Just a quick question,

I was looking through the function list to see if there was something I could
add to an npc script to set a players account status. For example, raise it
from 0 to 1 ?
What my intentions are here, is having the bot cmd access at 1 and then an
npc will raise the player status to 1 when required level is met, giving the
player access to the bots.
Reply With Quote
  #2  
Old 06-21-2016, 09:13 PM
ghanja's Avatar
ghanja
Dragon
 
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
Default

This assumes you have Perl DBI installed.


/plugins/statusupdate.pl
Code:
sub UpdateStatus {
	my $idargument = $_[0];
	my $statuslevel = $_[1];
	my $dbh = plugin::MySQL_Connect();
	my $query = "UPDATE account SET status = ".$statuslevel." WHERE id = ".$idargument.";";
	$dbh->do($query);
	$dbh->disconnect();
	$client->UpdateAdmin();
}

return 1;
Code:
sub EVENT_SAY {
	if ($status == 0) {
		UpdateStatus($client->AccountID(),1);
	}
}
You could substitute 1 for whatever status level you want of course (0-255 anyway).

Last edited by ghanja; 06-21-2016 at 09:13 PM.. Reason: code block fail
Reply With Quote
  #3  
Old 06-22-2016, 09:40 AM
DanCanDo's Avatar
DanCanDo
Discordant
 
Join Date: May 2016
Location: Above Hell
Posts: 400
Default

Thanks ghanja for that snippet.
I'm still trying to get it to work though, (chuckle)
I created the plugin (statusupdate.pl) and put it in the plugins folder.(restarted server)
On the npc, I had to add a $text and $level along with the call for status. This is what
I've got so far.

Code:
sub EVENT_SAY {
	if (($text=~/hail/i) && ($status == 0) && ($ulevel=>10)) {
		UpdateStatus($client->AccountID(),1);
	}
}
I've tried using plugin::UpdateStatus , and plugin::statusupdate , but so far no go.
I'll keep piddling around with it though.
Reply With Quote
  #4  
Old 06-22-2016, 11:09 AM
ghanja's Avatar
ghanja
Dragon
 
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
Default

I copy pasted mostly from a portion of code I already had written (however it was just a subroutine in a player.pl), added the $statuslevel and gave it a plugin filename. Sorry for not placing the plugin:: before UpdateStatus

Are you certain you have Perl DBI installed?

Also, I would up your logging (its my preferred setting anyway), do this in game:
Code:
#logs set gmsay 20 3
#logs reload_all
For testing, perhaps just keep it all confined within the NPC's script (for now). If it gives a warning about UpdateStatus being redefined (which would be good), just ignore it for now.

Code:
sub EVENT_SAY {
	if ($text=~/hail/i && $status == 0 && $ulevel=>10) {
		UpdateStatus($client->AccountID(),1);
	}
} 
	
sub UpdateStatus {
	my $idargument = $_[0];
	my $statuslevel = $_[1];
	my $dbh = plugin::MySQL_Connect();
	my $query = "UPDATE account SET status = ".$statuslevel." WHERE id = ".$idargument.";";
	$dbh->do($query);
	$dbh->disconnect();
	$client->UpdateAdmin();
}
Also providing this link, just in case:

http://wiki.eqemulator.org/p?Install..._other_Modules
Reply With Quote
  #5  
Old 06-22-2016, 07:50 PM
DanCanDo's Avatar
DanCanDo
Discordant
 
Join Date: May 2016
Location: Above Hell
Posts: 400
Default

Quote:
Originally Posted by ghanja View Post
Are you certain you have Perl DBI installed?
Yes, I have the DBI installed. Most of the custom quests/plugins work good
so far. I ran those logging cmds you suggested, seemed to show success in
the console, but when looking in logs, the only thing I am seeing related to
any quests is this :

Code:
[06-22-2016 :: 17:30:13] [Quests] Useless use of a variable in void context at quests/nexus/Bot_Giver.pl line 5.
Bot_Giver is the NPC I put that script on. Line 5 is part of the example gave
me. But that's the only thing showing up in any logs. I did contain it all on the
NPC, as you suggested. Still nothing happening. The only reaction I get from
NPC is on the "hail", it faces me, as normal.
Code:
sub EVENT_SAY {
	if (($text=~/hail/i && $status == 0 && $ulevel=>10)) {
		UpdateStatus($client->AccountID(),1);
	}
} #This is line 5
Reply With Quote
  #6  
Old 06-22-2016, 09:27 PM
joligario's Avatar
joligario
Developer
 
Join Date: Mar 2003
Posts: 1,490
Default

Quote:
Originally Posted by DanCanDo View Post
$ulevel=>10
Not sure if this is your issue, but you may want to relook this.
Reply With Quote
  #7  
Old 06-22-2016, 09:41 PM
ghanja's Avatar
ghanja
Dragon
 
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
Default

Quote:
Originally Posted by joligario View Post
Not sure if this is your issue, but you may want to relook this.
Hadn't even caught that fat comma, damnit. Good catch thank you Joli.
Reply With Quote
  #8  
Old 06-23-2016, 02:29 AM
DanCanDo's Avatar
DanCanDo
Discordant
 
Join Date: May 2016
Location: Above Hell
Posts: 400
Default

Quote:
Originally Posted by joligario View Post
Not sure if this is your issue, but you may want to relook this.
Thanks for noticing joligario. ghanja has been so kind to help figure out why
the script is not working.
Through his suggestions, the perl DBI has been reinstalled, the MySQL.pl has
been looked at, but still plugging away troubleshooting.
The rest of my scripts work, just not this new challenge.(chuckle)
Reply With Quote
  #9  
Old 06-24-2016, 07:55 PM
DanCanDo's Avatar
DanCanDo
Discordant
 
Join Date: May 2016
Location: Above Hell
Posts: 400
Default

Ok, got the DBI connection problem solved. simple little "technical difficulty" (chuckle)
Had to change "localhost" to 127.0.0.1 in the script.
Reply With Quote
  #10  
Old 06-24-2016, 09:11 PM
DanCanDo's Avatar
DanCanDo
Discordant
 
Join Date: May 2016
Location: Above Hell
Posts: 400
Default

Many thanks to ghanja for all the help in getting this "set status" goal achieved.
It's all working good now, but with a lot of help from ghanja in trouble shooting
the DBI connection problem.(he gave me some debug scripts to run). Then, of
course the NPC script that he provided was the icing on the cake.
Reply With Quote
  #11  
Old 06-24-2016, 10:34 PM
DanCanDo's Avatar
DanCanDo
Discordant
 
Join Date: May 2016
Location: Above Hell
Posts: 400
Default

Just thought I would share what the end results were for an npc to set the
player status (increase). Just in case anyone else is interested in using it.
This is all with the great help of ghanja
In the plugins folder, the MySQL.pl file was renamed to MySQL(old).pl but you
can use whatever you want. A new one was created with the following:
You will have to EDIT the credentials for your DB.(database name, password)
Code:
sub MySQL_Connect {
	use DBI;
	use DBD::mysql;
	$dbh = DBI->connect("DBI:mysql:peq:127.0.0.1:3306;", "root", "password", {RaiseError => 1});
	return $dbh;
}

return 1;
Then the script was put on NPC. You can EDIT the value for whatever your
desired status is needed to be raised to. (this one raises it from 0 to 1)
It also requires a level of 10 before the NPC will raise it for you. You can edit
that to your likings. I've tested this 3 times now and all working good.
Code:
sub EVENT_SAY {
	if ($text=~/hail/i && $status == 0 && $ulevel >= 10) {
		my $actid = $client->AccountID();
		UpdateStatus($actid,1);
		quest::say ("Welcome $name Your status has been raised to 1.");
	}
} 
	
sub UpdateStatus {
	my $idargument = $_[0];
	my $statuslevel = $_[1];
	my $dbh = plugin::MySQL_Connect();
	my $query = "UPDATE account SET status = ".$statuslevel." WHERE id = ".$idargument.";";
	$dbh->do($query);
	$dbh->disconnect();
	$client->UpdateAdmin();
}
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 07:54 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