//@unloadnpc GvG Match Assistant
//@loadnpc npc/amatsu/match/entrance.txt

/*
CREATE TABLE `match` (
 `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
 `timestamp` datetime NOT NULL,
 `claimdate` datetime NOT NULL,
 `account_id` int(11) NOT NULL,
 `char_id` int(11) NOT NULL,
 `name` varchar(30) NOT NULL,
 `isclaimed` smallint(1) NOT NULL,
 `last_unique_id` int(11) unsigned DEFAULT NULL,
 PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=193 DEFAULT CHARSET=latin1
*/

new_1-1,66,108,4	script	GvG Match Assistant	4_MAL_CAPTAIN,{
	mes(.npc$);
	if(getgmlevel() < .GMAccess && !.Active){
		mes "There is no active GvG Match Event at the moment.";
		close;
	} 
	mes("I'm here to evaluate players who wish to join the ^ff0000GvG Match Event^000000.");
	next;
	mes(.npc$);
	mes("After evaluation, you will be warped to a special area where you can receive:");
	mes "- Instant 99/50 ^ff00002nd Job^000000";
	mes "- Instant 99/50 ^ff0000Extended Job^000000";
	mes "- ^ff0000+7 Armors^000000 with ^ff0000Cards^000000";
	mes "- ^ff0000+7 Weapons^000000 with ^ff0000Cards^000000";
	mes("- ^ff0000Supplies^000000 is available also.");
	if(.zeny) mes("- ^ff0000"+callfunc("F_InsertComma",.zeny)+"z Zeny^000000");
	mes("- - -");
	mes("Important Note:");
	mes("- - -");
	mes("1. Your character will be exlussively use for GvG Match Event only.");
	mes "2. All equipments will be character bound and will stay at the arena only.";
	mes "3. Trading, Vending and Mail is prohibited at the arena.";
	mes("Would you like to be warp now?");
	next;
	switch(select(
		((getgmlevel() < .GMAccess)?":":" > ^FF0000GM Menu^000000:")+
		 " > ^0055FFWarp to Waiting Room^000000:"+
		 " > ^777777Close^000000"
	)) {
	case 1:
		mes(.npc$);
		while(1) {
			switch(select(
				"Guild Size [ ^28bf00"+.guild_min+"^000000 ]:"+
				"No Mobile [ ^28bf00"+.nomobile+"^000000 ]:"+
				"No Rejoin [ ^28bf00"+.norejoin+"^000000 ]:"+
				"Zeny [ ^28bf00"+.zeny+"^000000 ]:"+
				"Key [ ^28bf00"+getitemname($key)+"^000000 ]:"+
				"Allow Entry [ ^28bf00"+.Active+"^000000 ]:"+
				 "^777777Close^000000"
			)) {
			case 1: input .guild_min,1; break;
			case 2: input .nomobile,0; break;
			case 3: input .norejoin,0; break;
			case 4: input .zeny,0; break;
			case 5: input $key,0; break;
			case 6: input .Active,0; break;
			default:
				close();
			}
		}
		break;

	case 2:
		if(#haschar4match){
			mes(.npc$);
			mes "Oh! It seems that you already have character created for match event.";
			close;
		}
		if(countitem(Green_Voucher)){
			mes(.npc$);
			mes "Oh! this character is not eligible for match event. Just create a new one and talk to me again.";
			close;
		}							
		mes(.npc$);
		mes("Please wait ...");
		if(.zeny) Zeny = Zeny + .zeny;
		nude();
		atcommand("@itemreset");
		getitembound $key,1,4;
		#haschar4match = 1;	

		savepoint .mapName$,.warpx,.warpy;
		warp .mapName$,.warpx,.warpy;
		close();

	default:
		close();
	}
	close();


OnInit:
   .GMAccess = 99;
   $key = 7234;
   .mapName$ = "tournament";
   .warpx = 73;
   .warpy = 105;	
   .npc$ = "[ GvG Match Organizer ]";
   .guild_min = 5;
   .zeny = 5000000;
   .credits = 0;
   .nomobile = 0;
   .norejoin = 0;
   .Active = 0;		
   end;
}	
