//===== eAthena Script =======================================
//= Bullet Dealer Tony
//===== By ===================================================
//= Playtester, Paradox924X
//===== Version ==============================================
//= 1.3
//===== Compatible With ======================================
//= eAthena SVN with jAthena scripting engine and . variables
//===== Description ==========================================
//= Bullet trader.
//===== Comments =============================================
//= 1.0 First version [Playtester]
//= 1.1 Converted from Aegis [Paradox924X]
//= 1.2 More optimized conversion [Legionaire]
//= 1.2a Removed .GATs [Lupus]
//= 1.3 Fixed [Playtester] Optimized. Got rid of @vars [Lupus]
//============================================================

que_ng,187,156,3	script	Bullet Dealer Tony	86,{

	mes "[Tony]";
	if (BaseJob == Job_Gunslinger) {
		mes "I'm Bullet-tooth Tony!";
		mes "Whenever your out of bullets,";
		mes "Visit me!!!";
		next;
		mes "[Tony]";
		mes "Now~! Friend~Companion~ Buddy~";
		mes "What do you need?!";
		mes "Choose anything~!";
		mes "And pay money~!";
		next;
		switch(select("Poison Sphere:Flare Sphere:Lighting Sphere:Blind Sphere:Freezing Sphere:Cancel")) {
		case 1: callfunc "Bullet_Trade",937,10,13205; break;
		case 2: callfunc "Bullet_Trade",7097,2,13203; break;
		case 3: callfunc "Bullet_Trade",7053,3,13204; break;
		case 4: callfunc "Bullet_Trade",1024,5,13206; break;
		case 5: callfunc "Bullet_Trade",7054,2,13207; break;
		default:
			mes "[Tony]";
			mes "Mmm~ Okay~";
			mes "Please visit again~";
			mes "I, Bullet-tooth Tony,";
			mes "Will always be here~!!!";
			close;
		}
	}
	mes "I'm a trader who supplies";
	mes "Gunslingers with trade items.";
	mes "I am called Bullet-tooth Tony.";
	next;
	mes "[Tony]";
	mes "I don't think you are a Gunslinger";
	mes "So just look around";
	mes "and go.";
	close;
}

function	script	Bullet_Trade	{
	mes "[Tony]";
	mes "Input the amount you wish to purchase.";
	next;
	mes "[Tony]";
	mes "We trade 30 "+getitemname(getarg(2))+"s for";
	mes "1 Phracon,";
	mes "1 Emveretarcon,";
	mes "and "+getarg(1)+" "+getitemname(getarg(0))+".";
	next;
	mes "[Tony]";
	mes "The maximum number you can trade is 500.";
	mes "If you want to cancel, input 0.";
	next;
	input .@amount;
	mes "[Tony]";
	if (.@amount < 1 || .@amount > 500) {
		mes "Invalid Amount!";
		mes "Enter again~!";
		close;
	} else if (countitem(1010) >= .@amount && countitem(1011) >= .@amount && countitem(getarg(0)) >= (.@amount*getarg(1))) {
		if (checkweight(getarg(2),.@amount * 30) == 0) {
			mes "I cannot give it to you because your inventory is full. Come back after your inventory has more space.";
			close;
		} else {
			mes "Oh~ Good!";
			mes "Trade number checked!";
			mes "I'll trade immediately.";
			delitem 1010,.@amount;
			delitem 1011,.@amount;
			delitem getarg(0),.@amount * getarg(1);
			getitem getarg(2),.@amount * 30;
			close;
		}
	} else {
		mes "Tsk Tsk~";
		mes "You do not have";
		mes "enough items for the";
		mes "items you want to trade.";
		mes "Prepare again and come back.";
		close;
	}
}