|
|
 |
 |
 |
 |
|
 |
 |
|
 |
 |
|
 |
|
Quests::Q&A This is the quest support section |
 |
|
 |

03-29-2013, 11:55 PM
|
Discordant
|
|
Join Date: Jan 2013
Posts: 284
|
|
Charm Up-grader.
My charm up-grader will upgrade you from Rank 1 to Rank 2, but after that he just gives back your items, any ideas? Code below:
Code:
sub EVENT_SAY
{
my $charm = quest::saylink("Charm", 1);
my $token = quest::varlink(140226);
if($text=~/Hail/i)
{
plugin::Whisper("Hello, young $class, would you like a $charm?");
plugin::Whisper("To upgrade your charm you must hand me the charm and an $token.");
#plugin::Whisper("In development, try again later.");
}
if($text=~/Charm/i)
{
quest::summonitem(140126);
}
}
sub EVENT_ITEM
{
@charmlist = qw(
140126
140127
140128
140129
140130
140131
140132
140133
140134
140135
140136
140137
140138
140139
140140
140141
140142
140143
140144
140145
140146
140147
140148
140149
140150
140151
140152
140153
140154
140155
140156
140157
140158
140159
140160
140161
140162
140163
140164
140165
140166
140167
140168
140169
140170
140171
140172
140173
140174
140175
140176
140177
140178
140179
140180
140181
140182
140183
140184
140185
140186
140187
140188
140189
140190
140191
140192
140193
140194
140195
140196
140197
140198
140199
140200
140201
140202
140203
140204
140205
140206
140207
140208
140209
140210
140211
140212
140213
140214
140215
140216
140217
140218
140219
140220
140221
140222
140223
140224
140225
);
my $n = 0;
while ($charmlist[$n])
{
my $charmid = $charmlist[$n];
if (plugin::check_handin(\%itemcount, $charmid => 1, 140226 => 1))
{
plugin::Whisper("Here is your upgraded charm!");
quest::summonitem($charmid+1, 1);
}
else
{
plugin::return_items(\%itemcount);
quest::givecash($copper,$silver,$gold,$platinum);
}
$n++;
}
}
|
 |
|
 |

03-30-2013, 12:26 AM
|
Demi-God
|
|
Join Date: Aug 2010
Posts: 1,742
|
|
Think about the logic there. Check if the first item matches, if it does give the upgrade, otherwise return the items. By the time you get to checking the second item you've already given everything back.
I'm no expert, but it seems to me you would want to check the whole list for matches before giving anything back.
|

03-30-2013, 01:14 AM
|
Dragon
|
|
Join Date: May 2010
Posts: 965
|
|
|
 |
|
 |

03-30-2013, 02:30 AM
|
Discordant
|
|
Join Date: Jan 2013
Posts: 284
|
|
Revised version, haven't tested, is this the way mentioned in that post?
Code:
sub EVENT_SAY
{
my $charm = quest::saylink("Charm", 1);
my $token = quest::varlink(140226);
if($text=~/Hail/i)
{
plugin::Whisper("Hello, young $class, would you like a $charm?");
plugin::Whisper("To upgrade your charm you must hand me the charm and an $token.");
#plugin::Whisper("In development, try again later.");
}
if($text=~/Charm/i)
{
quest::summonitem(140126);
}
}
sub EVENT_ITEM
{
@charmlist = qw(
140126
140127
140128
140129
140130
140131
140132
140133
140134
140135
140136
140137
140138
140139
140140
140141
140142
140143
140144
140145
140146
140147
140148
140149
140150
140151
140152
140153
140154
140155
140156
140157
140158
140159
140160
140161
140162
140163
140164
140165
140166
140167
140168
140169
140170
140171
140172
140173
140174
140175
140176
140177
140178
140179
140180
140181
140182
140183
140184
140185
140186
140187
140188
140189
140190
140191
140192
140193
140194
140195
140196
140197
140198
140199
140200
140201
140202
140203
140204
140205
140206
140207
140208
140209
140210
140211
140212
140213
140214
140215
140216
140217
140218
140219
140220
140221
140222
140223
140224
140225
);
my $n = 0;
while ($charmlist[$n])
{
my $charmid = $charmlist[$n];
if (plugin::check_handin(\%itemcount, $charmid => 1, 140226 => 1))
{
plugin::Whisper("Here is your upgraded charm!");
quest::summonitem($charmid+1, 1);
}
$n++;
}
plugin::return_items(\%itemcount);
quest::givecash($copper,$silver,$gold,$platinum);
}
|
 |
|
 |

03-30-2013, 06:28 AM
|
 |
Dragon
|
|
Join Date: Dec 2009
Posts: 719
|
|
very inefficient to loop through the entire list of valid charms (100?) instead of just checking the item ids that were turned in (max of 4).
put this at the top of your file to be able to use the ~~ operator:
Code:
foreach my $itemid (%itemcount)
{
next unless $itemid ~~ [140126..140225];
if (plugin::check_handin(\%itemcount, $charmid => 1, 140226 => 1))
{
plugin::Whisper("Here is your upgraded charm!");
quest::summonitem($itemid+1, 1);
}
}
plugin::return_items(\%itemcount);
quest::givecash($copper, $silver, $gold, $platinum);
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
|

03-30-2013, 11:14 AM
|
 |
Dragon
|
|
Join Date: Dec 2009
Posts: 719
|
|
oops. that should read:
Code:
foreach my $itemid (keys %itemcount)
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
|

03-30-2013, 04:16 PM
|
Discordant
|
|
Join Date: Jan 2013
Posts: 284
|
|
The one you gave me actually doesn't work, in the fact that he just eats the items, the second one I posted, the revised one, works correctly.
|

03-30-2013, 06:33 PM
|
 |
Dragon
|
|
Join Date: Dec 2009
Posts: 719
|
|
that $charmid should be $itemid. was half asleep both times i posted.
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 01:55 AM.
|
|
 |
|
 |
|
|
|
 |
|
 |
|
 |