I am not exactly sure what you are trying to do here, but maybe posting your script would help us to figure out what your issue is. If you want an NPC's heading, you can just do this (2 example of how to get the heading):
Code:
sub EVENT_SAY {
my $Heading = $npc->GetHeading();
quest::say("My exported heading is $h and my GetHeading is $Heading.");
}