Advertisement
NatedogServer

Collect Quest plugin

Nov 12th, 2014
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.18 KB | None | 0 0
  1. #plugin::check_hascount($client, itemid, amountcheck)
  2. sub check_hascount {
  3.     my $client = shift;
  4.     my $itemid = shift;
  5.     my $count = shift;
  6.     my $count_total = 0;
  7.    
  8.     #Ignore cursor / cursor bags Slots 30 / 331-340
  9.     my @slots = (0..29, 251..330);
  10.     foreach $slot (@slots) {
  11.         if ($client->GetItemIDAt($slot) == $itemid) {
  12.             $count_total+= $client->GetItemAt($slot)->GetCharges();
  13.         }
  14.     }
  15.     if ($count_total >= $count) {
  16.         return 1;
  17.     } else {
  18.         return 0;
  19.     }
  20. }
  21.  
  22. #plugin::collect_quest($client, itemid, amountcheck)
  23. sub collect_quest {
  24.     my $client = shift;
  25.     my $itemid = shift;
  26.     my $count = shift;
  27.     my $item_charges;
  28.    
  29.     #Ignore cursor / cursor bags Slots 30 / 331-340
  30.     my @slots = (0..29, 251..330);
  31.     foreach $slot (@slots) {
  32.         if ($client->GetItemIDAt($slot) == $itemid) {
  33.             $item_charges = $client->GetItemAt($slot)->GetCharges();
  34.             if ($item_charges >= $count) {
  35.                 $client->DeleteItemInInventory($slot, $count, 1);
  36.                 $count = 0;
  37.             }
  38.             elsif($item_charges < $count && $item_charges > 0) {
  39.                 $client->DeleteItemInInventory($slot, $item_charges, 1);
  40.                 $count-= $item_charges;
  41.             }
  42.         }
  43.         if($count <= 0) {
  44.             return 1;
  45.         }
  46.     }
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement