your logic was a bit convoluted, had redundant checks, and at least one part was never going to be triggered (see highlights). also, when you were incrementing $botcount, it wasn't updating the qglobals, which it seemed to appear what you intended.
Quote:
Originally Posted by Sinclipse
Code:
##Bot Script ##Made by Dirge
sub EVENT_SAY
{
$botcount = $qglobal{bot_spawn_limit};
if(($ulevel >= 10) && ($botcount == 0))
{
$companion = quest::saylink("companion");
$yes = quest::saylink("yes");
# we already know $botcount is 0
if($botcount == 0)
{
if($text=~/hail/i)
{
plugin::Whisper("Hello there $name; would you be interested in obtaining a [$companion]?");
}
elsif($text=~/companion/i)
{
plugin::Whisper("Of course, I live to serve. 'Insert info about bot 1'");
}
elsif($text=~/yes/i)
{
# we already know both of these are true
if(($ulevel >= 10) && ($botcount == 0))
{
plugin::Whisper("Enjoy your first of many companions.");
# this is not updating the qglobal
$botcount = $qglobals{bot_spawn_limit} + 1;
}
# this will never happen, as we already know $botcount is 0
else
{
plugin::Whisper("You already have one bot; come back again once you are more experienced.");
}
}
}
}
elsif(($ulevel >= 30) && ($botcount > 0 && $botcount < 2))
{
$completed = 0;
$companion = quest::saylink("companion");
if($text=~/hail/i)
{
plugin::Whisper("Hello again $name; are you interested in acquiring a second [$companion]?");
}
elsif($text=~/companion/i)
{
plugin::Whisper("Very well, 'Insert info about bot 2'");
}
##End Product
elsif($completed == 1)
{
plugin::Whisper("Congratulations $name; here is your second companion.");
# this is not updating the qglobal
$botcount = $qglobal{bot_spawn_limit} + 1;
}
}
elsif($botcount >= 2)
{
plugin::Whisper("You already have the maximum number of companions; go adventure.");
}
else
{
plugin::Whisper("Please return when you have acquired enough knowledge.");
}
}
This is the current code we have, it doesn't work. I've changed the plugin::Whisper to $npcwhisper as well, I can't seem to figure this out, is it something I'm doing wrong in the Database? As, when I tried copying over the Bazaar way of obtaining Bots to a random NPC in Nexus, it STILL didn't work... What's going on with the script, any help would be great.
|
try this:
Code:
##Bot Script ##Made by Dirge
sub EVENT_SAY
{
$companion = quest::saylink("companion");
$yes = quest::saylink("yes");
# qglobal not set, assume no bots.
if (!defined $qglobal{bot_spawn_limit})
{
if ($ulevel < 10)
{
quest::say("Please return when you have acquired enough knowledge.");
}
elsif ($text=~/hail/i)
{
quest::say("Hello there $name; would you be interested in obtaining a [$companion]?");
}
elsif ($text=~/companion/i)
{
quest::say("Of course, I live to serve. 'Insert info about bot 1'");
}
elsif ($text=~/yes/i)
{
quest::say("Enjoy your first of many companions.");
quest::setglobal('bot_spawn_limit', 1, 5);
}
}
# qglobal is set to 1
elsif ($qglobal{bot_spawn_limit} == 1)
{
$completed = 0;
if ($ulevel < 30)
{
quest::say("Please return when you have acquired enough knowledge.");
}
elsif ($text=~/hail/i)
{
quest::say("Hello again $name; are you interested in acquiring a second [$companion]?");
}
elsif ($text=~/companion/i)
{
quest::say("Very well, 'Insert info about bot 2'");
}
## End Product
elsif ($completed == 1)
{
quest::say("Congratulations $name; here is your second companion.");
quest::setglobal('bot_spawn_limit', 2, 5);
}
}
# qglobal is > 1
else
{
quest::say("You already have the maximum number of companions; go adventure.");
}
}