Log in

View Full Version : Proximity and hasitem


Randymarsh9
06-30-2009, 12:46 AM
I am trying to make something that will basically move someone away if they don't have an item in their inventory and then let them pass by if they do have it.

sub EVENT_SPAWN{
my $x;
my $y;
$x = $npc->GetX();
$y = $npc->GetY();
quest::set_proximity( $x-30,$x+30,$y-5,$y+5);
}

sub EVENT_ENTER{
if(plugin::check_hasitem($client, 1531)) {
quest::emote("You pass beyond the barrier");
}
elsif{
quest::movechar(189,0,0,0);
}
}

Nothing happens either way. I never really use proximities, so I'm sure this is another simple mistake

Sion
06-30-2009, 01:36 AM
This should work:

sub EVENT_SPAWN {
my $x;
my $y;
$x = $npc->GetX();
$y = $npc->GetY();
quest::set_proximity( $x-30,$x+30,$y-5,$y+5);
}

sub EVENT_ENTER {
if(plugin::check_hasitem($client, 1531)) {
quest::emote("You pass beyond the barrier");
}
else{
quest::movepc(189,0,0,0);
}
}


It looks like you used elseif instead of else and used quest::movechar when its supposed to be quest::movepc.

Randymarsh9
06-30-2009, 01:48 AM
Does elsif really not work? I have it in another quest where it works fine

Shendare
06-30-2009, 01:55 AM
The elsif statement is used to check another condition. The else statement is used when there is no other condition to check.

Example:


if ($faction == 1)
{
quest::say("Faction 1!");
}
elsif ($faction == 2)
{
quest::say("Faction 2!");
}
else
{
quest::say("Faction 3+!");
}

Sion
06-30-2009, 02:08 AM
elsif works but in this case you would want to just use else. elsif is basically an else statement and an if statement combined.