
morocc,171,103,4	script	Trader#osmoc	4_F_ALCHE_A,{
	mes "[ ^0055FFHourly Coin Shop^000000 ]";
	mes "Hello ^00CC00"+strcharinfo(PC_NAME)+"^000000!";
	mes "You currently have [ ^0055FF"+countitem(Hourly_Coin)+" "+getitemname(Hourly_Coin)+"^000000 ]. I will open the hourly coin shop for you now.";
	close2; 
	callfunc "onlineshop",1;
	end;	
OnInit:
	delwaitingroom;
	waitingroom "Hourly Coin Shop",0;
	end;
end;
}


-	script	online_shop	FAKE_NPC,{
function Add;
OnInit:
	
	freeloop(1);
	set .ShowZeny,1;	// Show Zeny cost, if any? (1: yes / 0: no)
	set .MaxStack,100;	// Max number of quest items purchased at one time.
	setarray .points$[0],"#CASHPOINTS","Cash Points";
	setarray .OnlineShops$[1],"Special";
	Add(1,30412,1,0,0,30023,8); //Lucky Egg 1
	Add(1,30413,1,0,0,30023,8); //Lucky Egg 2
	Add(1,30414,1,0,0,30023,8); //Lucky Egg 3

	Add(1,30024,1,0,0,30023,1); //Light White Potion Box
	Add(1,30025,1,0,0,30023,1); //Light Blue Potion Box
	Add(1,12016,1,0,0,30023,1); //Speed Potion
	Add(1,30020,1,0,0,30023,24); //VIP
	Add(1,14533,1,0,0,30023,4); //Field Manual 100%
	Add(1,12210,1,0,0,30023,4); //Bubble Gum

	Add(1,12219,1,0,0,30023,1); //Windwalk
	Add(1,12220,1,0,0,30023,1); //Adrenaline
	Add(1,12215,1,0,0,30023,1); //LV10 Blessing Scroll
	Add(1,12216,1,0,0,30023,1); //LV10 Agil Scroll
	Add(1,12217,1,0,0,30023,1); //LV5 Aspersio Scroll
	Add(1,12218,1,0,0,30023,1); //LV5 Assumptio Scroll
	Add(1,12221,1,0,0,30023,1); //Megaphone

	Add(1,14588,1,0,0,30023,2); //Party Blessing Scroll
	Add(1,14589,1,0,0,30023,2); //Party Increase Agi Scroll
	Add(1,14590,1,0,0,30023,2); //Party Assumptio Scroll

	Add(1,14542,1,0,0,30023,1); //Big Defense Potion
	Add(1,14544,1,0,0,30023,1); //Big Magic Defense Potion
	Add(1,30027,1,0,0,30023,1); //Card Remover Hammer

	Add(1,30404,1,0,0,30023,84);
	Add(1,30405,1,0,0,30023,84);
	Add(1,30406,1,0,0,30023,84);
	Add(1,30407,1,0,0,30023,84);

	Add(1,12202,1,0,0,30023,4);
	Add(1,12203,1,0,0,30023,4);
	Add(1,12204,1,0,0,30023,4);
	Add(1,12205,1,0,0,30023,4);
	Add(1,12206,1,0,0,30023,4);
	Add(1,12207,1,0,0,30023,4);
	Add(1,12209,1,0,0,30023,1);

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

	freeloop(0);
	set .menu$,"";
	for(set .@i,1; .@i<=getarraysize(.OnlineShops$); set .@i,.@i+1) {
		set .menu$, .menu$+.OnlineShops$[.@i]+":";
		npcshopdelitem "onlineshop"+.@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$+.OnlineShops$[@i[.@j]]+":";
		set .@i, @i[select(.@menu$)-1];
	}
	deletearray @i[0],getarraysize(@i);
	if (.OnlineShops$[.@i] == "") {
		message strcharinfo(PC_NAME),"An error has occurred.";
		end;
	}
	dispbottom "Select one item at a time.";
	callshop "onlineshop"+.@i,1;
	npcshopattach "onlineshop"+.@i;
	end;

OnBuyItem:
	disable_items();
	setarray .@o[0],@bought_nameid[0],((@bought_quantity[0] > .MaxStack)?.MaxStack:@bought_quantity[0]);
	copyarray .@o[3],getd(".o_"+.@o[0]+"[0]"),getarraysize(getd(".o_"+.@o[0]));
	set .@o[2],.@o[1]*.@o[3];
	if (!.@o[2] || .@o[2] > 30000) {
		message strcharinfo(PC_NAME),"You can't purchase that many "+getitemname(.@o[0])+".";
		end;
	}
	if (!checkweight(.@o[0],.@o[2])) {
		mes "[ Online Points Shop ]";
		mes "^FF0000You need "+(((.@o[2]*getiteminfo(.@o[0],6))+Weight-MaxWeight)/10)+" additional weight capacity to complete this trade.^000000";
		close;
	}
	if (.@o[4]) Zeny -= (.@o[4]*.@o[1]);
	if (.@o[5]) setd .points$[0], getd(.points$[0])-(.@o[5]*.@o[1]);

	if (.@o[6]) for(set .@i,6; .@i<getarraysize(.@o); set .@i,.@i+2){
		if(countitem(.@o[.@i]) < .@o[.@i+1]*.@o[1]) end;
		delitem .@o[.@i],.@o[.@i+1]*.@o[1];
	}
	getitembound .@o[0],.@o[2],1;
	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(".o_"+getarg(1)+"[0]"),.@j[0],getarraysize(.@j);
	npcshopadditem "onlineshop"+getarg(0),getarg(1),((.ShowZeny)?getarg(6):0);
	return;
}

}

function	script	onlineshop	{
	deletearray @i[0],getarraysize(@i);
	for(set .@i,0; .@i<getargcount(); set .@i,.@i+1)
		set @i[.@i],getarg(.@i);
	doevent "online_shop::OnMenu";
	end;

}

// Dummy shop data -- copy as needed.
//============================================================
-	shop	onlineshop1	FAKE_NPC,909:-1


