Code:
sub EVENT_SAY
{
if($text=~/hail/i)
{
if($solusek == "")
{
quest::say("Hello, would you like to [help] me?");
$solusek="";
}
elsif($solusek=="1")
{
quest::say("Thanks for helping me!");
$solusek="";
}
}
if($text=~/help/i)
{
quest::targlobal("solusek","1","Y5",281099,$charid,26);
quest::me("You have recieved a character flag!");
}
}
Kk lets start with a few things.
The quest::targlobal command is used to set entries into the sql database, which are then turned into global variables for use in the form $var1, $var2 etc.. however they are not perl global variables.
What this means is, they can't be set as script variables,
will not work to affect the sql table.
with that lets try to re write the code yes?
Code:
sub EVENT_SAY
{
if($text=~/hail/i)
{
if($solusek == "")
{
quest::say("Hello, would you like to [help] me?");
}
elsif($solusek=="1")
{
quest::say("Thanks for helping me!");
}
}
if($text=~/help/i)
{
quest::targlobal("solusek","1","Y5",281099,$charid,26);
quest::me("You have recieved a character flag!");
}
}
Now a few things to look at here, you are trying to set a global variable for a flag, i assume this means you will use this flag with mob number 281099, and i also assume that the script this is put on is infact mob 281099.
now the script above dosen't do what you orignally intended, so lets add the stuff that needs to be added so it will do what you were trying to accomplish.
Code:
sub EVENT_SAY
{
if($text=~/hail/i)
{
if($solusek == "")
{
quest::say("Hello, would you like to [help] me?");
}
elsif($solusek=="1")
{
quest::targlobal("solusek","","Y1",281099,$charid,26);
quest::say("Thanks for helping me!");
}
}
if($text=~/help/i)
{
quest::targlobal("solusek","1","Y5",281099,$charid,26);
quest::me("You have recieved a character flag!");
}
}
The Result of this quest wil be.
You say: "Hail Mob 281099."
Mob says: "Hello, would you like to [help] me?"
You say: "I will help you"
You have Recieved a Character Flag!
You say: "Hail Mob 281099"
Mob says: "Thanks for helping me!"
You say: "Hail mob 281099"
Mob says: "Would you like to [help] me?"
You say: "I will help you"
You have Recieved a Character Flag!
You say: "Hail Mob 281099"
Mob says: "Thanks for helping me!"
just a big long loop!!
If you were to start off by just saying
"I will help you"
then hail he would say
"Thanks for helping me!"
if you said
"i will help you"
again, he would say
"Thanks for helping me!"
on the next hail, now you could aviod this by putting in a variable check right after the $text =~/help/i line
Code:
sub EVENT_SAY
{
if($text=~/hail/i)
{
if($solusek == "")
{
quest::say("Hello, would you like to [help] me?");
}
elsif($solusek=="1")
{
quest::targlobal("solusek","","Y1",281099,$charid,26);
quest::say("Thanks for helping me!");
}
}
if($text=~/help/i)
{
if($solusek != "1")
{
quest::targlobal("solusek","1","Y5",281099,$charid,26);
quest::me("You have recieved a character flag!");
}
else # $solusek does = 1
{
quest::say("Yes, i know you will help me!");
}
}
}
Now a little thing i have found about quests, i have run into a problem multiple times that for some odd reason doesn't set the varialbe to the exact $charid. i.e.
"Hail, Mob!"
"Hello Bob, are you [good]?"
"I am good"
"Glad to hear"
"Hail, Mob!"
"Yes i know your good"
Ok so this goes well, however the next person comes up.
"Hail, Mob!"
"Yes i know your good"
Err.. whats going on? Problem with the communication between the qglobal table, and zone.exe. <shrug>
Or!
"Hail Mob"
"Hi Bob, have you got my item?"
You hand in item
Mob sets variable $item to value "2" indicating you have turned int he item.
"Asome! Tell me when you are [ready]"
But before you can say ready, Joe was watching and types
"i am ready"
Now he should get the respond
"Your not ready Joe, i didn't get an item from you"
But instead he gets.
Variable set to "1" indicating you are no longer ready, but it affectrs your variable and not his =/.
"Ok off you go!"
and Bob says "ready" and gets the
"Your not ready Bob, i didn't get an item from you.
erf nother problem.
SO! to avoid this a simple change is made to assigning variables
instead of
Code:
quest::targlobal("Var","1","D1",$mobid,$charid,$zoneid)
you would instead make the value personal.
eg.
Code:
quest::targlobal("Var",$charid + 1,"D1",$mobid,$charid,$zoneid);
This makes sure that Character 1 will have a value of 2, and character 2 will have a value of 3, thus when you check to see if they have the correct value you put.
Code:
If($var == $charid + 1)
{ }
this will make it so that if joe says "ready" and the variable returns 3 becuase hei s charid 2, it will not pass, but when Bob says "ready" it finds th e variable to equal $charid + 1 = 1 +1 = 2, and it works!.
that way you won't run into these types of errors =), and ofcourse you can use any combination with $charid. $charid + 2, $charid + 1423, etc.. it doesn't matter, however it ensures that you don't run into this issue.
Hope this helped =)