PDA

View Full Version : Buffer Script Help


Furinex
11-17-2007, 08:48 AM
Ok so I have a problem, Im trying to get this script working for an NPC buffer in PoK. Basically when you hail him, they text works, he spits it back at you, and you can go further by saying pricelist and he'll spit more text at you... Hell, you can even say Heal and he'll CH you. But the problem is, if you do any of the buffs commands like kei or sow then he wont do a damn thing... here's the script...

sub EVENT_SAY
{
if($text=~/Hail/i)
{quest::say("Greetings $name. If you want me to cast a spell on you, please say so and I

will give you my [pricelist]. If you want me to [heal] you, please say so and I will do it

for free.");}
if($text=~/pricelist/i)
{quest::say("I can cast the following spells : Spirit of Wolf = [sow], Dead Man Floating =

[dmf], Clarity II = [clarity], Spiritual Light = [sl], Spiritual Radiance = [sr], Temperance

= [temp], Virtue = [virtue], KEI = [kei], Conviction = [conv], Clairvoyance = [clairo]");}
if ($text=~/heal/i)
{
quest::selfcast(13);
{
}
sub EVENT_ITEM
{
if ($text=~/sow/i)
{
quest::selfcast(278);
}
if ($text=~/dmf/i)
{
quest::selfcast(457);
}
if ($text=~/clarity/i)
{
quest::selfcast(1693);
}
if ($text=~/sl/i)
{
quest::selfcast(2176);
}
if ($text=~/sr/i)
{
quest::selfcast(2177);
}
if ($text=~/temp/i)
{
quest::selfcast(3692);
}
if ($text=~/virtue/i)
{
quest::selfcast(3467);
}
if ($text=~/kei/i)
{
quest::selfcast(2570);
}
if ($text=~/conv/i)
{
quest::selfcast(5257);
}
if ($text=~/clairo/i)
{
quest::selfcast(5513);
}


What am I doing wrong?

Derision
11-17-2007, 11:07 AM
What am I doing wrong?

The major thing you had wrong was the responses for casting spells (other than heal) were in a SUB EVENT ITEM block ... that is for item hand-ins.

This should work (I tested it on my server). Basically moved everything into the SUB EVENT SAY, and I think there were some bracket mis-matches as well:






sub EVENT_SAY
{
if($text=~/Hail/i)
{
quest::say("Greetings $name. If you want me to cast a spell on you, please say so and I will give you my [pricelist]. If you want me to [heal] you, please say so and I will do it for free.");
}

if($text=~/pricelist/i)
{
quest::say("I can cast the following spells : Spirit of Wolf = [sow], Dead Man Floating = [dmf], Clarity II = [clarity], Spiritual Light = [sl], Spiritual Radiance = [sr], Temperance = [temp], Virtue = [virtue], KEI = [kei], Conviction = [conv], Clairvoyance = [clairo]");
}

if ($text=~/heal/i)
{
quest::selfcast(13);
}


if ($text=~/sow/i)
{
quest::selfcast(278);
}

if ($text=~/dmf/i)
{
quest::selfcast(457);
}

if ($text=~/clarity/i)
{
quest::selfcast(1693);
}

if ($text=~/sl/i)
{
quest::selfcast(2176);
}

if ($text=~/sr/i)
{
quest::selfcast(2177);
}

if ($text=~/temp/i)
{
quest::selfcast(3692);
}

if ($text=~/virtue/i)
{
quest::selfcast(3467);
}

if ($text=~/kei/i)
{
quest::selfcast(2570);
}

if ($text=~/conv/i)
{
quest::selfcast(5257);
}

if ($text=~/clairo/i)
{
quest::selfcast(5513);
}

}

Richardo
11-20-2007, 02:38 AM
As Derision said... Try to remember opening and closing brackets.. Here's an example.. In the sub EVENT_ITEM block you had, you were forgetting the second closing bracket at the bottom which is invalid syntax. With the closing bracket, your syntax would have been fine although it wouldn't have worked the way you wanted ingame.

sub EVENT_SAY
{ ##This bracket is opening for the operator below.
if($text=~/hail/i)
{ ##This bracket is opening for the statement below.
quest::say("Hello $name!");
} ##This bracket closes the first opening bracket
} ##This bracket closes the second opening bracket

Whenever there is a {, there must always be a } to close it or the syntax is incorrect.

Here is another example in your code that you can learn from.

if($text=~/pricelist/i)
{
if ($text=~/heal/i)
{
quest::selfcast(13);
{ ##This must be a closing bracket because of the opening bracket above.
}

Secrets
12-01-2007, 05:18 AM
Sorry for adding another post to a week-old thread, but this is another thing that can help for future reference (in regards to finding unclosed brackets):

You can run them through the perl parser in the command line interface to find where and why your syntax is wrong.

If you are in windows, and installed perl with all the default settings, you can simply drag-and-drop the .pl file into the command line and if the perl file is correct, it will just put you back at the windows command line.

If it's not, it will say something like, "Syntax error on line x" where x is a line number. You can then go into wordpad or notepad and go to that line and see what the issue is. Be prepared to look above it if it is an unmatched left bracket.

Just thought i'd throw that out there to help some people.