viewing paste restoc diff | Diff

Posted on the | Last edited on
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649
Index: sql-files/restock.sql
===================================================================
--- sql-files/restock.sql   (revision 0)
+++ sql-files/restock.sql   (revision 0)
@@ -0,0 +1,29 @@
+-- --------------------------------------------------------
+-- restock systeme
+--
+-- Table structure for table `restock`
+--
+
+CREATE TABLE IF NOT EXISTS `restock_lists` (
+  `list_id` int(11) NOT NULL AUTO_INCREMENT,
+  `list_name` varchar(200) NOT NULL,
+  `char_id` int(11) NOT NULL,
+  PRIMARY KEY (`list_id`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+CREATE TABLE IF NOT EXISTS `restock_items` (
+  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+  `list_id` int(11) NOT NULL,
+  `slot` int(11) NOT NULL DEFAULT '0',
+  `item_id` int(11) NOT NULL DEFAULT '0',
+  `item_nb` int(11) NOT NULL DEFAULT '0',
+  `identify` smallint(6) unsigned NOT NULL DEFAULT '0',
+  `refine` tinyint(3) unsigned NOT NULL DEFAULT '0',
+  `attribute` tinyint(4) unsigned NOT NULL DEFAULT '0',
+  `card0` smallint(11) NOT NULL DEFAULT '0',
+  `card1` smallint(11) NOT NULL DEFAULT '0',
+  `card2` smallint(11) NOT NULL DEFAULT '0',
+  `card3` smallint(11) NOT NULL DEFAULT '0',
+  PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
Index: npc/gro_custom/restock.txt
===================================================================
--- npc/gro_custom/restock.txt  (revision 0)
+++ npc/gro_custom/restock.txt  (revision 0)
@@ -0,0 +1,334 @@
+-  script  Restock#00  80,{
+
+cutin "job_dancer_eir01",2;
+L_menu :
+   classchange 4060,0;
+   set @charid,getcharid(0);
+   set @charname$,strcharinfo(0);
+   menu    "Restock",L_restk,
+       "Voir son enregistrement",L_seelist,
+       "Enregistrer ses consommables",L_record,
+       "Supprimer un Slot",L_delslot,
+       "Changer de liste d'enregistrement",L_mdflist,
+       "Supprimer une liste d'enregistrement",L_dellist,
+       "Quittez",-;
+   cutin "",255;
+   close;
+//end L_menu
+
+L_record:
+   query_sql "select count(*) from `"+$restock_tl$+"` where char_id="+@charid+"",.@count;
+   mes "[Restockeur]";
+   mes "Bonjour "+@charname$+"";
+   if(.@count < 5) {       
+       mes "Vous pouvez ici enregistrer vos items à restock !";
+       mes "Il vous suffit de mettre les items en nombre voulut dans votre inventaire !";
+       mes "Tout d'abord, veuillez entrer un nom pour votre liste :";
+       mes "Attention vous avez le droit au maximum à 5 listes différentes !";
+       next;
+       do {    
+           set .@ok,callsub(S_new_list);
+       } while(.@ok==0);
+       next;
+       query_sql "insert into `"+$restock_tl$+"`(list_name,char_id) values('"+escape_sql(@newlist$)+"',"+@charid+");";
+       query_sql "select list_id from `"+$restock_tl$+"` where list_name='"+escape_sql(@newlist$)+"' and char_id="+@charid,.@list_id;
+       set .@memook,callsub(S_memo_list,.@list_id); //attemp to save list
+       next;
+       mes "[Restockeur]";
+       if(.@memook){
+           set restock_lsel,.@list_id;
+           mes "Liste Enregistrée !";
+       }
+       else {  
+           query_sql "delete `"+$restock_tl$+"` where list_id='"+.@list_id; //remove if association failed
+           mes "Failed to memorize your list";
+       }
+   }   
+   else {
+       mes "Vous ne pouvez pas enregistrer de nouvelle liste, vous avez plus de 5 listes différentes !";
+   }
+   next;
+   goto L_menu;
+//end L_record
+
+
+L_restk:
+   callsub S_countlist;
+   set .@query$,"select item_id,item_nb,refine,identify,attribute,card0,card1,card2,card3 from `"+$restock_ti$+"` where list_id="+restock_lsel;
+   debugmes .@query$;
+   query_sql .@query$,.@item_id[0],.@item_nb[0],.@item_ref[0],.@item_iden[0],.@item_att[0],.@item_c0[0],.@item_c1[0],.@item_c2[0],.@item_c3[0]; //that the query man !
+   set .@nbitems,getarraysize(.@item_id);
+   debugmes ".@nbitems="+.@nbitems;
+
+   for(set .@item_it,0; .@item_it<.@nbitems; set .@item_it, .@item_it+1){
+       set .@item_id, .@item_id[.@item_it]; //current item for iteration
+       set .@list_nb, .@item_nb[.@item_it]; //list amount for item
+
+       set .@ref,.@item_ref[.@item_it];
+       set .@iden, .@item_iden[.@item_it];
+       set .@att, .@item_att[.@item_it];
+       set .@c0, .@item_c0[.@item_it];
+       set .@c1, .@item_c1[.@item_it];  
+       set .@c2, .@item_c2[.@item_it]; 
+       set .@c3, .@item_c3[.@item_it];
+       set .@inv_nb, countitem2(.@item_id,.@iden,.@ref,.@att,.@c0,.@c1,.@c2,.@c3); //inventory amount for item
+       debugmes "item_id="+.@item_id+" .@list_nb="+.@list_nb+" .@inv_nb="+.@inv_nb;
+       if (.@inv_nb > .@list_nb) { //put extra in storage
+           set .@diff_it, .@inv_nb - .@list_nb;
+           set .@ok,inv2stor(.@item_id,.@diff_it,.@iden,.@ref,.@att,.@c0,.@c1,.@c2,.@c3);
+           debugmes "storeitem id="+.@item_id+" amount="+.@diff_it+" .@ok="+.@ok;
+       }
+       else if (.@inv_nb < .@list_nb) { //try to retrive diff from storage
+           set .@diff_it, .@list_nb - .@inv_nb;
+           set .@stor_nb,countstorageitem(0,.@item_id,.@iden,.@ref,.@att,.@c0,.@c1,.@c2,.@c3);
+           debugmes ".@diff_it="+.@diff_it+" .@stor_nb="+.@stor_nb;
+           if(.@stor_nb >= .@diff_it){
+               set .@ok,stor2inv(.@item_id,.@diff_it,.@iden,.@ref,.@att,.@c0,.@c1,.@c2,.@c3);
+               debugmes "retriveitem id="+.@item_id+" amount="+.@diff_it+" .@ok="+.@ok;
+           }
+           else {
+               dispbottom "You don't have enough item="+.@item_id+"in storage, retirving rest";
+               set .@ok,stor2inv(.@item_id,.@stor_nb,.@iden,.@ref,.@att,.@c0,.@c1,.@c2,.@c3);
+               debugmes "retriveitem id="+.@item_id+" restamount="+.@stor_nb+" .@ok="+.@ok;
+           }   
+       }           
+   }
+   cutin "",255;
+   close;      
+//end rstk
+
+L_seelist:
+   callsub S_countlist;
+   query_sql "select list_name from `"+$restock_tl$+"` where list_id="+restock_lsel,.@lname$;
+   mes "nliste: "+restock_lsel+", name : "+.@lname$;
+   set .@slotmenu$,callsub(S_build_slots,1);
+   next;
+   goto L_menu;
+//end seelist
+
+L_delslot:
+   callsub S_countlist;
+   query_sql "select list_name from `"+$restock_tl$+"` where list_id="+restock_lsel,.@lname$; //name lookup
+   mes "nliste: "+restock_lsel+", name : "+.@lname$;
+   set .@slotmenu$,callsub(S_build_slots,0);
+   mes "Quel slot voulez vous supprimez ?";
+   select(.@slotmenu$);
+   query_sql "delete from `"+$restock_ti$+"` where list_id="+restock_lsel+" and slot="+(@menu-1);
+   mes "Slot have been correctly deleted";
+   next;
+   goto L_menu;
+//end delslot
+
+   
+L_mdflist:
+   callsub S_countlist;
+   mes "Quel liste voulez vous selectionner parmit celle-ci ?";
+   set .@menulist$,callsub(S_build_lists,0);
+   select(.@menulist$);
+   explode(.@options$,.@menulist$,":");
+   debugmes "mdf .@options$="+.@options$[@menu-1];
+   set .@list_select$,.@options$[@menu-1];
+   mes "Options selected ="+.@list_select$;
+   query_sql "select list_id from `"+$restock_tl$+"` where char_id="+@charid+" and list_name='"+escape_sql(.@list_select$)+"'",.@list_id;
+   set restock_lsel,.@list_id;
+   next;
+   goto L_menu;
+//end mdflist
+
+L_dellist:
+   callsub S_countlist;
+   mes "Quel liste voulez vous supprimer parmit celle-ci ?";
+   set .@menulist$,callsub(S_build_lists,0);
+   select(.@menulist$);
+   explode(.@options$,.@menulist$,":");
+   debugmes "del .@options$="+.@options$[@menu-1];
+   set .@list_select$,.@options$[@menu-1];
+   mes "Etes vous sur que vous voulez supprimer cette liste ?";
+   mes "Options selected ="+.@list_select$;
+   if(select("Yes:Non")==1){
+       query_sql "select list_id from `"+$restock_tl$+"` where char_id="+@charid+" and list_name='"+escape_sql(.@list_select$)+"'",.@list_id;
+       query_sql "delete from `"+$restock_tl$+"` where list_id="+.@list_id;
+       query_sql "delete from `"+$restock_ti$+"` where list_id="+.@list_id;
+   }
+   next;
+   goto L_menu;
+//end L_dellist
+
+
+
+//sub function for easy call
+S_new_list:
+   mes "Entrez le nom de votre liste !";
+   input @newlist$;                
+   if(@newlist$ == "") {
+       mes "Votre nom de liste n'est pas valide !";
+       next;
+       return 0;
+   }
+   query_sql "select list_id from `"+$restock_tl$+"` where char_id="+@charid+" and list_name='"+escape_sql(@newlist$)+"'",.@list_id;
+   if(.@list_id != 0) {
+       mes "Vous avez deja entrer ce nom de liste !";
+       next;
+       return 0;
+   }
+   return 1;
+//end newlist
+
+S_memo_list:
+   set .@list_id,getarg(0);
+   debugmes "S_memo_list id="+.@list_id;
+   select("Créer ma liste manuellement:Scanner mon inventaire");
+   switch(@menu){
+       case 1: //manuel
+           /*
+           set .@end,1;
+           do{ 
+               switch(select("Avancer:Reculer:Finir:Annuler")){
+                   case 1 : 
+                       if (.@slot<126) set .@slot,.@slot+1;
+                       else mes "Maximum de slot atteint"; 
+                       break;
+                   case 2 : if (.@index>1) set .@slot,.@slot-1;
+                       else mes "Le slot ne peut être negatif";
+                       break;
+                   case 3 : set .@end,0;
+                       break;
+                   case 4 :
+                       return 0;
+               }
+               if(@menu!=3){
+                   mes "Slot ["+.@slot+"] = "+getitemname(.@itemslot_id[.@slot])+":"+.@itemslot_id[.@slot]+" / "+.@itemslot_nb[.@slot];
+                   mes "Entrez l'item id :";
+                   input .@item_id;
+                   setarray .@itemslot_id[.@slot],.@item_id;
+                   mes "Entrez la quantité :";
+                   input .@item_nb;
+                   setarray .@itemslot_nb[.@slot],.@item_nb;
+                   mes "MAJ Slot ["+.@slot+"] = "+getitemname(.@item_id)+":"+.@item_id+" / "+.@item_nb;
+               }               
+           } while(.@end);
+           */
+           mes "Currently rewriting this, disable"; return 0;
+           break;
+       case 2: //scan inventaire
+           getinventorylist();
+           if(@inventorylist_count > 127){ //not possible normally but eh
+               mes "Les listes doivent être inférieur a 128 items";
+               return 0;
+           }
+           //copy to merge both methode
+           //copyarray .@itemslot_id[0],@inventorylist_id[0],@inventorylist_count;
+           //copyarray .@itemslot_nb[0],@inventorylist_amount[0],@inventorylist_count;
+           for (set .@slot,0; .@slot<@inventorylist_count; set .@slot,.@slot+1) {
+               set .@item_id,@inventorylist_id[.@slot];
+               set .@item_nb,@inventorylist_amount[.@slot];
+               set .@ref,@inventorylist_refine[.@slot];
+               set .@iden,@inventorylist_identify[.@slot];
+               set .@att,@inventorylist_attribute[.@slot];
+               set .@c0,@inventorylist_card1[.@slot];
+               set .@c1,@inventorylist_card2[.@slot];  
+               set .@c2,@inventorylist_card3[.@slot]; 
+               set .@c3,@inventorylist_card4[.@slot];
+               set .@query$,"insert into `"+$restock_ti$+"`(list_id,slot,item_id,item_nb,refine,identify,attribute,card0,card1,card2,card3) values("+.@list_id+","+.@slot+","+.@item_id+","+.@item_nb+","+.@ref+","+.@iden+","+.@att+","+.@c0+","+.@c1+","+.@c2+","+.@c3+");";
+               debugmes .@query$;
+               query_sql .@query$;
+           }
+           break;
+   } //end switch
+   /*
+   set .@listsize,getarraysize(.@itemslot_id);
+   for (set .@slot,0; .@slot<.@listsize; set .@slot,.@slot+1) {
+       set .@item_ib,.@itemslot_id[.@slot];
+       set .@item_nb,.@itemslot_nb[.@slot];
+       query_sql "insert into `"+$restock_ti$+"`(list_id,slot,item_id,item_nb) values("+.@list_id+","+.@slot+","+.@item_id+","+.@item_nb+");";
+   }
+   */
+   return 1;
+//end memo list    
+
+S_build_slots:
+   set .@display,getarg(0);
+   set .@query$,"select item_id,item_nb from `"+$restock_ti$+"` where list_id="+restock_lsel;
+   debugmes .@query$;
+   query_sql "select item_id,item_nb from `"+$restock_ti$+"` where list_id="+restock_lsel,.@item_id[0],.@item_nb[0];
+   set .@slot_nb,getarraysize(.@item_id);
+   debugmes ".@slot_nb="+.@slot_nb;
+   for(set .@slot,0; .@slot<.@slot_nb; set .@slot, .@slot+1) {
+       set .@slotmenu$,.@slotmenu$+"Slot ["+.@slot+"] = "+getitemname(.@item_id[.@slot])+" / "+.@item_nb[.@slot]+":";
+       if (.@display==1) mes "Slot ["+.@slot+"] = "+getitemname(.@item_id[.@slot])+" / "+.@item_nb[.@slot];
+       debugmes ".@slot["+.@slot+"]="+getitemname(.@item_id[.@slot])+" / "+.@item_nb[.@slot];
+   }
+   debugmes ".@slotmenu$="+.@slotmenu$;
+   return .@slotmenu$;
+//end build_slots
+
+S_build_lists:
+   set .@display,getarg(0);
+   query_sql "select distinct list_name from `"+$restock_tl$+"` where char_id="+@charid,.@listname$[0];
+   set .@lcount,getarraysize(.@listname$);
+   for(set .@numlist,0; .@numlist<.@lcount; set .@numlist, .@numlist+1) {
+       if (.@display==1) mes .@listname$[.@numlist];
+       set .@menulist$, .@menulist$+.@listname$[.@numlist]+":";
+       debugmes "numl["+.@numlist+"]="+.@listname$[.@numlist];
+   }
+   debugmes ".@menulist$="+.@menulist$;    
+   return .@menulist$;
+//end build_lists
+   
+S_countlist:
+   query_sql "select count(list_id) from `"+$restock_tl$+"` where char_id="+@charid+"",@listcount;
+   if (@listcount<=0){
+       mes "[Restockeur]";
+       mes "Bonjour "+@charname$+"";
+       mes "Vous n'avez fait aucun enregistrement !";
+       next;
+       goto L_menu;
+   }
+   return @listcount;
+//end countlist
+
+end; //extra end for security
+OnInit:    //config part
+   set $restock_tl$,"restock_lists";
+   set $restock_ti$,"restock_items";
+   end;
+}
+
+
+
+aldebaran,137,106,0    duplicate(Restock#00)   Restock#01  80
+amatsu,102,143,4   duplicate(Restock#00)   Restock#02  80
+ayothaya,203,171,4 duplicate(Restock#00)   Restock#03  80
+brasilis,240,318,4 duplicate(Restock#00)   Restock#04  80
+mid_camp,223,243,4 duplicate(Restock#00)   Restock#05  80
+cave,107,42,4  duplicate(Restock#00)   Restock#06  80
+comodo,190,141,4   duplicate(Restock#00)   Restock#07  80
+dicastes01,197,196,4   duplicate(Restock#00)   Restock#08  80
+einbroch,60,195,4  duplicate(Restock#00)   Restock#09  80
+einbech,166,132,4  duplicate(Restock#00)   Restock#10  80
+geffen,124,62,4    duplicate(Restock#00)   Restock#11  80
+gonryun,156,122,4  duplicate(Restock#00)   Restock#12  80
+hugel,91,157,4 duplicate(Restock#00)   Restock#13  80
+izlude,134,85,4    duplicate(Restock#00)   Restock#14  80
+lighthalzen,151,100,4  duplicate(Restock#00)   Restock#15  80
+louyang,207,97,4   duplicate(Restock#00)   Restock#16  80
+xmas,144,127,4 duplicate(Restock#00)   Restock#17  80
+manuk,288,188,4    duplicate(Restock#00)   Restock#18  80
+morocc,159,101,4   duplicate(Restock#00)   Restock#19  80
+moscovia,218,194,4 duplicate(Restock#00)   Restock#20  80
+payon,182,107,4    duplicate(Restock#00)   Restock#21  80
+prontera,153,189,4 duplicate(Restock#00)   Restock#22  80
+rachel,106,129,4   duplicate(Restock#00)   Restock#23  80
+splendide,179,148,4    duplicate(Restock#00)   Restock#24  80
+umbala,125,125,4   duplicate(Restock#00)   Restock#25  80
+veins,215,135,4    duplicate(Restock#00)   Restock#26  80
+yuno,154,187,4 duplicate(Restock#00)   Restock#27  80
+bat_room,148,150,4 duplicate(Restock#00)   Restock#28  80
+amatsu,273,212,4   duplicate(Restock#00)   Restock#39  80
+alberta,33,240,4   duplicate(Restock#00)   Restock#40  80
+
+//BG
+
+
+
+
Index: npc/scripts_custom.conf
===================================================================
--- npc/scripts_custom.conf (revision 104)
+++ npc/scripts_custom.conf (working copy)
@@ -197,10 +197,10 @@
 npc: npc/gro_custom/kafra.txt
 npc: npc/gro_custom/tooldealer.txt
 npc: npc/gro_custom/tower.txt
+npc: npc/gro_custom/restock.txt
 
 
 
-
 // WoE
 
 // Guild WoE time settings.
@@ -254,4 +254,4 @@
 npc: npc/gro_custom/guild2/schg_cas04.txt
 npc: npc/gro_custom/guild2/schg_cas05.txt
 // Guild Dungeon Entrances
-npc: npc/gro_custom/guild2/guild_dungeon.txt
\ No newline at end of file
+npc: npc/gro_custom/guild2/guild_dungeon.txt
 
 
Index: src/map/script.c
===================================================================
--- src/map/script.c    (revision 104)
+++ src/map/script.c    (working copy)
@@ -4217,6 +4217,7 @@
            sd->npc_menu -= menu_countoptions(text, sd->npc_menu, &menu);
            if( sd->npc_menu <= 0 )
                break;// entry found
+           pc_setregstr(sd, add_str("@options$"),text); //text option selected
        }
        pc_setreg(sd, add_str("@menu"), menu);
        script_pushint(st, menu);
@@ -5945,7 +5946,7 @@
 
        if( itemdb_isstackable2(id) )
        {
-           ARR_FIND(0,MAX_STORAGE,i,compare_item(&sd->status.storage.items[i],&it));
+           ARR_FIND(0,MAX_STORAGE,i,compare_item(&sd->status.storage.items[i],&it,0));
            if( i < MAX_STORAGE )
            { // Item on Storage
                script_pushint(st,amount + sd->status.storage.items[i].amount > MAX_AMOUNT ? 0 : 1);
 
 
+/*==========================================
+ * Countstorageitem,type,item{,charid} [Lighta]
+ * type : 0 inventory, 1 guildinventory
+ * item : itemid or itemname
+ *------------------------------------------*/
+BUILDIN_FUNC(countstorageitem)
+{
+   TBL_PC * sd = ((script_hasdata(st,11)) ? map_id2sd(script_getnum(st,11)) : script_rid2sd(st));
+    int i, type, count = 0;
+   struct item_data* item_data;
+   struct guild_storage *gstor;
+    struct storage_data *stor;
+    struct item tmp_it;
 
+    type = script_getnum(st,2);
+        
+   if(sd != NULL && (item_data = itemdb_exists(script_getnum(st,3))) != NULL ){
+            tmp_it.nameid = item_data->nameid;
+            tmp_it.identify = script_getnum(st,4);
+            tmp_it.refine = script_getnum(st,5);
+            tmp_it.attribute = script_getnum(st,6);             
+            tmp_it.card[0] = script_getnum(st,7);
+            tmp_it.card[1] = script_getnum(st,8);
+            tmp_it.card[2] = script_getnum(st,9);
+            tmp_it.card[3] = script_getnum(st,10);
+            
+            switch(type){
+                    case 0 :
+                            stor=&sd->status.storage;
+                            for(i = 0; i < MAX_STORAGE; i++) {
+                                    if( (&stor->items[i] != NULL)
+                                            && stor->items[i].amount > 0 
+                                            && compare_item(&stor->items[i],&tmp_it,1)
+                                    )
+                                    count += stor->items[i].amount;
+                            }
+                            script_pushint(st,count);
+                            break;
+                    case 1:
+                            if (sd->status.guild_id && (gstor=guild2storage2(sd->status.guild_id))) {
+                                for(i = 0; i < MAX_GUILD_STORAGE; i++) {
+                                        if( (&gstor->items[i] != NULL)
+                                                && gstor->items[i].amount > 0
+                                                && compare_item(&gstor->items[i],&tmp_it,1)
+                                        )
+                                        count += gstor->items[i].amount;
+                                }
+                                script_pushint(st,count);
+                            }
+                            break;
+                    default :
+                            ShowError("Invalid type specified in countstorageitem");
+                           script_pushint(st,-1);
+                            break;
+            }  
+        }
+        
+   return 0;
+}
+
+/*==========================================
+ * inv2stor,item_id,item_nb,attribute,refine,identify,c0,c1,c2,c3{,charid} [Lighta]
+ * interface pour pour la fonction de storage storage_storageadd
+ * transferant un item de l'inventaire au storage
+ *------------------------------------------*/
+BUILDIN_FUNC(inv2stor)
+{
+   TBL_PC * sd = ((script_hasdata(st,11)) ? map_id2sd(script_getnum(st,11)) : script_rid2sd(st));
+        int i,ok;
+   struct item_data* item_data;
+        struct item tmp_it;
+        int item_id = script_getnum(st,2);
+        int item_nb = script_getnum(st,3);
+        
+        nullpo_ret(sd);
+        
+        if( (item_data = itemdb_exists(item_id)) != NULL ){
+            tmp_it.nameid = item_data->nameid;
+            tmp_it.identify = script_getnum(st,4);
+            tmp_it.refine = script_getnum(st,5);
+            tmp_it.attribute = script_getnum(st,6);             
+            tmp_it.card[0] = script_getnum(st,7);
+            tmp_it.card[1] = script_getnum(st,8);
+            tmp_it.card[2] = script_getnum(st,9);
+            tmp_it.card[3] = script_getnum(st,10);
+            
+            ARR_FIND( 0, MAX_INVENTORY, i, ((&sd->status.inventory[i] != NULL)
+                    && compare_item(&sd->status.inventory[i],&tmp_it,1) ));
+            if( i < MAX_INVENTORY ){
+                ok=storage_storageadd(sd,i,item_nb);
+                script_pushint(st,ok);
+                storage_storageclose(sd);
+                return ok;
+            }
+        }
+        script_pushint(st,-1);
+        return 0;
+}
+
+/*==========================================
+ * inv2stor,item_id,item_nb,attribute,refine,identify,c0,c1,c2,c3{,charid} [Lighta]
+ * interface pour pour la fonction de storage_storageget
+ * transferant un item du storage a l'inventaire
+ *------------------------------------------*/
+BUILDIN_FUNC(stor2inv)
+{
+   TBL_PC * sd = ((script_hasdata(st,11)) ? map_id2sd(script_getnum(st,11)) : script_rid2sd(st));
+        int i,ok;
+   struct item_data* item_data;
+        struct item tmp_it;
+        int item_id = script_getnum(st,2);
+        int item_nb = script_getnum(st,3);
+        
+        nullpo_ret(sd);
+        
+        if( (item_data = itemdb_exists(item_id)) != NULL){
+            tmp_it.nameid = item_data->nameid;
+            tmp_it.identify = script_getnum(st,4);
+            tmp_it.refine = script_getnum(st,5);
+            tmp_it.attribute = script_getnum(st,6);        
+            tmp_it.card[0] = script_getnum(st,7);
+            tmp_it.card[1] = script_getnum(st,8);
+            tmp_it.card[2] = script_getnum(st,9);
+            tmp_it.card[3] = script_getnum(st,10);
+            ARR_FIND( 0, MAX_STORAGE, i, ((&sd->status.storage.items[i] != NULL)
+                    && compare_item(&sd->status.storage.items[i],&tmp_it,1) )
+                    );
+            if( i < MAX_STORAGE ){
+                ok=storage_storageget(sd,i,item_nb);
+                script_pushint(st,ok);
+                return ok;
+            }
+        }
+        script_pushint(st,-1);
+        return 0;
+}
+
+
+
 // declarations that were supposed to be exported from npc_chat.c
 #ifdef PCRE_SUPPORT
 BUILDIN_FUNC(defpattern);
@@ -18519,7 +18658,10 @@
    
    BUILDIN_DEF(checkweight2, "*"), // [Lighta] :)
    BUILDIN_DEF(checkweights, "rr"),
-
+   BUILDIN_DEF(countstorageitem,"iiiiiiiii?"),
+    BUILDIN_DEF(stor2inv,"iiiiiiiii?"),
+    BUILDIN_DEF(inv2stor,"iiiiiiiii?"),
+       
    BUILDIN_DEF(vending_add, "ii*"), //epoque then mrj
    BUILDIN_DEF(vending_remove, "i*"),
    BUILDIN_DEF(vending_open, "*"),
Index: src/map/storage.c
===================================================================
--- src/map/storage.c   (revision 104)
+++ src/map/storage.c   (working copy)
@@ -121,14 +121,19 @@
    clif_updatestorageamount(sd, sd->status.storage.storage_amount, MAX_STORAGE);
    return 0;
 }
-// helper function
-int compare_item(struct item *a, struct item *b)
+
+/* helper function
+ * checking if 2 item structure are identique
+ * flag :
+ *      1 = not checking expire_time
+ */
+int compare_item(struct item *a, struct item *b, short flag)
 {
    if( a->nameid == b->nameid &&
        a->identify == b->identify &&
        a->refine == b->refine &&
        a->attribute == b->attribute &&
-       a->expire_time == b->expire_time &&
+       (flag&1 || (a->expire_time == b->expire_time) ) )
    {
        int i;
@@ -439,7 +444,7 @@
    {
        for(i=0; i< MAX_MEMBER_STORAGE; ++i)
        {
-           if(compare_item(&mstor->items[i], item_data))
+           if(compare_item(&mstor->items[i], item_data,0))
            {
                if(mstor->items[i].amount+amount > MAX_AMOUNT)
                    return 1;
@@ -513,7 +518,7 @@
 
    if(itemdb_isstackable2(data)){ //Stackable
        for(i=0;i<MAX_GUILD_STORAGE;i++){
-           if(compare_item(&stor->items[i], item_data)) {
+           if(compare_item(&stor->items[i], item_data,0)) {
                if(stor->items[i].amount+amount > MAX_AMOUNT)
                    return 1;
                stor->items[i].amount+=amount;
@@ -640,7 +645,7 @@
    {//Stackable
        for( i = 0; i < MAX_STORAGE; i++ )
        {
-           if( compare_item(&stor->items[i], item_data) )
+           if( compare_item(&stor->items[i], item_data,0) )
            {// existing items found, stack them
                if( amount > MAX_AMOUNT - stor->items[i].amount )
                    return 1;
Index: src/map/storage.h
===================================================================
--- src/map/storage.h   (revision 104)
+++ src/map/storage.h   (working copy)
@@ -27,6 +27,7 @@
 void storage_storage_quit(struct map_session_data *sd, int flag);
 struct member_storage_data* member2storage(int member_id);
 struct guild_storage* guild2storage(int guild_id);
+struct guild_storage *guild2storage2(int guild_id);
 int member_storage_delete(int member_id);
 int guild_storage_delete(int guild_id);
 int storage_member_storageopen(struct map_session_data *sd);
@@ -54,7 +55,7 @@
 int storage_guild_storagesaved(int guild_id); //Ack from char server that guild store was saved.
 
 
-int compare_item(struct item *a, struct item *b);
+int compare_item(struct item *a, struct item *b, short flag);
 int storage_additem2(struct map_session_data *sd, struct item* item_data, int amount);
 
 #endif /* _STORAGE_H_ */
Viewed 1312 times, submitted by lighta.