Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Custom

Quests::Custom Custom Quests here

Reply
 
Thread Tools Display Modes
  #1  
Old 03-14-2017, 10:57 PM
ghanja's Avatar
ghanja
Dragon
 
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
Default GM Functions in global_player.pl

Having offloaded a few of the EVENT_SAY functions on a few active servers, seems they come appreciated. I'm certain format/form/code in the below could be optimized, as some things have changed revisions here and there and, well, once they worked, I left them alone to work on other pending projects/code.

If nothing else, it may give others ideas or what not. I'm bored with no current project to work on, so, figured I'd post some junk. I love statistics, thus the reason for many of the qglobals flying around in otherwise (to most) unnecessary EVENT's.


quests/global/global_player.pl
Code:
## Dependencies: DBI Perl installation, Akka's Doors Manipulation and proper settings in your /plugins/LoadMysql.pl
## Why: Doors Manipulation 
$MINACCESSLEVELFORGMSTUFF = 80; ## ACCESS LEVEL NEEDED FOR GM STUFF
sub EVENT_SAY {
	if ($status >= $MINACCESSLEVELFORGMSTUFF) {
		@args = split(' ', $text);
		##
		## plugin::Doors_Manipulation_EVENT_SAY();  ## Great plugin from Akkadius commented out in case you dont use/have it (but you should!)
		##
		#######################################
		if ($text=~/#gmcommands/i) {
			$client->Message(315,"-----------------------------------");
			$client->Message(315,"Custom Commands Available:");
			$client->Message(315,"-----------------------------------");
			$client->Message(315,"#zemzone - Display and/or adjust ZEM for a zone");
			$client->Message(315,"#gmwho - GM show who's in the zone with IP address(es)");
			$client->Message(315,"#linked - Show targetted players IP linked accounts");
			$client->Message(315,"#gotoinstance - Goto instances via identifier number");
			$client->Message(315,"#summonall - Will summon all players (not GMs) to your current location");
			$client->Message(315,"#returnplayers - Will return players to their last position before #summonall");
			$client->Message(315,"#psay - Makes targetted player shout whatever you want");
			$client->Message(315,"#pshout - Makes targetted player shout whatever you want");
			$client->Message(315,"#getaway - Knockback of all non-gm players within distance 30");			
		}
		#######################################
		elsif ($text=~/#gotoinstance/i) {
			if($arg[1]) {
				$connect = plugin::LoadMysql();
				$query =	"SELECT
							zone.zoneidnumber,
							zone.safe_x,
							zone.safe_y,
							zone.safe_z
							FROM
							zone
							WHERE
							short_name = '" . $arg[1] . "'";
				$query_handle = $connect->prepare($query);
				$query_handle->execute();
				while (@row = $query_handle->fetchrow_array()){ $ISL[0] = [@row];}
					$client->Message(15, "Sending you to zonesn: $arg[1] version: $arg[2] with identifier number: $arg[3]");
					plugin::SendToInstance("public", "$arg[1]", $arg[2], $ISL[0][1], $ISL[0][2], $ISL[0][3], "$arg[3]", 65000);
				}
			else {
				$client->Message(15, "Usage: #gotoinstance <zonesn> <version> <identifier number>");
			}
		}
		#######################################
		elsif ($text=~/#linked/i) {
			if ($client->GetTarget()->IsClient()) {
				$client->Message(11, "-------------------------------------------------------------------------");
				$client->Message(11, "[GM:] Showing Linked Accounts for Targetted Player");
				$client->Message(11, "-------------------------------------------------------------------------");
				my $dbh = plugin::LoadMysql();
				my $sth = $dbh->prepare("
											SELECT accid, name
											FROM account_ip
											INNER JOIN character_data
											ON account_ip.accid = character_data.account_id
											WHERE account_ip.ip = ?
										");
				$sth->bind_param(1,ConvertIP($client->GetTarget()->CastToClient->GetIP()));
				$sth->execute();
				while (my @row = $sth->fetchrow_array()) {
					my ($account_id, $playername ) = @row;
					quest::gmsay ("    Account ID: ".$account_id." --- Name: ".$playername."", 11, 1);
				}
				$sth->finish();
				$dbh->disconnect();
			}
			else {
				$client->Message(15, "[GM:] You MUST target a PLAYER to use this command!");
			}
		}
		#######################################
		elsif ($args[0]=~/#zemzone/i){
			if (($args[1]) && (!$args[2])) {
				my $zonetochange = $args[1];
				my $dbh = plugin::LoadMysql();
				my $sth=$dbh->prepare('SELECT zone_exp_multiplier FROM zone WHERE short_name = ?') 
					or die "Couldn't prepare statement: " . $dbh->errstr;
				$sth->bind_param(1,$zonetochange);
				$sth->execute();
				my $currentzem = $sth->fetchrow_array();
				$client->Message(15, "[GM:] Current ZEM for ".plugin::Zone("LN",$zonetochange)." is $currentzem");
			}
			elsif ($args[1] && $args[2]) {
				my $zonetochange = $args[1];
				my $changezem = $args[2];
				my $dbh = plugin::LoadMysql();
				$sth = $dbh->prepare('SELECT zone_exp_multiplier FROM zone WHERE short_name = ?')
					or die "Couldn't prepare statement: " . $dbh->errstr;					
				$sth->bind_param(1,$zonetochange);
				$sth->execute();
				my $currentzem = $sth->fetchrow_array();
				$client->Message(315, "UPDATING: Changing ZEM for ".plugin::Zone("LN",$zonetochange)." from $currentzem to $changezem");
				$sth = $dbh->prepare('UPDATE zone SET zone_exp_multiplier = ? WHERE short_name = ?')
					or die "Couldn't prepare statement: " . $dbh->errstr;					
				$sth->bind_param(1,$changezem);
				$sth->bind_param(2,$zonetochange);
				$sth->execute();
				$client->Message(15, "[GM:] NOTIFICATION: ZEM for ".plugin::Zone("LN",$zonetochange)." changed from $currentzem to $changezem !");
				quest::reloadallrules();
			}
			else { 
				$client->Message(315,"Usage: #ZEMZONE [zonesn] (without backets) to view ZEM for specified [zonesn]"); 
				$client->Message(315,"Usage: #ZEMZONE [zonesn] [newzem] (without backets) to change ZEM for specified [zonesn] to [newzem]"); 
			}
		}
		#######################################		
		elsif ($text=~/#getaway/i) {
			@zoneclients = $entity_list->GetClientList();
			foreach $singleclient (@zoneclients) {
				if (($singleclient->AccountID() != $client->AccountID()) && (not $singleclient->GetGM())) {
					$singleclient->BuffFadeBySlot($singleclient->GetBuffSlotFromType(57), 1);
					$singleclient->BuffFadeBySlot($singleclient->GetBuffSlotFromType(58), 1);
					if ($client->CalculateDistance($singleclient->GetX(),$singleclient->GetY(),$singleclient->GetZ()) <= 30) {
						$singleclient->DoKnockback($client, 7, 5);
					}
				}
			}
		}
		#######################################
		elsif ($text=~/#summonall/i) {
			quest::delglobal("summonallzone");
			quest::delglobal("summonallx");
			quest::delglobal("summonally");
			quest::delglobal("summonallz");
			quest::delglobal("summonallh");
			$client->SetGlobal("summonallzone",$zoneid,7,"F");
			$client->SetGlobal("summonallx",$client->GetX(),7,"F");
			$client->SetGlobal("summonally",$client->GetY(),7,"F");
			$client->SetGlobal("summonallz",$client->GetZ(),7,"F");
			$client->SetGlobal("summonallh",$client->GetHeading(),7,"F");
			quest::crosszonesignalnpcbynpctypeid(10, 14000);
		}		
		#######################################
		elsif ($text=~/#psay/i) {
			if($arg[1]) {
				if ($client->GetTarget()->IsClient()) {
					$formattedstring = "";
					for ($count = 1; $count < scalar(@args); $count++) {
						$formattedstring = $formattedstring." ".$args[$count];
					}
					$client->GetTarget()->CastToClient()->Say($formattedstring);
				} else {
					$client->Message(315,"Target must be a player!");
				}
			} else {
				$client->Message(315,"Usage: Target player and type #psay <text>");
			}
		}
		#######################################
		elsif ($text=~/#pshout/i) {
			if($arg[1]) {
				if ($client->GetTarget()->IsClient()) {
					$formattedstring = "";
					for ($count = 1; $count < scalar(@args); $count++) {
						$formattedstring = $formattedstring." ".$args[$count];
					}
					$client->GetTarget()->CastToClient()->Shout($formattedstring);
				} else {
					$client->Message(315,"Target must be a player!");
				}
			} else {
				$client->Message(315,"Usage: Target player and type #pshout <text>");
			}
		}
		#######################################
		elsif ($text=~/#returnplayers/i) {
			quest::crosszonesignalnpcbynpctypeid(10, 15000);
		}
		#######################################
		elsif ($text=~/#gmwho/i) {
			my %classhash = (
				1 	=> "Warrior",
				2 	=> "Cleric",
				3 	=> "Paladin",
				4 	=> "Ranger",
				5 	=> "Shadow Knight",
				6 	=> "Druid",
				7 	=> "Monk",
				8 	=> "Bard",
				9 	=> "Rogue",
				10	=> "Shaman",
				11	=> "Necromancer",
				12	=> "Wizard",
				13	=> "Magician",
				14	=> "Enchanter",
				15	=> "Beastlord",
				16	=> "Berserker",
			);
			my %racehash = (
				1	=>	"Human",
				2	=>	"Babarian",
				3	=>	"Erudite",
				4	=>	"Wood Elf",
				5	=>	"High Elf",
				6	=>	"Dark Elf",
				7	=>	"Half Elf",
				8	=>	"Dwarf",
				9	=>	"Troll",
				10	=>	"Ogre",
				11	=>	"Halfling",
				12	=>	"Gnome",
				128	=>	"Iksar",
				130	=>	"Vah Shir",
				330	=>	"Froglok",
			);
			my %clientversionhash = (
				1	=>	"P99",
				2	=>	"Tit",
				4	=>	"SoF",
				8	=>	"SoD",
				16	=>	"UF",
				32	=>	"RoF",
				64	=>	"RoF2",
			);
			$client->Message (11, "----------------------------------------");
			$client->Message (11, "[GM:] Players in Zone:");
			$client->Message (11, "----------------------------------------");
			my @clientsarray = $entity_list->GetClientList();
			foreach my $singleclient (@clientsarray) {
				my $clientguildname;
				if (quest::getguildnamebyid($singleclient->GuildID())) {
					$clientguildname = "".quest::getguildnamebyid($singleclient->GuildID())."";
				} 
				else { 
					$clientguildname = "NG"; 
				}
				my $wholist =	"[".$singleclient->GetLevel()." ".plugin::customclass($singleclient->GetClass(),$singleclient->GetDeity()).
								"] ".$singleclient->GetName()." (".$classhash{$singleclient->GetClass()}.") (".
								$racehash{$singleclient->GetRace()}.") <".$clientguildname."> [IP: ".ConvertIP($singleclient->GetIP())."] ".
								"[Client: ".$clientversionhash{$client->GetClientVersionBit()}."]";
				$client->Message (11, "".$wholist."");
			}
			$client->Message (11, "-------------------------------------------------------------------");
			$client->Message (11, "There are ".scalar (@clientsarray)." players in zone!");
		}
	}
}

sub EVENT_CONNECT {
	my %clientverhash = (
		1	=>	"P99",
		2	=>	"Ti",
		4	=>	"SoF",
		8	=>	"SoD",
		16	=>	"UF",
		32	=>	"RoF",
		64	=>	"RoF2",
	);
	#######################
	## New Toon Handling ##
	#######################
	if (!defined $qglobals{"newtoon"}) {
		quest::setglobal("newtoon",1,5,"F");
		quest::gmsay ("-----------------------------------------------------------------------------------------------", 257, 1);
		quest::gmsay ("[GM:] <$name> newly created toon, checking IP linked characters:", 11, 1);
		quest::gmsay ("-----------------------------------------------------------------------------------------------", 11, 1);
		my $dbh = plugin::LoadMysql();
		my $sth = $dbh->prepare("
									SELECT accid, name
									FROM account_ip
									INNER JOIN character_data
									ON account_ip.accid = character_data.account_id
									WHERE account_ip.ip = ?
								");
		$sth->bind_param(1,ConvertIP($client->GetIP()));
		$sth->execute();
		while (my @row = $sth->fetchrow_array()) {
			my ($account_id, $playername ) = @row;
			quest::gmsay ("    Account ID: ".$account_id." --- Name: ".$playername."", 11, 1);
		}
		$sth->finish();
		$dbh->disconnect();
		quest::gmsay ("-----------------------------------------------------------------------------------------------", 257, 1);
	} else {
		quest::gmsay ("-----------------------------------------------------------------------------------------------", 14, 1);
		quest::gmsay ("[GM:] New Connection [IP:".ConvertIP($client->GetIP())."]:", 11, 1);
		if($uguild_id > 0) {
			my $guildname = quest::getguildnamebyid($uguild_id);
			quest::gmsay("($ulevel $class) $name ($race) <$guildname> ZONE: $zonesn", 11, 1);
		}
		else {
			quest::gmsay("($ulevel $class) $name ($race) <UNGUILDED> ZONE: $zonesn", 11, 1);
		}
		quest::gmsay ("Account Name :: [".$client->AccountName()."] --- Status :: [".$status."] --- Client :: [".$clientverhash{$client->GetClientVersionBit()}."]", 11, 1);
		quest::gmsay ("-----------------------------------------------------------------------------------------------", 14, 1);
	}
}

sub EVENT_DISCOVER_ITEM {
	if (!defined $qglobals{"discovereditems"}) {
		quest::setglobal("discovereditems",1,5,"F");
	}
	else {
		quest::setglobal("discovereditems",$qglobals{"discovereditems"}+1,5,"F");
	}
}

sub EVENT_FORAGE_FAILURE {
	if (!defined $qglobals{"foragefails"}) {
		quest::setglobal("foragefails",1,5,"F");
	}
	else {
		quest::setglobal("foragefails",$qglobals{"foragefails"}+1,5,"F");
	}
}

sub EVENT_FORAGE_SUCCESS {
	if (!defined $qglobals{"foragesuccesses"}) {
		quest::setglobal("foragesuccesses",1,5,"F");
	}
	else {
		quest::setglobal("foragesuccesses",$qglobals{"foragesuccesses"}+1,5,"F");
	}
}

sub EVENT_DUEL_LOSE {
	if (!defined $qglobals{"duelslost"}) {
		quest::setglobal("duelslost",1,5,"F");
	}
	else {
		quest::setglobal("duelslost",$qglobals{"duelslost"}+1,5,"F");
	}
}

sub EVENT_DUEL_WIN {
	if (!defined $qglobals{"duelswon"}) {
		quest::setglobal("duelswon",1,5,"F");
	}
	else {
		quest::setglobal("duelswon",$qglobals{"duelswon"}+1,5,"F");
	}
}

sub EVENT_COMBINE_SUCCESS {
	if (!defined $qglobals{"tscombines"}) {
		quest::setglobal("tscombines",1,5,"F");
	}
	else {
		quest::setglobal("tscombines",$qglobals{"tscombines"}+1,5,"F");
	}
}

sub EVENT_COMBINE_FAILURE {
	if (!defined $qglobals{"tsfailures"}) {
		quest::setglobal("tsfailures",1,5,"F");
	}
	else {
		quest::setglobal("tfailures",$qglobals{"tsfailures"}+1,5,"F");
	}
}

sub EVENT_LOOT {
	if (!defined $qglobals{"looteditems"}) {
		quest::setglobal("looteditems",1,5,"F");
	}
	else {
		quest::setglobal("looteditems",$qglobals{"looteditems"}+1,5,"F");
	}
}

sub EVENT_TRADE {
	if (!defined $qglobals{"tradeditems"}) {
		quest::setglobal("tradeditems",1,5,"F");
	}
	else {
		quest::setglobal("tradeditems",$qglobals{"tradeditems"}+1,5,"F");
	}
}

sub EVENT_SIGNAL {
	if ($signal == 50) {
		if (not $client->GetGM()) {
			my $presummonzone = $qglobals{"presummonreturnzone"};
			my $presummonx = $qglobals{"presummonreturnx"};
			my $presummony = $qglobals{"presummonreturny"};
			my $presummonz = $qglobals{"presummonreturnz"};
			my $presummonh = $qglobals{"presummonreturnh"};
			$client->MovePC($presummonzone, $presummonx, $presummony, $presummonz, $presummonh);
		}
	}
}

sub EVENT_DEATH_COMPLETE {
    # PVP Death
	if ($entity_list->GetMobByID($killer_id) && $entity_list->GetMobByID($killer_id)->IsClient()) {
		if (!defined $qglobals{"pvpdeaths"}) {
			quest::setglobal("pvpdeaths",1,5,"F");
		}
		else {
			quest::setglobal("pvpdeaths",$qglobals{"pvpdeaths"}+1,5,"F");
		}
    }
	else {
		if (!defined $qglobals{"deaths"}) {
			quest::setglobal("deaths",1,5,"F");
		} else {
			quest::setglobal("deaths",$qglobals{"deaths"}+1,5,"F");
		}
	}
}

sub EVENT_CLICKDOOR {
    ## if($status >= $MINACCESSLEVELFORGMSTUFF){
    ##    plugin::Doors_Manipulation_EVENT_CLICKDOOR();
    ## }
}

sub ConvertIP {
	my $longip = $_[0];
	$firstoctet = $longip % 256;
	$longip -= $firstoctet;
	$longip /= 256;
	$secondoctet = $longip % 256;
	$longip -= $secondoctet;
	$longip /= 256;
	$thirdoctet = $longip % 256;
	$longip -= $thirdoctet;
	$longip /= 256;
	my $convertedip = "$firstoctet.$secondoctet.$thirdoctet.$longip";
	return $convertedip;
}


Below is needed for the summoning/returning (which I -believe- was working).

/quests/global/zone_controller.pl
Code:
sub EVENT_SIGNAL {
	#######        #summonall command
	if ($signal == 14000) {
		my @clientlist = $entity_list->GetClientList();
		foreach $singleclient (@clientlist) {
			if (not $singleclient->GetGM()) {
				$singleclient->SetGlobal("presummonreturnzone",$singleclient->GetZoneID(),5,"F");
				$singleclient->SetGlobal("presummonreturnx",(int($singleclient->GetX() * 100) / 100),5,"F");
				$singleclient->SetGlobal("presummonreturny",(int($singleclient->GetY() * 100) / 100),5,"F");
				$singleclient->SetGlobal("presummonreturnz",(int($singleclient->GetZ() * 100) / 100),5,"F");
				$singleclient->SetGlobal("presummonreturnh",(int($singleclient->GetHeading() * 100) / 100),5,"F");
				my $summonzone = (int(plugin::readglobal("summonallzone") * 100) / 100);
				my $summonx = (int(plugin::readglobal("summonallx") * 100) / 100);
				my $summony = (int(plugin::readglobal("summonally") * 100) / 100);
				my $summonz = (int(plugin::readglobal("summonallz") * 100) / 100);					
				my $summonh = (int(plugin::readglobal("summonallh") * 100) / 100);					
				$singleclient->MovePC($summonzone,$summonx,$summony,$summonz,$summonh);
			}
		}
	}
	#######        #returnplayers command
	elsif ($signal == 15000) {
		my @clist = $entity_list->GetClientList();
		foreach my $sclient (@clist) {
			if (not $sclient->GetGM()) {
				$sclient->SignalClient(50);
			}
		}
	}
}
I removed some code (though didnt bother optimizing that code that I left in place), that, I wanted to keep to myself for now. Hopefully I didn't break anything in the process, I only checked the code remaining for syntax.
Reply With Quote
  #2  
Old 03-15-2017, 10:14 AM
Maze_EQ
Demi-God
 
Join Date: Mar 2012
Posts: 1,103
Default

Haha I remember when you wrote this and we had fun with it on NLAIR.
__________________
"No, thanks, man. I don't want you fucking up my life, too."

Skype:
Comerian1
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 08:03 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