Advertisement
Guest User

Exploit-able Vendor script ?

a guest
Jul 22nd, 2014
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.04 KB | None | 0 0
  1. //===== rAthena Script ==========================================================
  2. //= Custom Shop
  3. //===== By: =====================================================================
  4. //= Emistry
  5. //===== Current Version: ========================================================
  6. //= 2.0
  7. //===== Compatible With: ========================================================
  8. //= rAthena
  9. //===== Additional Comments: ====================================================
  10. //= 1.0 Initial Script
  11. //= 2.0 Optimized. Cleaned script. Added Currency Trader [Boom]
  12. //===============================================================================
  13. //Shop Currency can be either ItemID or Variable Name, but must write within Quotation Marks ( "" )
  14. //Zeny , #CASHPOINTS , #KAFRAPOINTS , CustomVariable , #CustomVariable
  15.  
  16.  
  17. - shop cshop1 -1,512:100
  18.  
  19. prontera,150,165,2 script Shop 564,{
  20.  
  21. set .npcname$, "Premium item dealer";
  22. function ShopSettings;
  23. function ValidateCost;
  24. function CurrencyInfo;
  25. function ClearData;
  26. function ValueConvert;
  27. function ErrorNotice;
  28.  
  29. // Menu Selection
  30. select("Upper Headgears","Middle Headgears","Lower Headgears");
  31.  
  32. ClearData();
  33. ShopSettings( @menu );
  34.  
  35.  
  36. npcshopitem "cshop1",512,100;
  37. npcshopdelitem "cshop1",512;
  38.  
  39. for(set .@i,0; .@i < getarraysize( @ItemLists ); set .@i,.@i+1)
  40. npcshopadditem "cshop1",@ItemLists[.@i],@ItemCost[.@i];
  41.  
  42. mes "ok, shop now !";
  43. mes "^00FF00----------------------------^000000";
  44. CurrencyInfo( @Currency$ );
  45. mes "^00FF00----------------------------^000000";
  46. close2;
  47. npcshopattach "cshop1";
  48. callshop "cshop1",1;
  49. end;
  50.  
  51. function ShopSettings
  52. {
  53. switch( getarg(0) ){
  54.  
  55. case 1:
  56. // Currency [ Item ID / Variable Name ]
  57. set @Currency$,"674";
  58. // Item ID Lists
  59. setarray @ItemLists[0],5105,5106,5407,5406,5011;
  60. // Item Price
  61. setarray @ItemCost[0],100,100,100,100,100;
  62. break;
  63. end;
  64. case 2:
  65. // Currency [ Item ID / Variable Name ]
  66. set @Currency$,"674";
  67. // Item ID Lists
  68. setarray @ItemLists[0],5788,5794,5786,5389;
  69. // Item Price
  70. setarray @ItemCost[0],100,100,100,100;
  71. break;
  72. end;
  73. case 3:
  74. // Currency [ Item ID / Variable Name ]
  75. set @Currency$,"674";
  76. // Item ID Lists
  77. setarray @ItemLists[0],5521,5054,5110,2240;
  78. // Item Price
  79. setarray @ItemCost[0],100,100,100,100;
  80. break;
  81. end;
  82.  
  83. default:
  84. ErrorNotice( "Invalid Menu Selection for Menu "+@menu+"." );
  85. close;
  86. }
  87.  
  88. if( @Currency$ == "" )
  89. ErrorNotice( "Invalid Currency Setting in Menu "+@menu+" ." );
  90. if( getarraysize( @ItemCost ) != getarraysize( @ItemLists ) || getarraysize( @ItemLists ) != getarraysize( @ItemCost ) )
  91. ErrorNotice( "Missing or Extra Value of Item or Cost Settings in Menu "+@menu+" ." );
  92. return;
  93. }
  94.  
  95. function ErrorNotice
  96. {
  97. mes "^FF0000ERROR^000000 - "+getarg(0);
  98. mes "^00FF00----------------------------^000000";
  99. mes "Please inform the ^0000FFGame Masters^000000 immediately !";
  100. close;
  101. }
  102.  
  103. function CurrencyInfo
  104. {
  105. if( getitemname( atoi( getarg(0) ) ) != "null" ){
  106. mes "Item Currency : ^FF0000"+getitemname( atoi( getarg(0) ) )+"^000000";
  107. mes "Available Amount : ^0000FF"+ValueConvert( countitem( atoi( getarg(0) ) ) )+"^000000";
  108. }else if( getitemname( atoi( getarg(0) ) ) == "null" ){
  109. mes "Variable Currency : ^FF0000"+getarg(0)+"^000000";
  110. mes "Available Amount : ^0000FF"+ValueConvert( getd( getarg(0) ) )+"^000000";
  111. }
  112. return;
  113. }
  114.  
  115. function ValidateCost
  116. {
  117. if( getitemname( atoi( getarg(0) ) ) != "null" ){
  118. if( countitem( atoi( getarg(0) ) ) < getarg(1) ) return 1;
  119. }else{
  120. if( getd( getarg(0) ) < getarg(1) ) return 1;
  121. }
  122. return 0;
  123. }
  124.  
  125. function ClearData
  126. {
  127. set @Currency$,"";
  128. set @TotalCost,0;
  129. deletearray @bought_nameid[0],getarraysize( @bought_nameid );
  130. deletearray @bought_quantity[0],getarraysize( @bought_quantity );
  131. deletearray @ItemLists[0],getarraysize( @ItemLists );
  132. deletearray @ItemCost[0],getarraysize( @ItemCost );
  133. return;
  134. }
  135.  
  136. function ValueConvert
  137. {
  138. set .@num, atoi(""+getarg(0));
  139. if ( .@num == 0 || .@num >= 2147483647 ) return getarg(0);
  140. set .@l, getstrlen(""+.@num);
  141. for ( set .@i,0; .@i < .@l; set .@i, .@i + 1 ) {
  142. set .@num$, .@num % pow(10,.@i+1) / pow(10,.@i) + .@num$;
  143. if ( (.@i+1) % 3 == 0 && .@i+1 != .@l ) set .@num$, ","+ .@num$;
  144. }
  145. return .@num$;
  146. }
  147.  
  148. OnBuyItem:
  149. ShopSettings( @menu );
  150. for(set @i,0; @i < getarraysize( @bought_nameid ); set @i,@i+1)
  151. for(set @j,0; @j < getarraysize( @ItemLists ); set @j,@j+1)
  152. if( @ItemLists[@j] == @bought_nameid[@i] )
  153. set @TotalCost,@TotalCost + ( @ItemCost[@j] * @bought_quantity[@i] );
  154. mes "^FF0000[Cash Shop Cart]^000000";
  155. mes "Cart Contents:^000000";
  156. for( set @i,0; @i < getarraysize( @bought_nameid ); set @i,@i+1 )
  157. mes "^FF0000"+@bought_quantity[@i]+" x ^0000FF"+getitemname( @bought_nameid[@i] )+"^000000";
  158. mes "";
  159.  
  160. if( getitemname( atoi( @Currency$ ) ) != "null" )
  161. mes "Cost : ^0000FF"+ValueConvert( @TotalCost )+" x "+getitemname( atoi( @Currency$ ) )+"^000000";
  162. else if( getitemname( atoi( @Currency$ ) ) == "null" ){
  163. mes "Cost : ^0000FF"+ValueConvert( @TotalCost )+" "+@Currency$+"^000000";
  164. }
  165.  
  166. if( ValidateCost( @Currency$,@TotalCost ) ){
  167. if( getitemname( atoi( @Currency$ ) ) != "null" )
  168. mes "[ ^FF0000X^000000 ] Insufficient ^0000FF"+getitemname( atoi( @Currency$ ) )+"^000000";
  169. else{
  170. mes "[ ^FF0000X^000000 ] Insufficient ^0000FF"+@Currency$+"^000000";
  171. }
  172. }else{
  173. if( select( "^0000FFPurchase^000000:Cancel" ) == 1 ){
  174. if( getitemname( atoi( @Currency$ ) ) != "null" )
  175. delitem atoi( @Currency$ ),@TotalCost;
  176. else{
  177. set getd( @Currency$ ),getd( @Currency$ ) - @TotalCost;
  178. }
  179. for(set @i,0; @i < getarraysize( @bought_nameid ); set @i,@i+1)
  180. getitem @bought_nameid[@i],@bought_quantity[@i];
  181. //message strcharinfo(0),"Received "+getarraysize( @bought_nameid )+" Items.";
  182. message strcharinfo(0),"[Cash Shop] Transaction completed.";
  183. mes "thx!";
  184. }
  185. }
  186. ClearData();
  187. close;
  188. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement