Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - shop Emistry_Shop -1,512:100
- prontera,155,181,5 script Sample 757,{
- .@gmlevel = getgmlevel();
- mes "How can i help you ?";
- next;
- switch( select( "View Shop",
- ( .@gmlevel < .gm_level )?"":"[GM] Add Item",
- ( .@gmlevel < .gm_level )?"":"[GM] Delete Item",
- ( .@gmlevel < .gm_level )?"":"[GM] Change Currency" )){
- Case 1:
- if( $shop_size < 1 ){
- mes "No items for sales right now.";
- }else if( getarraysize( $shop_currency$ ) != 2 ){
- mes "Currency isnt selected.";
- }else{
- mes "Currency : "+$shop_currency$[0];
- npcshopitem "Emistry_Shop",512,100;
- npcshopdelitem "Emistry_Shop",512;
- .@i = 0;
- while( .@i < $shop_size ){
- npcshopadditem "Emistry_Shop",$shop_item[.@i],$shop_cost[.@i];
- .@i++;
- }
- deletearray @bought_nameid;
- deletearray @bought_quantity;
- callshop "Emistry_Shop",1;
- npcshopattach "Emistry_Shop";
- end;
- }
- break;
- Case 2:
- if( getarraysize( $shop_currency$ ) != 2 ){
- mes "Please edit the Currency first.";
- }else if( $shop_size >= .max_item ){
- mes "Only allow Max. of "+.max_item+" items in shop.";
- }else{
- mes "Enter Item ID :";
- do{
- input .@item,0,32767;
- if( !.@item ) close;
- .@i = 0;
- while( .@i < $shop_size ){
- if( $shop_item[.@i] == .@item ){
- message strcharinfo(0),"Cant add 2 same items.";
- .@item = 1;
- break;
- }
- .@i++;
- }
- }while( getitemname( .@item ) == "null" );
- mes "Enter Amount per purchase :";
- input .@amount,1,30000;
- mes "Enter Cost per purchase :";
- do{
- input .@cost$;
- .@cost = atoi( .@cost$ );
- }while( !.@cost );
- if( .@cost && .@amount ){
- next;
- mes "Item : "+getitemname( .@item );
- mes "Amount : "+.@amount;
- mes "Cost : "+.@cost+" x "+$shop_currency$[0];
- if( select( "Cancel","Confirm" ) == 2 ){
- $shop_item_name$[ $shop_size ] = getitemname( .@item );
- $shop_item[ $shop_size ] = .@item;
- $shop_amount[ $shop_size ] = .@amount;
- $shop_cost[ $shop_size ] = .@cost;
- $shop_size = getarraysize( $shop_item );
- }
- }else{
- mes "Cancelled.";
- }
- }
- break;
- Case 3:
- if( $shop_size < 1 ){
- mes "No items in the shop list.";
- }else{
- mes "Select an item to remove from shop list.";
- .@i = select( implode( $shop_item_name$,":" ) ) - 1;
- mes "Remove "+$shop_item_name$[.@i]+" from shop ?";
- if( select( "Cancel","Confirm" ) == 2 ){
- mes "Done";
- deletearray $shop_item_name$[.@i],1;
- deletearray $shop_item[.@i],1;
- deletearray $shop_amount[.@i],1;
- deletearray $shop_cost[.@i],1;
- $shop_size = getarraysize( $shop_item );
- }
- }
- break;
- Case 4:
- mes "Enter your shop Currency.";
- mes "^FF0000ItemID or Variables^000000.";
- input .@currency$;
- if( getitemname( atoi( .@currency$ ) ) != "null" ){
- .@currency_name$ = getitemname( atoi( .@currency$ ) );
- }else{
- mes "Enter a Name for Currency";
- input .@currency_name$;
- }
- next;
- mes "Your New Currency :";
- mes "Name : "+.@currency_name$;
- mes "Currency : "+.@currency$;
- if( select( "Cancel","Confirm" ) == 2 ){
- setarray $shop_currency$,.@currency_name$,.@currency$;
- }
- default: break;
- }
- close;
- OnInit:
- // Min. GM Level to access GM Menu
- .gm_level = 99;
- // Max Items in Shop
- .max_item = 30;
- end;
- OnBuyItem:
- if( !checkweight2( @bought_nameid,@bought_quantity ) ){
- mes "You will Overweight for that much of items.";
- }else{
- mes "You selected :";
- .@total_cost = .@x = .@y = 0;
- while( .@x < getarraysize( @bought_nameid ) ){
- mes "^FF0000"+@bought_quantity[.@x]+" x ^0000FF"+getitemname( @bought_nameid[.@x] )+"^000000";
- while( .@y < $shop_size ){
- if( @bought_nameid[.@x] == $shop_item[.@y] ){
- .@total_cost = .@total_cost + ( $shop_cost[.@y] * @bought_quantity[.@x] );
- break;
- }
- .@y++;
- }
- .@x++;
- }
- mes " ";
- mes "Total Cost : "+.@total_cost+" x "+$shop_currency$[0];
- next;
- if( select( "Buy","Cancel" ) == 1 ){
- .@item_currency = atoi( $shop_currency$[1] );
- if( getitemname( .@item_currency ) != "null" ){
- if( countitem( .@item_currency ) >= .@total_cost ){
- delitem .@item_currency,.@total_cost;
- }else{
- mes "Not enough items.";
- close;
- }
- }else{
- if( getd( $shop_currency$[1] ) >= .@total_cost ){
- setd( $shop_currency$[1] ),( getd( $shop_currency$[1] ) - .@total_cost );
- }else{
- mes "Not enough Currency";
- close;
- }
- }
- mes "DONE purchased "+getarraysize( @bought_nameid )+" Items using "+.@total_cost+" x "+$shop_currency$[0];
- for( .@i = 0; .@i < getarraysize( @bought_nameid ); .@i++ )
- getitem @bought_nameid[.@i],@bought_quantity[.@i];
- }
- }
- close;
- }
Advertisement
Add Comment
Please, Sign In to add comment