//Credits To Emistry for the Dynamic Shop Script //Modified by Mash - shop Emistry_Shop -1,512:100 prontera,155,181,5 script Sample 757,{ function ShopSettings; function ValidateCost; function CurrencyInfo; function ClearData; function ValueConvert; function ErrorNotice; function CcheckWeight; mes "[Telma]"; mes "Welcome, mighty warrior."; mes "Do you need supply for your battles?"; mes "I can exchange you a nice amount for your badges."; next; // Menu Selection select("Battleground Exclusive","WOE Exclusive"); ClearData(); ShopSettings( @menu ); npcshopitem "Emistry_Shop",512,100; npcshopdelitem "Emistry_Shop",512; for(set .@i,0; .@i < getarraysize( @ItemLists ); set .@i,.@i+1) npcshopadditem "Emistry_Shop",@ItemLists[.@i],@ItemCost[.@i]; mes "^00FF00____________________________^000000"; CurrencyInfo( @Currency$ ); mes "^00FF00____________________________^000000"; callshop "Emistry_Shop",1; npcshopattach "Emistry_Shop"; end; function ShopSettings { switch( getarg(0) ){ Case 1: set @sShop$, "BG"; // Currency [ Item ID / Variable Name ] set @Currency$,"7829"; // Item ID Lists setarray @ItemLists[0],504,505,678,7135; setarray @Amount[0],100,100,10,40; // Item Price setarray @ItemCost[0],1,1,1,1; break; Case 2: set @sShop$, "WOE"; // Currency [ Item ID / Variable Name ] set @Currency$,"7829"; // Item ID Lists setarray @ItemLists[0],7137,7138,662,12072; setarray @Amount[0],30,30,10,6; // Item Price setarray @ItemCost[0],4,4,4,8; break; default: ErrorNotice( "Invalid Menu Selection for Menu "+@menu+"." ); close; } if( @Currency$ == "" ) ErrorNotice( "Invalid Currency Setting in Menu "+@menu+" ." ); if( getarraysize( @ItemCost ) != getarraysize( @ItemLists ) || getarraysize( @ItemLists ) != getarraysize( @ItemCost ) || getarraysize( @Amount ) != getarraysize( @ItemCost ) || getarraysize( @Amount ) != getarraysize( @ItemLists ) ) ErrorNotice( "Missing or Extra Value of Item, Cost or Amount Settings in Menu "+@menu+" ." ); return; } function ErrorNotice { mes "^FF0000ERROR^000000 - "+getarg(0); mes "^00FF00____________________________^000000"; mes "Inform this Message to ^0000FFGame Staffs^000000 immediately !"; close; } function CurrencyInfo { if( getitemname( atoi( getarg(0) ) ) != "null" ){ mes "Item Currency : ^FF0000"+getitemname( atoi( getarg(0) ) )+"^000000"; mes "Available Amount : ^0000FF"+ValueConvert( countitem( atoi( getarg(0) ) ) )+"^000000"; }else if( getitemname( atoi( getarg(0) ) ) == "null" ){ mes "Variable Currency : ^FF0000"+getarg(0)+"^000000"; mes "Available Amount : ^0000FF"+ValueConvert( getd( getarg(0) ) )+"^000000"; } return; } function ValidateCost { if( getitemname( atoi( getarg(0) ) ) != "null" ){ if( countitem( atoi( getarg(0) ) ) < getarg(1) ) return 1; }else{ if( getd( getarg(0) ) < getarg(1) ) return 1; } return 0; } function ClearData { set @sShop$, ""; set @Currency$,""; set @TotalCost,0; deletearray @bought_nameid[0],getarraysize( @bought_nameid ); deletearray @bought_quantity[0],getarraysize( @bought_quantity ); deletearray @ItemLists[0],getarraysize( @ItemLists ); deletearray @ItemCost[0],getarraysize( @ItemCost ); deletearray @Amount[0],getarraysize( @Amount ); deletearray @exAmount[0],getarraysize( @exAmount ); deletearray @itemlistid[0],getarraysize( @itemlistid ); deletearray @itemlistcount[0],getarraysize( @itemlistcount ); return; } function ValueConvert { set .@num, atoi(""+getarg(0)); if ( .@num == 0 || .@num >= 2147483647 ) return getarg(0); set .@l, getstrlen(""+.@num); for ( set .@i,0; .@i < .@l; set .@i, .@i + 1 ) { set .@num$, .@num % pow(10,.@i+1) / pow(10,.@i) + .@num$; if ( (.@i+1) % 3 == 0 && .@i+1 != .@l ) set .@num$, ","+ .@num$; } return .@num$; } function CcheckWeight { switch( getarg(1,-1) ) { case -1: for ( set .@size, getarraysize(getarg(0)); .@i<.@size; set .@i, .@i+1 ) set .@weight, .@weight + getiteminfo( getelementofarray( getarg(0), .@i ), 6 ); break; case -2: for ( set .@size, getarraysize(getarg(0)); .@i<.@size; set .@i, .@i+2 ) set .@weight, .@weight + getiteminfo( getelementofarray( getarg(0), .@i ), 6 ) * getelementofarray( getarg(0), .@i+1 ) ; break; default: for ( set .@size, getarraysize(getarg(0)); .@i<.@size; set .@i, .@i+1 ) set .@weight, .@weight + getiteminfo( getelementofarray( getarg(0), .@i ), 6 ) * getelementofarray( getarg(1), .@i ) ; break; } return .@weight + Weight < MaxWeight; } OnBuyItem: ShopSettings( @menu ); for(set @i,0; @i < getarraysize( @bought_nameid ); set @i,@i+1) for(set @j,0; @j < getarraysize( @ItemLists ); set @j,@j+1) if( @ItemLists[@j] == @bought_nameid[@i] ) { set @TotalCost,@TotalCost + ( @ItemCost[@j] * @bought_quantity[@i] ); set @exAmount[@i],@Amount[@j]; } mes "^FF0000 BILLING LIST^000000"; mes "^00FF00____________________________^000000"; for( set @i,0; @i < getarraysize( @bought_nameid ); set @i,@i+1 ){ mes "^FF0000"+@bought_quantity[@i]+" x ^ff329e("+@exAmount[@i]+") ^0000FF"+getitemname( @bought_nameid[@i] )+"^000000"; set @itemlistid[@i],@bought_nameid[@i]; set @itemlistcount[@i],@bought_quantity[@i]*@exAmount[@i]; } mes "^00FF00____________________________^000000"; if( getitemname( atoi( @Currency$ ) ) != "null" ) mes "Total Cost : ^0000FF"+ValueConvert( @TotalCost )+" x "+getitemname( atoi( @Currency$ ) )+"^000000"; else if( getitemname( atoi( @Currency$ ) ) == "null" ){ mes "Total Cost : ^0000FF"+ValueConvert( @TotalCost )+" "+@Currency$+"^000000"; } mes "^00FF00____________________________^000000"; if( ValidateCost( @Currency$,@TotalCost ) ){ if( getitemname( atoi( @Currency$ ) ) != "null" ) mes "[ ^FF0000X^000000 ] Insufficient ^0000FF"+getitemname( atoi( @Currency$ ) )+"^000000"; else{ mes "[ ^FF0000X^000000 ] Insufficient ^0000FF"+@Currency$+"^000000"; } }else{ switch(select(" ~ ^0055FFPurchase in Inventory^000000: ~ ^0055FFPurchase in Storage^000000: ~ ^777777Cancel^000000")) { case 1: if ( CcheckWeight( @itemlistid, @itemlistcount ) ) { delitem atoi( @Currency$ ),@TotalCost; for(set @i,0; @i < getarraysize( @bought_nameid ); set @i,@i+1) { if (@sShop$ == "BG") { getitem2 @bought_nameid[@i],@bought_quantity[@i]*@exAmount[@i],1,0,0,254,0,getbattleflag("bg_reserved_char_id")&0xffff,(getbattleflag("bg_reserved_char_id")>>16)&0xffff; } else { getitem2 @bought_nameid[@i],@bought_quantity[@i]*@exAmount[@i],1,0,0,254,0,getbattleflag("woe_reserved_char_id")&0xffff,(getbattleflag("woe_reserved_char_id")>>16)&0xffff; } } specialeffect2 699; mes "Thank you for shopping."; } else{ next; mes "[Telma]"; mes "It's seen you can't carry the stuff you want to buy."; mes "Go and store some items on your Kafra Storage."; } close; case 2: for(set @j,0; @j < getarraysize( @bought_nameid ); set @j,@j+1) { if (@sShop$ == "BG") { if( checkspace(@bought_nameid[@j],@bought_quantity[@j]*@exAmount[@j],1,0,0,254,0,getbattleflag("bg_reserved_char_id")&0xffff,(getbattleflag("bg_reserved_char_id")>>16)&0xffff) == 0 ) { mes "It's seen your storage cannot accept more items."; mes "Go to your store and check the free space."; close; } } else { if( checkspace(@bought_nameid[@j],@bought_quantity[@j]*@exAmount[@j],1,0,0,254,0,getbattleflag("woe_reserved_char_id")&0xffff,(getbattleflag("woe_reserved_char_id")>>16)&0xffff) == 0 ) { mes "It's seen your storage cannot accept more items."; mes "Go to your store and check the free space."; close; } } } delitem atoi( @Currency$ ),@TotalCost; for(set @i,0; @i < getarraysize( @bought_nameid ); set @i,@i+1) { if (@sShop$ == "BG") { storeitem2 @bought_nameid[@i],@bought_quantity[@i]*@exAmount[@i],1,0,0,254,0,getbattleflag("bg_reserved_char_id")&0xffff,(getbattleflag("bg_reserved_char_id")>>16)&0xffff; } else { storeitem2 @bought_nameid[@i],@bought_quantity[@i]*@exAmount[@i],1,0,0,254,0,getbattleflag("woe_reserved_char_id")&0xffff,(getbattleflag("woe_reserved_char_id")>>16)&0xffff; } } specialeffect2 699; mes "Thank you for shopping."; close; case 3: close; } } ClearData(); close; }