Untitled

By Gruff Peafowl, 1 Month ago, written in php.
  1. -       shop    dyn_shop1       -1,501:50
  2.  
  3. prontera,181,200,4      script  Dynamic Shop    123,{
  4. callshop "dyn_shop1",0;
  5. npcshopattach "dyn_shop1";
  6.  
  7. OnSellItem:
  8. for(set @i, 0; @i < getarraysize(@sold_nameid); set @i, @i + 1){
  9.         if(countitem(@sold_nameid[@i]) < @sold_quantity[@i] && @sold_quantity[@i] <= 0){
  10.                 mes "omgh4x!";
  11.                 close;
  12.         }
  13.         if(@sold_nameid[@i] == 501){
  14.                 set $@rpotsleft, $@rpotsleft + @sold_quantity[@i];
  15.                 set Zeny, Zeny + @sold_quantity[@i]*20;
  16.                 delitem 501, @sold_quantity[@i];
  17.         } else {
  18.                 if(@sold_nameid[@i] == 502){
  19.                         set $@opotsleft, $@opotsleft + @sold_quantity[@i];
  20.                         set Zeny, Zeny + @sold_quantity[@i]*100;
  21.                         delitem 502, @sold_quantity[@i];
  22.                 } else {
  23.                         mes "Sorry, I don't need your items.";
  24.                 }
  25.         }
  26. }
  27. deletearray @sold_quantity, getarraysize(@sold_quantity);
  28. deletearray @sold_nameid, getarraysize(@sold_nameid);
  29. mes "Deal completed.";
  30. close;
  31.  
  32. OnBuyItem:
  33. for(set @i, 0; @i < getarraysize(@bought_nameid); set @i, @i + 1){
  34.         if(@bought_quantity[@i] <= 0){
  35.                 mes "omgh4x!";
  36.                 end;
  37.         }
  38.         if(@bought_nameid[@i] == 501){
  39.                 if(@bought_quantity[@i] > $@rpotsleft){
  40.                         if($@rpotsleft > 0){
  41.                                 set @bought_quantity[@i], $@rpotsleft;
  42.                         } else {
  43.                                 mes "We are out of red potions!";
  44.                                 close;
  45.                         }
  46.                 }
  47.                 if(Zeny >= 40*@bought_quantity[@i]){
  48.                         set Zeny, Zeny - 40*@bought_quantity[@i];
  49.                         getitem 501, @bought_quantity[@i];
  50.                         set $@rpotsleft, $@rpotsleft - @bought_quantity[@i];
  51.                 } else {
  52.                         mes "You have insufficient cash.";
  53.                         close;
  54.                 }
  55.         } else {
  56.                 if(@bought_quantity[@i] > $@opotsleft){
  57.                         if($@opotsleft > 0){
  58.                                 set @bought_quantity[@i], $@opotsleft;
  59.                         } else {
  60.                                 mes "We are out of orange potions!";
  61.                                 close;
  62.                         }
  63.                 }
  64.                 if(Zeny >= 200*@bought_quantity[@i]){
  65.                         set Zeny, Zeny - 200*@bought_quantity[@i];
  66.                         getitem 502, @bought_quantity[@i];
  67.                         set $@opotsleft, $@opotsleft - @bought_quantity[@i];
  68.                 } else {
  69.                         mes "You have insufficient cash.";
  70.                         close;
  71.                 }
  72.         }
  73. }
  74. deletearray @bought_quantity, getarraysize(@bought_quantity);
  75. deletearray @bought_nameid, getarraysize(@bought_nameid);
  76. mes "Trade done.";
  77. close;
  78.  
  79. OnInit:
  80. npcshopitem "dyn_shop1", 501,40,502,200;
  81. set $@rpotsleft, 10;
  82. set $@opotsleft, 10;
  83. }