office,136,28,4	script	Item Mall	4_MAL_KAFRA,{

	mes "[ ^ff0000Item Mall^000000 ]";
	mes "You currently have:";
	mes "Cash Points: ^FF0000"+#CASHPOINTS+"^000000";
	next;
	switch(select("^FF0000Shop Now^000000","Premium Services","Claim Donation")) {
	case 1:
		callfunc "ishop";
		close(); 
	case 2:
	
		mes "[ ^ff0000Item Mall^000000 ]";
		mes "So, Which ^FF0000Premium Services^000000 you would like to look at it";
			switch(select(
			 "- Change Guild Leader:"+
	 		 "- ^777777Close^000000"
			)) {
			next;	
			case 1:	// Change GM 24USD = 1250
				if (getcharid(0) != getguildmasterid(getcharid(2))) {
					mes "[ ^ff0000Item Mall^000000 ]";
					mes "You are not a guild master.";
					close();
				}
				set .@gldid,getcharid(2);
				mes "[ ^ff0000Item Mall^000000 ]";
				query_sql("SELECT `name` , `master` , `guild_lv` FROM `guild` WHERE `guild_id` = '"+.@gldid+"'",.@gname$,.@char$,.@glvl);
				mes "^FF0000Change Guild Master^000000";
				mes "This service is FREE until 7/14";
				//mes "This service will cost you";
				//mes "^FF0000 20,000^000000 Cash Points";

				mes "Information:";
				mes "Guild Name: ^ff0000"+.@gname$+"^000000";
				mes "Guild Level: ^ff0000"+.@glvl+"^000000";
				mes "Guild Master: ^ff0000"+.@char$+"^000000";
				mes "Do you wish to continue changing guild master?";
				next;
				if( select("No", "Yes") == 1 )
					close();
				/*
				if(#CASHPOINTS < 1250 ) {
					mes "[ ^ff0000Item Mall^000000 ]";
					mes "Im sorry, but you don't have enough ^FF0000Cash Points^000000 to process this request.";
					close();
				}
				*/
				mes "[ ^ff0000Item Mall^000000 ]";
				mes "^FF0000NOTE^000000:";
				mes "^FF0000-^000000 Double check the spelling.";
				mes "^FF0000-^000000 The character name you";
				mes "  will be providing should";
				mes "  be the NEW guild leader.";
				mes "^FF0000-^000000 New Guild leader should be online.";
				mes "Enter the ^FF0000new^000000 guild leader's name.";
				input .@cgl$;
				next;
				mes "[ ^ff0000Item Mall^000000 ]";
				mes "Please ^FF0000re-enter^000000 the name again for confirmation.";
				input .@cgl2$;
				next;

				if (.@cgl$ != .@cgl2$) {
					mes "[ ^ff0000Item Mall^000000 ]";
					mes "The names you entered doesn't match.";
					close();
				}
				.@check = query_sql("SELECT `account_id` FROM `char` WHERE `name`='"+escape_sql(.@cgl$)+"'",.@acid);
				if (!.@check){
					mes "[ ^ff0000Item Mall^000000 ]";
					mes "Character [ ^FF0000"+.@cgl$+"^000000 ] doesn't exist!";
					close();
				}
				if (.@cgl$ == .@char$) {
					mes "[ ^ff0000Item Mall^000000 ]";
					mes "Character [ ^FF0000"+.@cgl$+"^000000 ] is already the leader of [ ^FF0000"+.@gname$+"^000000 ] Guild.";
					close();
				}
				if (!isloggedin(getcharid(3,.@cgl$), getcharid(0,.@cgl$))){
					mes "[ ^ff0000Item Mall^000000 ]";
					mes "Character [ ^FF0000"+.@cgl$+"^000000 ] must be online to proceed!";
					close();
				}
				if (getcharid(2,.@cgl$) != .@gldid){
					mes "[ ^ff0000Item Mall^000000 ]";
					mes "Character [ ^FF0000"+.@cgl$+"^000000 ] is not a member of [ ^FF0000"+.@gname$+"^000000 ] Guild.";
					close();
				}

				mes "[ ^ff0000Item Mall^000000 ]";
				mes "Please confirm the following details before we proceed,";
				mes "Current Leader: ^FF0000"+strcharinfo(PC_NAME)+"^000000";
				mes "New Leader: ^FF0000"+.@cgl$+"^000000";
				mes "Would you like to proceed?";
				next;
				if (select("Close","^FF0000Confirmed^000000!") != 1) {
					close2;
					if (.gcdone == .@gldid){
						if ( .delay > gettimetick(2) ){
							message strcharinfo(0), "Transfer failed!";
							mes "[ ^ff0000Item Mall^000000 ]";
							mes "You must wait [^FF0000"+(.delay - gettimetick(2))+"^000000] seconds,";
							mes .@char$+"'s guild has been currently";
							mes "modified and changed their";
							mes "guild leader authority.";
							close();
						}
					}

					//#CASHPOINTS -= 1250;
					//callfunc("F_CashLog",#CASHPOINTS,1250,"Change Guild Leader");
					
					message strcharinfo(0), "You have succesfully transferred the guild!";
					announce strcharinfo(0)+" : The [ "+.@gname$+" ] Guild previously owned by "+.@char$+" succesfully transferred its ownership to "+.@cgl$+"!",bc_all,0xe57c00;
					guildchangegm(.@gldid,.@cgl$);
					.gcdone = .@gldid;
					if (.d)
					.delay = gettimetick(2) + .d;
					sleep2 1000;
					if (isloggedin(getcharid(3,.@cgl$), getcharid(0,.@cgl$))){
						atcommand "@kick "+.@cgl$;
					}
					if (isloggedin(getcharid(3,.@char$), getcharid(0,.@char$))){
						atcommand "@kick "+.@char$;
					}
					end;
				}

				close();

			default:

				close();	
		}
	case 3:
		.@balance = 0;
		query_sql("SELECT `balance` FROM `cp_credits` WHERE `account_id` = '"+getcharid(3)+"'",.@balance);
		mes "[ ^ff0000Item Mall^000000 ]";
		if (.@balance < 1) { mes "^FF0000You have no pending donation credits available for claim.^000000";cutin "",255; close; }
		.@cv = .@balance/100;
		.@cr = .@balance - (.@cv * 100);
		mes "^0000ffYou have:^000000 ";
		mes "Pending Donation Credits: ^FF0000"+F_InsertComma(.@balance)+"^000000";
		mes "You will receive: ";
		mes "   ^ff0000"+.@cv+"^000000 Cash Voucher";
		mes "   ^ff0000"+.@cr+"^000000 Cash Points";
		mes "^FF0000Do you want to claim now?^000000";
		next;				
		switch(select("No","Yes")) {
			case 1: 	
				cutin "",255; close;
			case 2:				
				#CASHPOINTS += .@cr;
				dispbottom "You received "+.@cr+" Cash Points."; 
				getitem 7179,.@cv;
				callfunc("F_CashLog",#CASHPOINTS,.@cr,"Redeemed Donation");
				query_sql "update `cp_credits` set `balance` = `balance` - "+ (.@balance) +" where `account_id` = '"+getcharid(3)+"'";
				mes "Thank you for using this service.";
				cutin "",255; close;
			default: cutin "",255; close;
		}
		close();
	default:
		close();
	}
}

// Script Core
//============================================================
-	script	i_shop	FAKE_NPC,{
function Add; function Chk; function Slot; function A_An;
OnInit:
	
	freeloop(1);

// -----------------------------------------------------------
//  Basic shop settings.
// -----------------------------------------------------------

	set .Announce,0;	// Announce quest completion? (1: yes / 0: no)
	set .ShowSlot,1;	// Show item slots? (2: all equipment / 1: if slots > 0 / 0: never)
	set .ShowID,1;  	// Show item IDs? (1: yes / 0: no)
	set .ShowZeny,1;	// Show Zeny cost, if any? (1: yes / 0: no)
	set .MaxStack,1;	// Max number of quest items purchased at one time.

// -----------------------------------------------------------
//  Points variable -- optional quest requirement.
//	setarray .points$[0],"<variable name>","<display name>";
// -----------------------------------------------------------

	setarray .points$[0],"#CASHPOINTS","Cash Points";

// -----------------------------------------------------------
//  Shop IDs -- to add shops, copy dummy data at bottom of file.
//	setarray .iShops$[1],"<Shop 1>","<Shop 2>"{,...};
// -----------------------------------------------------------

	setarray .iShops$[1],"Usables","Functional","Regular Headgear","Accessories","Special Costumes","Costume Wings";

// -----------------------------------------------------------
//  Quest items -- do NOT use a reward item more than once!
//	Add(<shop ID>,<reward ID>,<reward amount>,
//	    <Zeny cost>,<point cost>,
//	    <required item ID>,<required item amount>{,...});
// -----------------------------------------------------------


//Add(1,12215,1,0,2); //LV10 Blessing Scroll
//Add(1,12216,1,0,2); //LV10 Agil Scroll
//Add(1,12217,1,0,2); //LV5 Aspersio Scroll
//Add(1,12218,1,0,7); //LV5 Assumptio Scroll
//Add(1,14588,1,0,5); //Party Blessing 10 Scroll
//Add(1,14589,1,0,5); //Party Increase Agi 10 Scroll

Add(1,12913,1,0,20); //Blessing 10 Scroll Box
Add(1,12914,1,0,20); //Increase AGI 10 scroll Box
Add(1,12915,1,0,30); //Aspersio_5_Scroll_Box
Add(1,12916,1,0,30); //Assumptio 5 Scroll Box

Add(1,13912,1,0,45); //Party Blessing 10 Scroll Box
Add(1,13913,1,0,45); //Party Increase Agi 10 Scroll Box

Add(1,14003,1,0,2); //Elite Siege Box
Add(1,14542,1,0,7); //Big Defense Potion
Add(1,14544,1,0,7); //Big Magic Defense Potion
Add(1,14536,1,0,5); //Abrasive
Add(1,12202,1,0,10); //Steamed Tongue
Add(1,12203,1,0,10); //Steamed Scorpion
Add(1,12204,1,0,10); //Dragon Breath Cocktail
Add(1,12205,1,0,10); //Hwergelmir's Tonic
Add(1,12206,1,0,10); //Cooked Nine Tail's Tails
Add(1,12207,1,0,10); //Stew Of Immortality
Add(1,12210,1,0,25); //Bubble Gum
Add(1,14533,1,0,15); //Field Manual 100%
Add(1,14592,1,0,15); //JOB Battle Manual
Add(1,12209,1,0,2); //Life Insurance
Add(1,14537,1,0,4); //Regeneration Potion
Add(1,13749,1,0,63); //Big Defense Potion 10 Box
Add(1,14091,1,0,63); //Big Magic Defense Potion 10 Box
Add(1,13720,1,0,36); //Regeneration 10 Box
Add(1,14159,1,0,90); //Steamed Tongue Box
Add(1,14160,1,0,90); //Steamed Scorpion Box
Add(1,14161,1,0,90); //Dragon Breath Cocktail Box
Add(1,14162,1,0,90); //Hwergelmir's Tonic Box
Add(1,14163,1,0,90); //Nine Tail Dish Box
Add(1,14164,1,0,90); //Stew Of Immortality Box
Add(1,12902,1,0,225); //Bubble Gum Box
Add(1,13717,1,0,20); //Abrasive 5 Box
Add(1,12710,1,0,15); //Guyak Pudding

Add(2,30368,1,0,15); //Red Voucher
Add(2,12790,1,0,300); //Name Change Coupon
Add(2,12211,1,0,15); //Kafra Card
Add(2,12909,1,0,135); //Kafra Card Box
Add(2,6320,1,0,578); //Premium Reset Stone
Add(2,12213,1,0,578); //Neuralizer
Add(2,7619,1,0,40); //Enriched Elunium
Add(2,12920,1,0,360); //Enriched Elunium Box
Add(2,7620,1,0,37); //Enriched Oridecon
Add(2,12921,1,0,333); //Enriched Oridecon Box
Add(2,7776,1,0,25); //Gym Pass
Add(2,13710,1,0,225); //Gym Pass Box
Add(2,7621,1,0,8); //Token Of Siegfried
Add(2,12922,1,0,72); //Token of Siegfried Box
Add(2,12622,1,0,350); //Halter Lead

Add(2,30404,1,0,860); //Elephant Pet
Add(2,30405,1,0,860); //Gorilla Pet
Add(2,30406,1,0,860); //Lion Pet
Add(2,30407,1,0,860); //Rhino Pet

Add(3,18813,1,0,490); //New Wave Sunglasses
Add(3,18563,1,0,580); //Heart Wing Headband
Add(3,18842,1,0,580); //Hat Of Girl
Add(3,5361,1,0,490); //Gangster Scarf
Add(3,5597,1,0,490); //Bubble Gum In Mouth
Add(3,5594,1,0,270); //Donut In Mouth
Add(3,5377,1,0,570); //Gentleman's Pipe
Add(3,5463,1,0,390); //Rainbow Scarf
Add(3,5462,1,0,370); //Spiked Scarf
Add(3,5775,1,0,270); //Choco Donut In Mouth
Add(3,5574,1,0,350); //Well-Chewed Pencil
Add(3,5376,1,0,510); //Flying Evil Wing
Add(3,5431,1,0,510); //Chicken Hat
Add(3,5137,1,0,490); //Alice Doll
Add(3,5766,1,0,263); //Amistr Cap
Add(3,18613,1,0,263); //Black Musang Hat
Add(3,5254,1,0,350); //Deviling Hat
Add(3,5211,1,0,263); //Dress Hat
Add(3,5533,1,0,263); //Emperor Wreath
Add(3,5230,1,0,263); //Gray Drooping Cat
Add(3,5396,1,0,263); //Jasper Crest
Add(3,5372,1,0,263); //Koneko Hat
Add(3,5311,1,0,263); //Large Hisbiscus
Add(3,5393,1,0,263); //Love Valentine's Hat
Add(3,18597,1,0,263); //Mercury Riser
Add(3,5815,1,0,263); //Purple Cowboy Hat
Add(3,5293,1,0,263); //Ramen Hat
Add(3,5227,1,0,263); //Red Deviruchi Hat
Add(3,5508,1,0,263); //Shark Hat
Add(3,5388,1,0,350); //Snake Head Hat
Add(3,5342,1,0,350); //Sorin Doll Hat
Add(3,5770,1,0,350); //Splash Hat
Add(3,5379,1,0,263); //Tam
Add(3,18612,1,0,263); //White Musang Hat
Add(3,5464,1,0,263); //Zaha Doll Hat
Add(3,5660,1,0,263); //Gryphon Hat
Add(3,5319,1,0,263); //Hello Mother Hat
Add(3,5658,1,0,300); //Imp Hat
Add(3,5426,1,0,263); //Karada Meguricha Hat
Add(3,5418,1,0,263); //Legionnaire Hat
Add(3,5442,1,0,263); //Necktie
Add(3,5665,1,0,263); //Shaman Hat
Add(3,5509,1,0,263); //Sting hat
Add(3,5526,1,0,263); //Tanigumi Girl Doll
Add(3,5611,1,0,263); //Turtle_Hat
Add(3,18656,1,0,263); //Witch's Pumpkin Hat
Add(3,5819,1,0,263); //Carnival Circlet
Add(3,18600,1,0,350); //Cat Ear Beret
Add(3,5518,1,0,580); //Gigantic Majestic Goat
Add(3,5325,1,0,480); //Robo Eye
Add(3,5389,1,0,420); //Angel Spirit
Add(3,5401,1,0,330); //Black Frame Glasses
Add(3,5800,1,0,480); //Blush of Groom
Add(3,5135,1,0,390); //Cyclop's Eye
Add(3,5104,1,0,300); //Dark Blinder
Add(3,5315,1,0,300); //Observer
Add(3,5288,1,0,330); //Red Glasses
Add(3,5471,1,0,390); //Hairband Of Reginleif
Add(3,5402,1,0,390); //Mischievous Fairy
Add(3,5793,1,0,300); //Ribbon Of Life
Add(3,5314,1,0,300); //Hockey Mask
Add(3,5151,1,0,300); //Note Headphones
Add(3,5152,1,0,250); //Chinese Crown
Add(3,5667,1,0,350); //Skull Hood
Add(3,5476,1,0,350); //Grand Peco Hairband
Add(3,5564,1,0,520); //Crown of Deceit
Add(3,5304,1,0,390); //Cap Of Blindness
Add(3,18506,1,0,250); //Hattah Black
Add(3,5485,1,0,250); //Tiger Face

Add(4,2765,1,0,350); //Novice Figure
Add(4,2766,1,0,350); //Swordman Figure
Add(4,2767,1,0,350); //Acolyte Figure
Add(4,2768,1,0,350); //Mage Figure
Add(4,2769,1,0,350); //Archer Figure
Add(4,2770,1,0,350); //Thief Figure
Add(4,2771,1,0,350); //Merchant Figure

Add(5,30208,1,0,390); //Phoenix Costume
Add(5,30211,1,0,350); //Bulgogi Hat Costume
Add(5,30217,1,0,300); //Cat Coffee Cup Costume
Add(5,30218,1,0,390); //Cat Ear Ribbon Costume
Add(5,30238,1,0,300); //Heart Of Cat Costume
Add(5,30242,1,0,440); //Vesper Headgear Costume
Add(5,30204,1,0,390); //Baby Deviling Costume
Add(5,30216,1,0,390); //Walking Deviling Costume
Add(5,30224,1,0,430); //Many Stars Costume
Add(5,30240,1,0,390); //Walking Snow Fox Costume
Add(5,31120,1,0,390); //Vampire Familiar Costume
Add(5,30209,1,0,430); //Sky Lantern Blessing Costume
Add(5,30219,1,0,390); //Clay Poring Jar Costume
Add(5,30222,1,0,300); //Jioia Costume
Add(5,30228,1,0,350); //Dark Snake Lord Scarf Costume
Add(5,30235,1,0,350); //Elephant Angel Costume
Add(5,20798,1,0,350); //Grim Reaper Protection Costume
Add(5,31055,1,0,350); //Poring Soap Pipe Costume
Add(5,30058,1,0,350); //Costume Straight Winter Scarf
Add(5,30059,1,0,300); //Costume Straight Winter Scarf
Add(5,30060,1,0,300); //Costume Straight Winter Scarf
Add(5,30061,1,0,300); //Costume Straight Winter Scarf
Add(5,30062,1,0,300); //Costume Straight Winter Scarf
Add(5,30063,1,0,300); //Costume Straight Winter Scarf
Add(5,30064,1,0,300); //Costume Straight Winter Scarf
Add(5,30065,1,0,300); //Costume Straight Winter Scarf
Add(5,30066,1,0,300); //Costume Straight Winter Scarf
Add(5,30067,1,0,300); //Costume Straight Winter Scarf
Add(5,30068,1,0,300); //Costume Straight Winter Scarf
Add(5,30069,1,0,300); //Costume Straight Winter Scarf
Add(6,31318,1,0,1350); //Bag
Add(6,20511,1,0,950); //Blue Wings of Fairy
Add(6,30400,1,0,950); //Golden Fairy Wing
Add(6,30401,1,0,950); //Pink Fairy Wing
Add(6,30402,1,0,950); //Back Ribbon Wing
Add(6,30399,1,0,950); //Wing Of Heart
Add(6,20510,1,0,950); //Sword Wing
Add(6,20727,1,0,950); //Brilliant Golden Wings
Add(6,20500,1,0,950); //Archangel's Wings
Add(6,20509,1,0,950); //Wings of Uriel
Add(6,20502,1,0,950); //Little Devil Wings
Add(6,20504,1,0,950); //Cupid's Pink Wings
Add(6,20762,1,0,950); //Great Devil Wings
Add(6,20764,1,0,950); //Fallen Angel Wing
Add(6,20737,1,0,950); //Kirin Wing
Add(6,20746,1,0,950); //Rudra Wings
Add(6,20761,1,0,950); //Happiness Wings




// -----------------------------------------------------------

	freeloop(0);
	set .menu$,"";
	for(set .@i,1; .@i<=getarraysize(.iShops$); set .@i,.@i+1) {
		set .menu$, .menu$+.iShops$[.@i]+":";
		npcshopdelitem "ishop"+.@i,909;
	}
	end;

OnMenu:
	set .@size, getarraysize(@i);
	if (!.@size) set .@i, select(.menu$);
	else if (.@size == 1) set .@i, @i[0];
	else {
		for(set .@j,0; .@j<.@size; set .@j,.@j+1)
			set .@menu$, .@menu$+.iShops$[@i[.@j]]+":";
		set .@i, @i[select(.@menu$)-1];
	}
	deletearray @i[0],getarraysize(@i);
	if (.iShops$[.@i] == "") {
		message strcharinfo(PC_NAME),"An error has occurred.";
		end;
	}
	dispbottom "Select one item at a time.";
	callshop "ishop"+.@i,1;
	npcshopattach "ishop"+.@i;
	end;

OnBuyItem:
	disable_items();
	// .@q[] : RewardID, BoughtAmt, RewardAmt, BaseAmt, ReqZeny, ReqPts, { ReqItem, ReqAmt, ... }
	setarray .@q[0],@bought_nameid[0],((@bought_quantity[0] > .MaxStack)?.MaxStack:@bought_quantity[0]);
	copyarray .@q[3],getd(".q_"+.@q[0]+"[0]"),getarraysize(getd(".q_"+.@q[0]));
	set .@q[2],.@q[1]*.@q[3];
	if (!.@q[2] || .@q[2] > 30000) {
		message strcharinfo(PC_NAME),"You can't purchase that many "+getitemname(.@q[0])+".";
		end;
	}
	mes "[ ^ff0000Item Mall^000000 ]";
	mes "Reward: ^0055FF"+((.@q[2] > 1)?.@q[2]+"x ":"")+Slot(.@q[0])+"^000000";
	mes "Requirements:";
	if (.@q[4]) mes " > "+Chk(Zeny,.@q[4]*.@q[1])+(.@q[4]*.@q[1])+" Zeny^000000";
	//if (.@q[5]) mes " > "+Chk(getd(.points$[0]),.@q[5]*.@q[1])+(.@q[5]*.@q[1])+" "+.points$[1]+" ("+getd(.points$[0])+"/"+(.@q[5]*.@q[1])+")^000000";
	if (.@q[5]) mes " > "+Chk(#CASHPOINTS,.@q[5]*.@q[1])+(.@q[5]*.@q[1])+" "+.points$[1]+" ("+#CASHPOINTS+"/"+(.@q[5]*.@q[1])+")^000000";
	if (.@q[6]) for(set .@i,6; .@i<getarraysize(.@q); set .@i,.@i+2)
		mes " > "+Chk(countitem(.@q[.@i]),.@q[.@i+1]*.@q[1])+((.ShowID)?"{"+.@q[.@i]+"} ":"")+Slot(.@q[.@i])+" ("+countitem(.@q[.@i])+"/"+(.@q[.@i+1]*.@q[1])+")^000000";
	next;
	setarray @qe[1], getiteminfo(.@q[0], ITEMINFO_LOC), getiteminfo(.@q[0], ITEMINFO_VIEWSPRITE);
	if (@qe[2] > 0 && ((@qe[1] & EQP_HEAD_LOW) || (@qe[1] & EQP_HEAD_TOP) || (@qe[1] & EQP_HEAD_MID) || (@qe[1] & EQP_COSTUME_HEAD_TOP) || (@qe[1] & EQP_COSTUME_HEAD_MID) || (@qe[1] & EQP_COSTUME_HEAD_LOW) || (@qe[1] & EQP_GARMENT) || (@qe[1] & EQP_COSTUME_GARMENT)))
		set .@preview,1;
	addtimer 1000, strnpcinfo(NPC_NAME)+"::OnEnd";

	while(1) {
		switch(select(" ~ Purchase ^0055FF"+ getitemname(.@q[0]) +"^000000", ((.@preview && !@qe[7])?" ~ Preview...": ""), " ~ ^777777Cancel^000000")) {
		case 1:
			if (@qe[0]) {
				mes "[ ^ff0000Item Mall^000000 ]";
				mes "You're Credit Points is not suffecient to purchase the item.";
				close();
			}
			if (!checkweight(.@q[0],.@q[2])) {
				mes "[ ^ff0000Item Mall^000000 ]";
				mes "^FF0000You need "+(((.@q[2]*getiteminfo(.@q[0],6))+Weight-MaxWeight)/10)+" additional weight capacity to complete this trade.^000000";
				close();
			}
			if (.@q[4]) Zeny -= (.@q[4]*.@q[1]);
			if (.@q[5]) {
				#CASHPOINTS -= (.@q[5]*.@q[1]);
				callfunc("F_CashLog",#CASHPOINTS,-(.@q[5]*.@q[1]),.@q[0]+" x "+.@q[2]);	
			}
			if (.@q[6]) for(set .@i,6; .@i<getarraysize(.@q); set .@i,.@i+2)
				delitem .@q[.@i],.@q[.@i+1]*.@q[1];
			getitem .@q[0],.@q[2];
			if (.Announce) chanmsg("system",""+strcharinfo(PC_NAME)+" has created "+((.@q[2] > 1)?.@q[2]+"x "+getitemname(.@q[0]):A_An(getitemname(.@q[0])))+"!");
			close();
		case 2:
			setarray @qe[3], getlook(LOOK_HEAD_BOTTOM), getlook(LOOK_HEAD_TOP), getlook(LOOK_HEAD_MID), getlook(LOOK_ROBE), 1;
			if ((@qe[1] & 1) || (@qe[1] & 4096)) changelook LOOK_HEAD_BOTTOM, @qe[2];
			else if ((@qe[1] & 256) || (@qe[1] & 1024)) changelook LOOK_HEAD_TOP, @qe[2];
			else if ((@qe[1] & 512) || (@qe[1] & 2048)) changelook LOOK_HEAD_MID, @qe[2];
			else if ((@qe[1] & 4) || (@qe[1] & 8192)) changelook LOOK_ROBE, @qe[2];
			break;
		case 3:
			close();
		}
	}

OnEnd:
	if (@qe[7]) {
		changelook LOOK_HEAD_BOTTOM, @qe[3];
		changelook LOOK_HEAD_TOP, @qe[4];
		changelook LOOK_HEAD_MID, @qe[5];
		changelook LOOK_ROBE, @qe[6];
	}
	deletearray @qe[0],8;
	end;

function Add {
	if (getitemname(getarg(1)) == "null") {
		//debugmes "Quest reward #"+getarg(1)+" invalid (skipped).";
		return;
	}
	setarray .@j[0],getarg(2),getarg(3),getarg(4);
	for(set .@i,5; .@i<getargcount(); set .@i,.@i+2) {
		if (getitemname(getarg(.@i)) == "null") {
			//debugmes "Quest requirement #"+getarg(.@i)+" invalid (skipped).";
			return;
		} else
			setarray .@j[.@i-2],getarg(.@i),getarg(.@i+1);
	}
	copyarray getd(".q_"+getarg(1)+"[0]"),.@j[0],getarraysize(.@j);
	npcshopadditem "ishop"+getarg(0),getarg(1),((.ShowZeny)?getarg(4):0);
	return;
}

function Chk {
	if (getarg(0) < getarg(1)) {
		set @qe[0],1;
		return "^FF0000";
	} else
		return "^00FF00";
}

function Slot {
	set .@s$,getitemname(getarg(0));
	switch(.ShowSlot) {
		case 1: if (!getitemslots(getarg(0))) return .@s$;
		case 2: if (getiteminfo(getarg(0),2) == 4 || getiteminfo(getarg(0),2) == 5) return .@s$+" ["+getitemslots(getarg(0))+"]";
		default: return .@s$;
	}
}

function A_An {
	setarray .@A$[0],"a","e","i","o","u";
	set .@B$, "_"+getarg(0);
	for(set .@i,0; .@i<5; set .@i,.@i+1)
		if (compare(.@B$,"_"+.@A$[.@i])) return "an "+getarg(0);
	return "a "+getarg(0);
}
}

function	script	ishop	{

	deletearray @i[0],getarraysize(@i);
	for(set .@i,0; .@i<getargcount(); set .@i,.@i+1)
		set @i[.@i],getarg(.@i);
	doevent "i_shop::OnMenu";
	end;
	
}


// Dummy shop data -- copy as needed.
//============================================================
-	shop	ishop1	FAKE_NPC,909:-1
-	shop	ishop2	FAKE_NPC,909:-1
-	shop	ishop3	FAKE_NPC,909:-1
-	shop	ishop4	FAKE_NPC,909:-1
-	shop	ishop5	FAKE_NPC,909:-1
-	shop	ishop6	FAKE_NPC,909:-1
-	shop	ishop7	FAKE_NPC,909:-1
-	shop	ishop8	FAKE_NPC,909:-1
-	shop	ishop9	FAKE_NPC,909:-1
-	shop	ishop10	FAKE_NPC,909:-1
-	shop	ishop11	FAKE_NPC,909:-1