Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #TEST QUEST...
- sub EVENT_SAY {
- if($text=~/#balls/i) {
- if(plugin::collect_quest($client, 1081, 4)) {
- $client->Message(335, "Removing 4 waters!");
- } else {
- $client->Message(335, "You dont have 4 waters!");
- }
- }
- }
- #plugin::check_hascount($client, itemid, amountcheck)
- sub collect_quest {
- my $client = shift;
- my $itemid = shift;
- my $count = shift;
- my $count_total = 0;
- my $stackable = 0;
- #Ignore cursor / cursor bags Slots 30 / 331-340
- my @slots = (22..29, 251..330);
- foreach $slot (@slots) {
- if ($client->GetItemIDAt($slot) == $itemid) {
- $stackable = $client->GetItemStat($itemid, "stackable");
- if($stackable) {
- $count_total+= $client->GetItemAt($slot)->GetCharges();
- } else {
- $count_total++;
- }
- }
- }
- if ($count_total >= $count) {
- plugin::collect_quest_remove($client, $itemid, $count);
- return 1;
- } else {
- return 0;
- }
- }
- #plugin::collect_quest($client, itemid, amountcheck)
- sub collect_quest_remove {
- my $client = shift;
- my $itemid = shift;
- my $count = shift;
- my $item_charges;
- my $stackable = 0;
- #Ignore cursor / cursor bags Slots 30 / 331-340
- my @slots = (22..29, 251..330);
- foreach $slot (@slots) {
- if ($client->GetItemIDAt($slot) == $itemid) {
- $stackable = $client->GetItemStat($itemid, "stackable");
- #stackable items must remove charges...
- if($stackable) {
- $item_charges = $client->GetItemAt($slot)->GetCharges();
- if ($item_charges >= $count) {
- $client->DeleteItemInInventory($slot, $count, 1);
- $count = 0;
- }
- elsif($item_charges < $count && $item_charges > 0) {
- $client->DeleteItemInInventory($slot, $item_charges, 1);
- $count-= $item_charges;
- }
- } else {
- #non-stackable items must be 0 charges to remove the entire item
- $item_charges = 1;
- $client->DeleteItemInInventory($slot, 0, 1);
- $count-= $item_charges;
- }
- }
- if($count <= 0) {
- return 1;
- }
- }
- return 0;
- }
- 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement