Thread: perl syntax...
View Single Post
  #2  
Old 06-19-2004, 09:30 AM
animepimp
Dragon
 
Join Date: Jan 2004
Posts: 860
Default

Your problem is that you are using far too many braces. You should use one pair of braces to enclose the entire sub. Then you should use one and only one pair to enclose every line you want to associate with each if statement. Change
Quote:
Code:
sub EVENT_SAY 
{ 
if ($text=~ /Hail/i){quest::say("Who are you and how do you know me?");} 
if ($text=~ /know/i){quest::say("Not just everyone knows me! Only a privileged few.  But you seem trustworthy, perhaps i can use you.");} 
if ($text=~ /use/i){quest::say("I lead the resistance in Norrath.  I'm in need of soldiers.  Are you willing?");} 
if ($text=~ /willing/i){quest::say("Good, see Nyla for equipment.  Then see one of our undercover ops in the house next to us for your assignment.");} 
{guest::givecash(1000,0,0,0);} 
{guest::setallskill(255);} 
{quest::level(8);} 
{quest::pvp(on);} 
}
To
Code:
sub EVENT_SAY 
{ 
if ($text=~ /Hail/i)
  {
  quest::say("Who are you and how do you know me?");
  } 
if ($text=~ /know/i)
  {
  quest::say("Not just everyone knows me! Only a privileged few.  But you seem trustworthy, perhaps i can use you.");
  } 
if ($text=~ /use/i)
  {
  quest::say("I lead the resistance in Norrath.  I'm in need of soldiers.  Are you willing?");
  } 
if ($text=~ /willing/i)
  {
  quest::say("Good, see Nyla for equipment.  Then see one of our undercover ops in the house next to us for your assignment.");
  guest::givecash(1000,0,0,0);
  guest::setallskill(255);
  quest::level(8);
  quest::pvp(on);
  }
}
It may not be your whole problem, but its definitely a big mistake. Lines are seperated by a ; no need to seperate each one by {}s. Block of code such as if statements are seperated by {}s. I'd suggest looking at an introductory programming tutorial website. I don't know if you can find one for perl, but C++ or Java ones would help you out a lot because their syntax is very similar and they would teach you all you need to know to write basic quests.
Reply With Quote