PDA

View Full Version : Displaying quest globals


kayen85
06-17-2008, 11:39 AM
I am having difficulty in getting any quest to use the quest global values that I enter. I used an example script from the site to set the value to ensure I was doing it right, however I can not under an circumstances write a line of code that will display the value, or even use it to trigger an event.

If I get mysql quest global file though, it is infact in there.... So how do I get it out so I can use it?

sub EVENT_SAY {

if ($text=~/hail/i) {

quest::say("Hail to you, lesser being!");

} elsif ($text=~/Set/i) {

quest::say("Setting your stupid var human !");
quest::delglobal("AVAR");
quest::setglobal("AVAR", 1, 7, "Y50");

} elsif ($text=~/Get/i) {

quest::say("Here is your results $qglobals{AVAR} " );




}

}

Every time I do get, it just reads the line and omits the value.

I have tried linking it to conditions like


if($qglobals{AVAR}) == 1)

or

if(defined($qglobals{AVAR}))


I am not sure what I am doing wrong at this point.

Kayen

Cripp
06-17-2008, 11:44 AM
try this one...
sub EVENT_SAY
{
if ($text=~/hail/i)
{
quest::say("Hail to you, lesser being!");
}
if ($text=~/Set/i)
{
quest::say("Setting your stupid var human !");
if (!defined $qgobals{AVAR})
{
quest::delglobal("AVAR");
quest::setglobal("AVAR", 1, 7, "Y50");
}
}
if ($text=~/Get/i)
{
my $avar = $qglobals{AVAR};
quest::say("Here is your results $avar");
}
}

PS: not sure if that red semicolon should go there or not.. thats why i made it red.

kayen85
06-17-2008, 12:06 PM
Tried your code, same problem. Its set perfectly in the mysql file but it will just not display it in the text when retrieved. Semicolon was needed btw.

I understand the code so it just doesn't make sense why it isn't working. Seems simple enough.

Kayen

Congdar
06-17-2008, 03:06 PM
using your original code, try this:


sub EVENT_SAY {
if ($text=~/hail/i) {
quest::say("Hail to you, lesser being!");
}
elsif ($text=~/Set/i) {
quest::say("Setting your stupid var human !");
quest::delglobal("AVAR");
quest::setglobal("AVAR", 1, 7, "Y50");
}
elsif ($text=~/Get/i) {
quest::say("Here is your results $AVAR");
}
}

kayen85
06-17-2008, 05:51 PM
Thanks Conglar,

But still no luck. I really don't know why it isn't displaying. Again the variable is in the global file I just can't use it.

SoTRichard
06-17-2008, 08:07 PM
don't know if this has anything to do with it, but sometimes i forget to set the npc's global to 1... you have to do that to get the globals to work.

kayen85
06-17-2008, 09:17 PM
Hmm maybe, how exactly do I set an NPC's global to 1?

Cripp
06-17-2008, 09:52 PM
ah ya thats it.. the sql syntax UPDATE npc_types SET qglobal=1 where id=npcID; (qglobal or qglobals, not sure which)

Congdar
06-17-2008, 09:54 PM
find the npc in the npc_types table in the database and set the qglobal value to 1

kayen85
06-17-2008, 10:33 PM
Yup, that was the problem. All fixed. Thanks guys appreciate it.

SoTRichard
06-17-2008, 11:55 PM
np, glad i could help