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

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

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 03-13-2016, 06:04 PM
ghanja's Avatar
ghanja
Dragon
 
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
Default

Heading out the door, so untested to say the least:

makecustompetnamestable.sql
Code:
DROP TABLE IF EXISTS `custom_petnames`;
CREATE TABLE `custom_petnames` (
  `charid` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  PRIMARY KEY (`charid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
/quests/default.pl (insert into existing)
Code:
sub EVENT_SPAWN {
	if (!$npc || $npc->GetSwarmOwner()) {
		if ($npc->GetOwnerID()) {
			if (defined plugin::FindPetName($npc->GetOwnerID())) {
				$npc->TempName(plugin::FindPetName($npc->GetOwnerID()));
			}
		}
	}
}
/quests/global/global_player.pl (insert into existing, working off of Tabasco's original code)
Code:
sub EVENT_SAY {
    if($text =~/^!petname/i) {
        my $pid = $client->GetPetID();
        my $pet = $entity_list->GetMobByID($pid);
        if($pet) {
            ($cm, $petname) = split(/\ /, $text, 2);
            if ($petname =~ m/[^a-zA-Z]/){
				$pet->TempName($petname);
				if (plugin::FindPetName($charid) != $petname) {
					plugin::EnterPetName($charid,$petname)
				}
			$client->Message(315, "Your pet name has been changed.");
            $client->Message(315, "This is a family friendly server.  Please be considerate when choosing a pet name.");
			}
        }
    }
}
/plugins/custompetnames.pl
Code:
sub EnterPetName {
	my $dbh = plugin::MySQL_Connect();
	$dbh->do("DELETE FROM `custom_petnames` WHERE `charid` = '$_[0]'");
	$sth = $dbh->prepare("INSERT INTO `custom_petnames` (`charid`, `petname`) VALUES (?, ?)");
	$sth->execute($_[0], $_[1]);
	$sth->finish();
	$dbh->disconnect();
}

sub FindPetName {
	my $entered_charid = $_[0];
	my $dbh = plugin::MySQL_Connect();
	my $sth = $dbh->prepare("SELECT `petname` FROM `custom_petnames` WHERE `charid` = '".$entered_charid."' LIMIT 1;");
	$sth->execute();
	@data = $sth->fetchrow_array();
	$sth->finish();
	$dbh->disconnect();
	if ($data[0] == NULL) {
		return NULL;
	} else {
		return ($data[0]);
	}
}
May or may not work, untested and far from a master coder of things. But had 10 minutes before I had to leave out, it may help someone out. I'm very interested to see what Kingly draws up. *Thank you Kingly, I never bothered looking at the source to see qglobal value was const *char anymore (just sorta went by the way I knew them to be -- reading the changeme = a good thing), well then. My way is superfluous in that case.
Reply With Quote
 


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 02:43 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 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3