Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Server Code Submissions

Reply
 
Thread Tools Display Modes
  #1  
Old 05-12-2010, 12:01 AM
Akkadius's Avatar
Akkadius
Administrator
 
Join Date: Feb 2009
Location: MN
Posts: 2,071
Default Database Group ID Call

The lovely work of Secrets made some instancing code possible by calling Group ID. The problem with using GetGroup and then GetGroupID is that if you don't have a group in the zone to check, you arent going to get an ID to assign and link up to the stored value of Qglobal to pullt he right instance.

If we could get this committed that would be great, and it works phenominal!

Code:
Index: perlparser.cpp
===================================================================
--- perlparser.cpp	(revision 1478)
+++ perlparser.cpp	(working copy)
@@ -2973,7 +2973,20 @@
 	XSRETURN_EMPTY;
 }
 
+XS(XS_getgroupidbychar);
+XS(XS_getgroupidbychar)
+{
+   dXSARGS;
+   if (items != 1)
+      Perl_croak(aTHX_ "Usage: getgroupidbychar(charid)");
 
+   int32   charid = (int)SvIV(ST(0));
+   int32   ret_id = quest_manager.GetGroupIDByChar(charid);
+
+   XSRETURN_UV(ret_id);
+}
+
+
 /*
 This is the callback perl will look for to setup the
 quest package's XSUBs
@@ -3170,6 +3183,7 @@
 		newXS(strcpy(buf, "removetitle"), XS__removetitle, file);
 		newXS(strcpy(buf, "wearchange"), XS__wearchange, file);
 		newXS(strcpy(buf, "voicetell"), XS__voicetell, file);
+		newXS(strcpy(buf, "getgroupidbychar"), XS_getgroupidbychar, file);
 	XSRETURN_YES;
 }
 
Index: questmgr.cpp
===================================================================
--- questmgr.cpp	(revision 1478)
+++ questmgr.cpp	(working copy)
@@ -2389,3 +2389,13 @@
 	}
 }
 
+int32 QuestManager::GetGroupIDByChar(int32 charid)
+{
+	if(charid)
+	{
+	return	database.GetGroupIDByChar(charid);
+	}
+
+	return 0;
+}
+
Index: questmgr.h
===================================================================
--- questmgr.h	(revision 1478)
+++ questmgr.h	(working copy)
@@ -215,6 +215,7 @@
 	uint8 FactionValue();
 	void wearchange(int8 slot, int16 texture);
 	void voicetell(char *str, int macronum, int racenum, int gendernum);
+	int32 GetGroupIDByChar(int32 charid);
 
 	//not in here because it retains perl types
 	//thing ChooseRandom(array_of_things)
Index: zonedb.cpp
===================================================================
--- zonedb.cpp	(revision 1478)
+++ zonedb.cpp	(working copy)
@@ -1645,6 +1645,23 @@
 	return count;
 }
 
+sint32 ZoneDatabase::GetGroupIDByChar(int32 charid){
+	char errbuf[MYSQL_ERRMSG_SIZE];
+    char *query = 0;
+    MYSQL_RES *result;
+    MYSQL_ROW row;
+	sint32 count=0;
+	if (RunQuery(query, MakeAnyLenString(&query, "SELECT groupid FROM group_id WHERE charid=%d", charid), errbuf, &result)) {
+		if((row = mysql_fetch_row(result))!=NULL)
+			count = atoi(row[0]);
+		mysql_free_result(result);
+	} else {
+		count=0;
+	}
+	safe_delete_array(query);
+	return count;
+}
+
  int8 ZoneDatabase::RaidGroupCount(int32 raidid, int32 groupid)
  {
  	char errbuf[MYSQL_ERRMSG_SIZE];
Index: zonedb.h
===================================================================
--- zonedb.h	(revision 1478)
+++ zonedb.h	(working copy)
@@ -326,6 +326,7 @@
 	 */
 	void RefreshGroupFromDB(Client *c);
 	int8 GroupCount(int32 groupid);
+	sint32 GetGroupIDByChar(int32 groupid);
 	/*
 	 * Raid
 	 */
Reply With Quote
  #2  
Old 05-12-2010, 01:25 AM
KLS
Administrator
 
