macro subroutine if quest # is active....

Wrote new code? Fixed a bug? Want to discuss technical stuff? Feel free to post it here.

Moderator: Moderators

Message
Author
ace_maranga
Noob
Noob
Posts: 2
Joined: 28 Apr 2011, 11:05
Noob?: No

macro subroutine if quest # is active....

#1 Post by ace_maranga »

i only know about the @eval($questList->{$questnumber}->$missions->{monsterid})

is there anyway to check if $quest $questnumber is currently active?

EternalHarvest
Developers
Developers
Posts: 1798
Joined: 05 Dec 2008, 05:42
Noob?: Yes

Re: macro subroutine if quest # is active....

#2 Post by EternalHarvest »

Just look into Network::Receive::ServerType0:

Code: Select all

sub quest_active {
	my ($self, $args) = @_;
	my $questID = $args->{questID};

	message $args->{active}
		? TF("Quest %s is now active.\n", $quests_lut{$questID} ? "$quests_lut{$questID}{title} ($questID)" : $questID)
		: TF("Quest %s is now inactive.\n", $quests_lut{$questID} ? "$quests_lut{$questID}{title} ($questID)" : $questID)
	, "info";

	$questList->{$args->{questID}}->{active} = $args->{active};
}

kabayongtao
Noob
Noob
Posts: 8
Joined: 28 Jul 2011, 09:35
Noob?: No

Re: macro subroutine if quest # is active....

#3 Post by kabayongtao »

Code: Select all

macro test{
log @eval ($::questList->{4142}->{active})
}

Code: Select all

[macro] test error: error in 1: @eval($::questList->{4142}->{active}) failed
I tried to use the code above, it works if the quest status is active, but openkore throws an error when the quest is inactive.

Can someone help?

kabayongtao
Noob
Noob
Posts: 8
Joined: 28 Jul 2011, 09:35
Noob?: No

Re: macro subroutine if quest # is active....

#4 Post by kabayongtao »

Never mind, I found out that macro plugin seems to have a bug in handling nulls. I tried things around, and I came up with this.

Code: Select all

sub subQuestActive{ 
	my ($inputID) = @_;	
	if ($questList->{$inputID}->{active} == ""){
		return 0
	}
	return  $questList->{$inputID}->{active};

}

macro test{
	log subQuestActive(9027)
}	

Post Reply