Log in

View Full Version : Checking player faction Needing guidance please


rixcraven
10-28-2012, 07:48 AM
I've got this code, and it waits til a Player enters the zone..
what I want it to do, is check the players faction against its own, and then either attack, or not, if the players faction is ok.
But I got a bit stuck on getting the faction of the player.. any help would be appreciated!!..

sub EVENT_SPAWN
{
my $x;
my $y;
my $z;
my $h;
my $timerinterval=int(rand(10)+1);

$x = $npc->GetX();
$y = $npc->GetY();
$z = $npc->GetZ();
$h = $npc->GetHeading();

quest::settimer("tmr",$timerinterval);
quest::shout("timer set to: $timerinterval");
quest::set_proximity( $x-280,$x+280,$y-280,$y+280,$z-280,$z+280);
}

sub EVENT_ENTER
{
$npc->SetFollowID($client->GetID());
if $faction ($client) >= 6)) ;
quest::shout2("Hey $name, Going to hunt you down..make you pay, There is a Bounty on your head");
elsif
quest::shout2("$name, I 'aint looking fer you today.. move along");
}

# WhenCobra Is Given 200pp he depops

sub EVENT_ITEM
{




}


# When the timer Is up Cobra taunts the target


sub EVENT_TIMER
{

my $say1 = "My clients are paying good money to have you dead, $name";
my $say2 = "Is that the best you can do, $class???";
my $say3 = "Go ahead, RUN... make my Day.";
my $say4 = "DIE FOR ME";
my $say5 = "When you die, I am going to take your head back to my clients.";
my $say6 = "A poor excuse for a $class.. ";
my $say7 = "I have slain greater than you, $class.. you are just one more to me";
my $say8 = "For 100pp, I might just let you go";
my $say9 = "This will teach others not to fool with MY clients";
my $say10 = "RUN, $class, like the scum you are!";
my $say11 = "Drop your weapon, and I'll make it quick for you";
my $say12 = "For 200pp I could perhaps not kill you";

if ($timer eq "tmr")
{
quest::stoptimer("tmr");
$talk=int(rand(12)+1);
if ($talk eq 1) { quest::say("$say1"); }
if ($talk eq 2) { quest::say("$say2"); }
if ($talk eq 3) { quest::say("$say3"); }
if ($talk eq 4) { quest::say("$say4"); }
if ($talk eq 5) { quest::say("$say5"); }
if ($talk eq 6) { quest::say("$say6"); }
if ($talk eq 7) { quest::say("$say7"); }
if ($talk eq 8) { quest::say("$say8"); }
if ($talk eq 9) { quest::say("$say9"); }
if ($talk eq 10) { quest::say("$say10"); }
if ($talk eq 11) { quest::say("$say11"); }
if ($talk eq 12) { quest::say("$say11"); }

my $timerinterval=int(rand(40)+10); #10-50 sec
quest::settimer("tmr",$timerinterval);
#quest::say("timer set to: $timerinterval");

}

}

sub EVENT_SAY
{

}

wolfwalkereci
10-28-2012, 08:10 AM
Using a event say this works for me.
sub EVENT_SAY {
if($text=~/hail/i) {
if ($faction ==7) {
quest::say("blah blah");
}
}
}

In your example I see you have the following:
if $faction ($client) >= 6)) ;
Missing a "(" in there. Not sure what else might be an issue.

c0ncrete
10-28-2012, 08:46 AM
besides missing the opening parenthesis and having an extra closing one your 'if' statement, you don't have anything for the script to do if it evaluates to true (nothing in curly braces, just ends with a semicolon). additionally, the following 'elsif' statement doesn't have anything to evaluate at all (should likely just be an 'else'), and the code to execute following isn't enclosed in curly braces.

you're probably looking for something like this:

if ($faction >= 6) {
quest::shout2("Hey, $name. I'm going to hunt you down... make you pay. There is a bounty on your head.");
}
else {
quest::shout2("$name, I ain't looking fer you today... move along.");
}

EVENT_ENTER only works when the client enters a set proximity to the npc, not when they enter the zone.

if you're wanting to check when a player enters the zone, you'll need to use EVENT_ENTERZONE in that zone's player.pl script. you should be able to check faction using $client->GetCharacterFactionLevel(), $client->GetFactionLevel(), or $client->GetModCharacterFactionLevel().

rixcraven
10-28-2012, 09:18 AM
besides missing the opening parenthesis and having an extra closing one your 'if' statement, you don't have anything for the script to do if it evaluates to true (nothing in curly braces, just ends with a semicolon). additionally, the following 'elsif' statement doesn't have anything to evaluate at all (should likely just be an 'else'), and the code to execute following isn't enclosed in curly braces.

you're probably looking for something like this:

if ($faction >= 6) {
quest::shout2("Hey, $name. I'm going to hunt you down... make you pay. There is a bounty on your head.");
}
else {
quest::shout2("$name, I ain't looking fer you today... move along.");
}

EVENT_ENTER only works when the client enters a set proximity to the npc, not when they enter the zone.

if you're wanting to check when a player enters the zone, you'll need to use EVENT_ENTERZONE in that zone's player.pl script. you should be able to check faction using $client->GetCharacterFactionLevel(), $client->GetFactionLevel(), or $client->GetModCharacterFactionLevel().

Yep!.. great, thanks a lot!, I know I'm not brilliant with perl.. (still a bit of a noob actually)!
So I value any hints! its nice to have a great support from this forum, my players and I salute you all