Join Date: Sep 2006
Posts: 1,348
Default

Code:
    $grp = $client->GetGroup();
    $grp_id = 0;
    if($grp)
    {
        $grp_id = $grp->GetID();
    }
Please explain how this is worse before it can be considered for submission.
Reply With Quote
  #3  
Old 05-12-2010, 01:59 AM
Akkadius's Avatar
Akkadius
Administrator
 
Join Date: Feb 2009
Location: MN
Posts: 2,071
Default

Quote:
Originally Posted by KLS View Post
Code:
    $grp = $client->GetGroup();
    $grp_id = 0;
    if($grp)
    {
        $grp_id = $grp->GetID();
    }
Please explain how this is worse before it can be considered for submission.
I've tried many variations, and it works great if you are checking for a group inside of a zone, but you can't store the Group_id that is actually in the database with it. I've gotten every other time of instance working just fine other than raid ID storing.

Let's say I grab an isntance with a person using the same format, if I zone and they are the only one in the zone, doing a group check fails before I can even grab ID.

With the code below I can store the group ID in a qglobal with the above .diff and recall that same Group_ID at any given zone, npc etc if I wanted to assign them consistently to the same instance. With the other method I will get a fail if no one else is in the zone, it can't reach a Group_ID. Nor does it output the ID.

Code:
sub EVENT_SAY
{
if($text=~/enter/i){
		my $GID = quest::getgroupidbychar($charid);
		if ($GID > 0)
		{
            if (defined($qglobals{"HalasWere_$GID"}))
            {
                my $QGlobalValue = $qglobals{"HalasWere_$GID"};
                quest::AssignToInstance($qglobals{"HalasWere_$GID"});
                quest::MovePCInstance(29, $QGlobalValue, 0, 0, 0);
            }
            else
            {
                my $instanceID = quest::CreateInstance("halas", 1, 7201);
                quest::AssignToInstance($instanceID); 
                quest::setglobal("HalasWere_$GID",$instanceID,7,"H2");
                quest::MovePCInstance(29, $instanceID, 0, 0, 0);
            }
        }
		else
		{
			quest::popup("Requirements","You need to have a group to enter this instance",0,0);
		}
}
}
If I use the below code, I do not get a variable back from the group call that you had originally suggested I tried, which worked, just not completely.

You can store the group ID in the global value this way. And if we had a raid ID call you could do it the same way here. Got instances working with group very flexibly here.

And once again, thank you for your great work with instances.

Code:
if($text=~/grouptest/i)
{

    $grp = $client->GetGroup();
	my $GID = quest::getgroupidbychar($charid);
    $grp_id = 0;
    if($grp)
    {
        $grp_id = $grp->GetID();
		quest::say("$grp_id");
		quest::say("$GID");
		}
    }
Reply With Quote
  #4  
Old 05-12-2010, 02:48 AM
KLS
Administrator
 
Join Date: Sep 2006
Posts: 1,348
Default

Indulge me: what are you getting back?

I don't really agree with this approach since group::GetID() should return the database id correctly and if a group exists in the database it should exist in zone. If it isn't then I say we fix that rather than adding a work around.
Reply With Quote
  #5  
Old 05-12-2010, 03:04 AM
Akkadius's Avatar
Akkadius
Administrator
 
Join Date: Feb 2009
Location: MN
Posts: 2,071
Default

Quote:
Indulge me: what are you getting back?

I don't really agree with this approach since group::GetID() should return the database id correctly and if a group exists in the database it should exist in zone. If it isn't then I say we fix that rather than adding a work around.
I don't get anything. And I agree, I don't care what way we do it, I just want to be able to pull group ID's regardless.

It doesn't pull group if people are out of zone, which kills the next command. And even if there is someone in the group, it wont output any integer for GetID();

Whatever you need to do, I'm all for it. I just want to be able to call group ID by client and as well as raid if we could.
Reply With Quote
  #6  
Old 08-03-2010, 11:52 AM
Akkadius's Avatar
Akkadius
Administrator
 
Join Date: Feb 2009
Location: MN
Posts: 2,071
Default

Quote:
Originally Posted by KLS View Post
Indulge me: what are you getting back?

