Advertisement
Emistry

[RO] Count Item in Account

Apr 23rd, 2019
487
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.29 KB | None | 0 0
  1. // https://rathena.org/board/topic/118854-npc-item-with-control-request/
  2.  
  3. prontera,155,181,5  script  Sample  4_F_KAFRA1,{
  4.     .@item_id = 512;
  5.    
  6.     if (callsub(L_HasItem, .@item_id)) {
  7.         npctalk "you already obtained "+getitemname(.@item_id);
  8.     }
  9.     else {
  10.         getitem .@item_id,1;
  11.         npctalk "you obtained "+getitemname(.@item_id);
  12.     }
  13.     end;
  14.  
  15.  
  16.     L_HasItem:
  17.         .@item_id = getarg(0, 0);
  18.         .@cid = getcharid(0);
  19.         .@aid = getcharid(3);
  20.         .@gid = getcharid(2);
  21.        
  22.         if (.@item_id) {
  23.             query_sql("SELECT COUNT(1) FROM `inventory` WHERE `nameid` = "+.@item_id+" AND `char_id` IN (SELECT `char_id` FROM `char` WHERE `account_id` = "+.@aid+")", .@inventory);
  24.             query_sql("SELECT COUNT(1) FROM `cart_inventory` WHERE `nameid` = "+.@item_id+" AND `char_id` IN (SELECT `char_id` FROM `char` WHERE `account_id` = "+.@aid+")", .@cart_inventory);
  25.            
  26.             if (.@gid)
  27.                 query_sql("SELECT COUNT(1) FROM `guild_storage` WHERE `nameid` = "+.@item_id+" AND `guild_id` = "+.@gid+")", .@guild_storage);
  28.  
  29.        
  30.             .@count += .@inventory;
  31.             .@count += .@cart_inventory;
  32.             .@count += .@guild_storage;
  33.            
  34.             .@count += countitem(.@item_id);
  35.             .@count += cartcountitem(.@item_id);
  36.             .@count += storagecountitem(.@item_id);
  37.             if (.@gid)
  38.                 .@count += guildstoragecountitem(.@item_id);
  39.         }
  40.         return (.@count > 0);
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement