View Single Post
  #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