I don't really agree with this approach since group::GetID() should return the database id correctly and if a group exists in the database it should exist in zone. If it isn't then I say we fix that rather than adding a work around.
This still gets the group ID just fine to store it in the database so that a group can recall their instance. But it is very weird about parsing. I don't know exactly why it is unreliable but it is. Once again I agree we should simply fix the existing function. The script below works highlighted in red. But unless you place the 'my $Group' variables in the right part of the script it flakes completely.

I once originally made this script for EZ so that it can do both Guild and Group instances together. And having the Group variables at the top of the script would null trying to get to the rest of the script, meaning if there was say text below the definition it wont show. So unless I define the group variables INSIDE the $text it will not show the rest of the script. I messed with this for several several hours and resorted to breaking these two scripts apart (This was a few months ago). I'm not saying that this doesn't call the ID, but it doesn't call the ID reliably, you have to walk around glass to get it to work in bigger scripts. Even as Perl parser won't pick up the errors and it simply got frustrating.


Code:
#######################WAYPOINT UTILITY SCRIPT########################
##########CREATED BY: AKKADIUS FROM BLOOD OF THE AKKADIAN#############
##########EZ SERVER VERSION###########################################
##########NPC RACE - 127, SPECIAL FLAGS - ABH,
sub EVENT_SPAWN {

    my $x = $npc->GetX();
	my $y = $npc->GetY();
	my $z = $npc->GetZ();
	my $range = (15);
	quest::set_proximity($x - $range, $x + $range, $y - $range, $y + $range, $z - 10, $z + 20);
	quest::settimer("effect",1);
	quest::settimer("effect2",1);
}

sub EVENT_ENTER
{
			$client->Message(315, "For Waypoint Options: Target the portal and type [Options]");	
}

sub EVENT_TIMER
{
	if($timer eq "effect"){
		$npc->SpellEffect(178);
		$npc->SpellEffect(203);
		$npc->SendAppearanceEffect(77,78);
		quest::stoptimer("effect");
		quest::settimer("effect",12);
	}
	if($timer eq "effect2"){
		$npc->SendAppearanceEffect(77,78);
		quest::stoptimer("effect2");
		quest::settimer("effect2",4);
	}
}

sub EVENT_SAY
{
			my $Cx = $client->GetX();
			my $Cy = $client->GetY();
			my $Cz = $client->GetZ();
			my $bind = quest::saylink("Bind in this Zone", 1);
			my $halls = quest::saylink("The Forgotten Halls",1);
			my $buffs = quest::saylink("Buffs",1);
			my $Other = quest::saylink("Other Options",1);
			my $instance = quest::saylink("Instance",1);
			my $npc_name = $npc->GetCleanName(); 
			my $Withdraw = quest::saylink("Withdraw",1);
			my $Deposit = quest::saylink("Deposit",1);
			my $Check = quest::saylink("Check Balance",1);
			my $Hundred = quest::saylink("100 Platinum",1);
			my $Thousand = quest::saylink("1,000 Platinum",1);
			my $TenThousand = quest::saylink("10,000 Platinum",1);
			my $HundredThousand = quest::saylink("100,000 Platinum",1);
			my $accountname1 = $client->AccountName();
			my $accountname = "<c \"#FBB117\">$accountname1</c>";
			my $accountid = $client->AccountID();
			my $bankcredit = $qglobals{"BankCredit_$accountid"} ? $qglobals{"BankCredit_$accountid"} : 0;
			my $bankcredit2 = "<c \"#FBB117\">$bankcredit</c>";
			my $ManageCredit = quest::saylink("Manage Credit",1);
			my $GuildInst = quest::saylink("-Guild Instance-",1);
			my $GroupInst = quest::saylink("-Group Instance-",1);
			my $EnterGuildInst = quest::saylink("Enter Guild Instance",1);
			my $EnterGroupInst = quest::saylink("Enter Group Instance",1);
			my $GuildCreate = quest::saylink("Create a Guild Instance",1);
			my $GuildDelete = quest::saylink("Delete Guild Instance",1);
			my $GroupDelete = quest::saylink("Delete Group Instance",1);
			my $GroupCreate = quest::saylink("Create Group Instance",1);
			#########################VARIABLES####################
			my $BuffCost = $ulevel; ### SETS THE COST FOR BUFFS
			#########################VARIABLES####################
			
			######################OPTIONS MENU####################
			if ($text=~/options/i)
			{
			$client->Message(10, "Waypoint:--------$zoneln-------");
			####################INSTANCE ZONE CHECKS########################
						my $ClientGroup = $client->GetGroup();
						my $GroupID = $ClientGroup->GetID();
						if (defined($qglobals{"GroupInstance$zonesn$GroupID"}))
						{
						my $GroupInstanceCreator = $qglobals{"GroupInstanceCreator$zonesn$GroupID"};
						$client->Message(315,"This Waypoint already has a Group Instance created by Group Member: [$GroupInstanceCreator]");
						$client->Message(315,"[$EnterGroupInst]");
						$client->Message(315,"[$GroupDelete]");
						$client->Message(10, "------------------------------------------------------------------------------");
						}
							else{ ### Zone Check
							$client->Message(315,"This Waypoint offers an option to create a [$GroupInst], would you like to create it?");
							$client->Message(315,"[$GroupCreate] [Cost: 2,000 Platinum from your Credit.]");
							$client->Message(10, "------------------------------------------------------------------------------");
							}
						##############################################################################
						####################INSTANCE ZONE CHECKS########################
						
			########REGULAR MENU OPTIONS (GLOBAL)############
			$client->Message(315, "[$buffs]  [Cost : $BuffCost]");
			$client->Message(315, "[$ManageCredit]");
			$client->Message(315, "[$Other]");
			########REGULAR MENU OPTIONS (GLOBAL)############
			}
			my $Walkthrough = quest::saylink("Walkthroughs and Guides", 1);
			my $Whatis = quest::saylink("What is Waypoint?", 1);
			if ($text =~ /Other Options/i)
				{
				$client->Message(10, " " );
				$client->Message(315, "[$Walkthrough]");
				$client->Message(315, "[$Whatis]");
				}
				
				##################START GROUP INSTANCE SEGMENT#######################
					my $GroupInstanceCost = 2000; ###2,000 Platinum Entry fee for Group.
					if($text=~/Create Group Instance/i)
					{
						my $ClientGroup = $client->GetGroup();
						my $GroupID = $ClientGroup->GetID();
							if ($ClientGroup) {
								if ($bankcredit < $GroupInstanceCost)
									{
										$client->Message(315,"You need "
											. ($GuildInstanceCost - $bankcredit) . " more plat!");
									}
									else {
										$bankcredit -= $GroupInstanceCost;
										quest::setglobal("BankCredit_$accountid", "$bankcredit", 7, 'F');
										my $bankcredit = $qglobals{"BankCredit_$accountid"} ? $qglobals{"BankCredit_$accountid"} : 0;
										my $bankcredit2 = "<c \"#FBB117\">$bankcredit</c>";
										quest::popup("Account Balance","<br><br>
										-------------ACCOUNT BALANCE: $accountname-------------
										<br>
										<br>
										You now have $bankcredit2 Platinum on the account $accountname!");
										$timestamp = localtime(time);
										my $npc_name = $npc->GetCleanName(); 
										my $accountname1 = $client->AccountName();
										quest::write("InstanceLogs/Instance$zonesn.txt","[$timestamp] : $name the $class at $ulevel has used $GuildInstanceCost on $npc_name for an instance, this player now has $bankcredit in his account: $accountname1.");
										quest::ze(15,"$name has created Group Instance: $zoneln");
								if (defined($qglobals{"GroupInstance$zonesn$GroupID"})) {
									$GroupInstanceID = $qglobals{"GroupInstance$zonesn$GroupID"};
									quest::AssignToInstance($GroupInstanceID);
									quest::MovePCInstance($zoneid, $GroupInstanceID, $Cx, $Cy, $Cz);
								}
								else {
									$GroupInstanceID = quest::CreateInstance("$zonesn", 0, 10800);
									quest::AssignToInstance($GroupInstanceID); 
									quest::setglobal("GroupInstance$zonesn$GroupID",$GroupInstanceID,7,"H3");
									quest::setglobal("GroupInstanceCreator$zonesn$GroupID",$name,7,"H3");
									quest::write("InstanceLogs/GroupInstance$zonesn.txt","[$timestamp] : $name has created instance $zoneln for Group ID: $GroupID");
									quest::MovePCInstance($zoneid, $GroupInstanceID, $Cx, $Cy, $Cz);
								}
							}
						}
						else
						{
						$client->Message(315,"You must be in a Group to create a Group Instance!");
						}
					}
					#########IF CREATED ALREADY, REQUESTING######
					if($text =~/Enter Group Instance/i)
					{
							my $ClientGroup = $client->GetGroup();
							my $GroupID = $ClientGroup->GetID();
							if (defined($qglobals{"GroupInstance$zonesn$GroupID"})) {
							$GroupInstanceID = $qglobals{"GroupInstance$zonesn$GroupID"};
							quest::AssignToInstance($GroupInstanceID);
							quest::MovePCInstance($zoneid, $GroupInstanceID, $Cx, $Cy, $Cz);
							}
							else
							{
							$client->Message(315,"Your Group does not have an instance in this zone, you must create it!");
							}
					}
					my $ClientGroup = $client->GetGroup();
					my $GroupID = $ClientGroup->GetID();
					#########Delete Instance Group Popup request######
					if($text =~/Delete Group Instance/i && $ClientGroup)
					{
							my $zonecolln = "<c \"#B1FB17\">$zoneln</c>";
							quest::popup("Delete Group  Instance","<c \"#FFFF66\">Are you sure you want to delete the 
							instance created for your Group in </c> [$zonecolln]?",111,1);
					}
					#########Delete Instance Group Popup request######
				
				
				
				###############OTHER OPTIONS##################
				if ($text =~ /What is Waypoint/i)
				{
				quest::popup("Waypoint: By Akkadius","<br><br>
				<c \"#FFFF66\">
				o Waypoint is a script made by Akkadius from the Blood of the
				Akkadian server, designed to help the ever growing EZ Server population's
				need for instancing for zones.<br><br>
				o Waypoint also provides various other benefits and utilities such as a 
				buff bot script away from the hub zone, but also requires a charge.<br><br>
				o Waypoint is a tool that provides information and guides posted from the EZ
				Server website.<br>
				");
				}
					if ($text =~ /-Group Instance-/i)
					{
					quest::popup("Group Instance","<br>
					<br>
					<c \"#FFFF66\">
					o What a Group Instance does, is it makes a new slate of the zone that is 
					being prompted for an instance for specifically the Group that requests it.
					<br>
					<br>
					Group Instances cost 2,000 Platinum from your Credit system to request.
					<br>
					</c>
					");
				}
				if ($text =~ /Walkthroughs and Guides/i)
				{
				quest::popup("Waypoint: By Akkadius","<br><br>
				<c \"#FFFF66\">
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				[EZ SERVER GUIDES]
				<br>
				----------------------------------------------------------------------------
				<br>
				o&nbsp;&nbsp;<a href=\"http://ezserveronline.com/forums/index.php?topic=87.0\">-EZ SERVER FAQ-</a><br>
				o&nbsp;&nbsp;<a href=\"http://ezserveronline.com/forums/index.php?topic=13.0\">-Casters/Fighters Guild Guide-</a><br>
				o&nbsp;&nbsp;<a href=\"http://ezserveronline.com/forums/index.php?topic=12.0\">-EZ SERVER EPIC GUIDE-</a><br>
				o&nbsp;&nbsp;<a href=\"http://ezserveronline.com/forums/index.php?topic=449.0\">-Epic 1.0-3.0 Epics Links-</a><br>
				o&nbsp;&nbsp;<a href=\"http://ezserveronline.com/forums/index.php?topic=463.0\">-Setting Up the EQ Clients Guide-</a><br>
				o&nbsp;&nbsp;<a href=\"http://ezserveronline.com/forums/index.php?topic=439.0\">-Titanium Vs SoF/SoD List-</a><br>
				----------------------------------------------------------------------------
				<br>
				o&nbsp; List provided by Danyelle of the EZ server.
				");
				}
			######################END OPTIONS MENU####################
			
			###############################START CREDIT SEGMENT####################################
				if ($text =~ /Manage Credit/i)
					{
						$client->Message(10, "[MANAGE CREDIT]");
						$client->Message(315, "[$Withdraw]");
						$client->Message(315, "[$Deposit]");
						$client->Message(315, "[$Check]");
					}
							if($text =~ /Check Balance/i)
								{
								quest::popup("Account Balance","<br><br>
								-------------ACCOUNT BALANCE: $accountname-------------
								<br>
								<br>
								You have $bankcredit2 Platinum on the account $accountname!");
								}
								
		############WITHDRAW 100 Platinum... Logged################
		if($text=~/100 platinum/i)
		{
		my $CreditAmnt = 100;
			if ($bankcredit < $CreditAmnt)
			{
					quest::popup("Notification","You need "
					. ($CreditAmnt - $bankcredit) . " more platinum from your $creditname fund.");
			}
				else
				{
					# Only record and say this stuff if there was a cost
					if ($CreditAmnt > 0)
					{
						$bankcredit -= $CreditAmnt;
						quest::setglobal("BankCredit_$accountid", "$bankcredit", 7, 'F');
						my $bankcredit = $qglobals{"BankCredit_$accountid"} ? $qglobals{"BankCredit_$accountid"} : 0;
						my $bankcredit2 = "<c \"#FBB117\">$bankcredit</c>";
						quest::popup("Account Balance","<br><br>
								-------------ACCOUNT BALANCE: $accountname-------------
								<br>
								<br>
								You now have $bankcredit2 Platinum on the account $accountname!");
						$timestamp = localtime(time);
						my $npc_name = $npc->GetCleanName(); 
						my $accountname1 = $client->AccountName();
						quest::write("CreditLogs/CreditPull_$zonesn.txt","[$timestamp] : $name the $class at level: $ulevel has pulled $CreditAmnt on Credit Keeper: ($npc_name), this player now has $bankcredit in his account: $accountname1.");
						quest::givecash(0,0,0,$CreditAmnt);
						$client->Message(315,"You have received [$CreditAmnt] platinum pieces!");
					}
				}
		}
		
	############WITHDRAW 1,000 Platinum... Logged################
	if($text=~/1,000 platinum/i)
	{
	my $CreditAmnt = 1000;
		if ($bankcredit < $CreditAmnt)
		{
				quest::popup("Notification","You need "
				. ($CreditAmnt - $bankcredit) . " more platinum from your $creditname fund.");
		}
		else
		{
			# Only record and say this stuff if there was a cost
			if ($CreditAmnt > 0)
			{
				$bankcredit -= $CreditAmnt;
				quest::setglobal("BankCredit_$accountid", "$bankcredit", 7, 'F');
				my $bankcredit = $qglobals{"BankCredit_$accountid"} ? $qglobals{"BankCredit_$accountid"} : 0;
				my $bankcredit2 = "<c \"#FBB117\">$bankcredit</c>";
				quest::popup("Account Balance","<br><br>
				-------------ACCOUNT BALANCE: $accountname-------------
				<br>
				<br>
				You now have $bankcredit2 Platinum on the account $accountname!");
				$timestamp = localtime(time);
				my $npc_name = $npc->GetCleanName(); 
				my $accountname1 = $client->AccountName();
				quest::write("CreditLogs/CreditPull_$zonesn.txt","[$timestamp] : $name the $class at level: $ulevel has pulled $CreditAmnt on Credit Keeper: ($npc_name), this player now has $bankcredit in his account: $accountname1.");
				quest::givecash(0,0,0,$CreditAmnt);
				$client->Message(315,"You have received [$CreditAmnt] platinum pieces!");
			}
		}
	}
	
	############WITHDRAW 10,000 Platinum... Logged################
	if($text=~/10,000 platinum/i)
	{
	my $CreditAmnt = 10000;
		if ($bankcredit < $CreditAmnt)
		{
				quest::popup("Notification","You need "
				. ($CreditAmnt - $bankcredit) . " more platinum from your $creditname fund.");
		}
		else
		{
			# Only record and say this stuff if there was a cost
			if ($CreditAmnt > 0)
			{
				$bankcredit -= $CreditAmnt;
				quest::setglobal("BankCredit_$accountid", "$bankcredit", 7, 'F');
				my $bankcredit = $qglobals{"BankCredit_$accountid"} ? $qglobals{"BankCredit_$accountid"} : 0;
				my $bankcredit2 = "<c \"#FBB117\">$bankcredit</c>";
				quest::popup("Account Balance","<br><br>
				-------------ACCOUNT BALANCE: $accountname-------------
				<br>
				<br>
				You now have $bankcredit2 Platinum on the account $accountname!");
				$timestamp = localtime(time);
				my $npc_name = $npc->GetCleanName(); 
				my $accountname1 = $client->AccountName();
				quest::write("CreditLogs/CreditPull_$zonesn.txt","[$timestamp] : $name the $class at level: $ulevel has pulled $CreditAmnt on Credit Keeper: ($npc_name), this player now has $bankcredit in his account: $accountname1.");
				quest::givecash(0,0,0,$CreditAmnt);
				$client->Message(315,"You have received [$CreditAmnt] platinum pieces!");
				
			}
		}
	}
	
	############WITHDRAW 100,000 Platinum... Logged################
	if($text=~/100,000 platinum/i)
	{
	my $CreditAmnt = 100000;
		if ($bankcredit < $CreditAmnt)
		{
				quest::popup("Notification","You need "
				. ($CreditAmnt - $bankcredit) . " more platinum from your $creditname fund.");
		}
		else
		{
			# Only record and say this stuff if there was a cost
			if ($CreditAmnt > 0)
			{
				$bankcredit -= $CreditAmnt;
				quest::setglobal("BankCredit_$accountid", "$bankcredit", 7, 'F');
				my $bankcredit = $qglobals{"BankCredit_$accountid"} ? $qglobals{"BankCredit_$accountid"} : 0;
				my $bankcredit2 = "<c \"#FBB117\">$bankcredit</c>";
				quest::popup("Account Balance","<br><br>
				-------------ACCOUNT BALANCE: $accountname-------------
				<br>
				<br>
				You now have $bankcredit2 Platinum on the account $accountname!");
				$timestamp = localtime(time);
				my $npc_name = $npc->GetCleanName(); 
				my $accountname1 = $client->AccountName();
				quest::write("CreditLogs/CreditPull_$zonesn.txt","[$timestamp] : $name the $class at level: $ulevel has pulled $CreditAmnt on Credit Keeper: ($npc_name), this player now has $bankcredit in his account: $accountname1.");
				quest::givecash(0,0,0,$CreditAmnt);
				
				
				$client->Message(315,"You have received [$CreditAmnt] platinum pieces!");
			}
		}
	}
					if($text =~ /Withdraw/i)
					{
					$client->Message(315,"'How much would you like to Withdraw?");
					$client->Message(315, "[$Hundred]");
					$client->Message(315, "[$Thousand]");
					$client->Message(315, "[$TenThousand]");
					$client->Message(315, "[$HundredThousand]");
					}
				if($text =~ /Deposit/i)
				{
				$client->Message(315,"$npc_name whispers, 'Just hand me the amount of platinum you'd like to deposit!");
				}
					###############################END CREDIT SEGMENT####################################
			if ($text =~ /buffs/i)
			{
				if ($bankcredit < $BuffCost)
				{
					$client->Message(315,"You need "
						. ($BuffCost - $bankcredit) . " more plat!");
				}
				else
				{
				   if ($ulevel < 36) {
							  quest::selfcast(19);   # Armor of Faith - AC
							  quest::selfcast(1445); # Armor of Protection - HP, AC
							  quest::selfcast(10);   # Augmentation - Mana
							  quest::selfcast(278);  # Spirit of Wolf
							  } # End 1-35
						   else {
							  quest::selfcast(5257); # Conviction - HP, AC
							  quest::selfcast(5513); # Clairvoyance - Mana
							  quest::selfcast(5507); # Speed of Salik - Haste
							  quest::selfcast(5396); # Wunshi's Focusing - Stat Cap
							  quest::selfcast(4054); # Spirit of the Shrew - SoW
							  quest::selfcast(2886); # Acumen of Dar Khura - Ultravision / See Invis
							  quest::selfcast(5398); # Spirit of Fortitude - STA
							  quest::selfcast(5358); # Nettle Shield
						  } # End 36-70
	 
				# Only record and say this stuff if there was a cost
					if ($BuffCost > 0)
					{
						$bankcredit -= $BuffCost;
						my $bankcredit2 = "<c \"#FBB117\">$bankcredit</c>";
						quest::setglobal("BankCredit_$accountid", "$bankcredit", 7, 'F');
						my $bankcredit = $qglobals{"BankCredit_$accountid"} ? $qglobals{"BankCredit_$accountid"} : 0;
						my $bankcredit2 = "<c \"#FBB117\">$bankcredit</c>";
						quest::popup("Account Balance","<br><br>
						-------------ACCOUNT BALANCE: $accountname-------------
						<br>
						<br>
						You now have $bankcredit2 Platinum on the account $accountname!");
						$timestamp = localtime(time);
						my $npc_name = $npc->GetCleanName(); 
						my $accountname1 = $client->AccountName();
						quest::write("CreditLogs/UsedBuffs.txt","[$timestamp] : $name the $class at $ulevel has used $BuffCost on $npc_name for buffs, this player now has $bankcredit in his account: $accountname1.");
					}
				}
			}
		}
		
		sub EVENT_POPUPRESPONSE {
				if ($popupid eq "111") ###Delete response for Group, Works for all Group cases
				{
				my $ClientGroup = $client->GetGroup();
				my $GroupID = $ClientGroup->GetID();
					if (defined($qglobals{"GroupInstance$zonesn$GroupID"}))
					{
						my $GroupInstanceID = $qglobals{"GroupInstance$zonesn$GroupID"};
						quest::DestroyInstance($GroupInstanceID);
						quest::ze(15,"$name has deleted his Group Instance");
						quest::delglobal("GroupInstance$zonesn$GroupID");
						quest::delglobal("GroupInstanceCreator$zonesn$GroupID");
						$timestamp = localtime(time);
						my $npc_name = $npc->GetCleanName(); 
						my $accountname1 = $client->AccountName();
						quest::write("InstanceLogs/InstanceDelete$zonesn.txt","[$timestamp] : $name the $class at $ulevel, has deleted Group # ($GroupID) [$zoneln] instance.");		
					}
					else{
					$client->Message(315,"There is no Group Instance to delete!");
					}
				}
		}
		
sub EVENT_ITEM
{
	my $accountname1 = $client->AccountName();
	my $accountname = "<c \"#FBB117\">$accountname1</c>";
	my $accountid = $client->AccountID();
	my $bankcredit = $qglobals{"BankCredit_$accountid"} ? $qglobals{"BankCredit_$accountid"} : 0;
			if ($platinum > 0)
			{
				$bankcredit += $platinum;
				my $bankcredit = $qglobals{"BankCredit_$accountid"} ? $qglobals{"BankCredit_$accountid"} : 0;
				my $bankcredit2 = "<c \"#FBB117\">$bankcredit</c>";
				quest::setglobal("BankCredit_$accountid", "$bankcredit", 7, 'F');
				quest::popup("Notification","You now have $bankcredit2 Platinum on the account $accountname!");
				$timestamp = localtime(time);
				my $npc_name = $npc->GetCleanName(); 
				my $accountname1 = $client->AccountName();
				quest::write("CreditLogs/Gavecredit.txt","[$timestamp] : $name the $class at $ulevel has given $npc_name $platinum platinum, this player now has $bankcredit in his account: $accountname1.");
			}
			else 
			{
			plugin::return_items(\%itemcount);
    		}
}
Reply With Quote
  #7  
Old 08-04-2010, 08:53 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

I think I went over this before with you a while back, but the GetID() does work fine every time for groups as long as you have the script setup properly.

Some things to note about your script example there are:

You need to verify that a group exists for the player before getting the ID of the group:

This:
Code:
my $ClientGroup = $client->GetGroup();
my $GroupID = $ClientGroup->GetID();
Should be:
Code:
my $ClientGroup = $client->GetGroup();
my $GroupID = 0;
if ($ClientGroup) {
	$GroupID = $ClientGroup->GetID();
}
You can add that at the beginning of your event (such as EVENT_SAY) and then you won't need to do that check again within that particular event. You can't do that check outside of a sub event, because that stuff is only loaded at the time the NPC spawns.

If you have any problems with it, maybe we can chat on IRC or something.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
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 05:13 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