//	~~~~~ Please use this latest int__ function that support negative numbers ~~~~~
function	script	int__	{
	.@i = getstrlen( .@str$ = getarg(0) ) -3;
	.@is_negative = charat( .@str$, 0 ) == "-";
	while ( .@i > .@is_negative ) {
		.@str$ = insertchar( .@str$, ",", .@i );
		.@i -= 3;
	}
	return .@str$;
}

-	script	Private Room Assistant	-1,{
	goto L_Start;

OnInit:
	//atcommand "@unloadnpc gkut";
	getmapxy .@map$, .@x, .@y, 1;
	if ( .@map$ == "" ) {

//	Config ---------------------------------------------------------------------------------------

	// Time for rent a room IN MINUTES. When time out, players inside the room will kick out. Do Not set this as 0
	set .timeout, 60;
	// if the room left empty for # minutes, will be treated as give up the room. Do Not set this as 0
	set .nobodygiveup, 5;

	// NOTE : The script only search item OR Zeny. if you specify item amount, then it will ask for the item. If item amount is 0, then it will ask for Zeny.

	// the cost to rent a room
	set .rentitemid, 0; // item id use for rent a room - 674 - mithil coin
	set .rentitemamount, 0; // amount of items to rent a room
	set .rentcost, 10000; // otherwise, Zeny cost to rent a room
	set .partycost,50000;
	set .guildcost,100000;

	// If the room has left over monsters while nobody in the room and the room not give up yet, shall we kill monsters in empty room ?
	set .killmonster, 0; // Default is yes

	set .@menu[10], 0; // Sell shop items options On/Off ( shop npc above )

	//	set respawn point when they leave the room. Obviously warp to the Private MVP Room Warper npc
	set .respawnmap$, "morocc"; // Note : "SavePoint" does NOT work
	set .respawnx, 145;
	set .respawny, 97;

	// The minimum GM level can kick a room in use
	set .gmlvlkick, 99;


//	Config Ends ------------------------------------------------------------------------

		if ( .timeout == 0 ) set .timeout, 60;
		if ( .nobodygiveup == 0 ) set .nobodygiveup, 5;
		if ( .inputlimit < 1 ) set .inputlimit, 1;

		if ( .rentitemid && .rentitemamount ) {
			if ( getitemname(.rentitemid) == "null" ) {
				//debugmes "Private Room: Rent a room is using invalid item id.";
			}
		}
		set .@i, 1;
		while ( .@i <= 9 ) {
			if ( .@menu[.@i] && getd(".group"+ .@i +"itemid") && getd(".group"+ .@i +"itemamount") ) {
				if ( getitemname( getd(".group"+ .@i +"itemid") ) == "null" ) {
					//debugmes "Private Room: Group no. "+ .@i +" is using invalid item id.";
				}
			}
			set .@i, .@i +1 ;
		}
		set .menu$, ( (.@menu[0])?"Heal":"" )+":"+( (.@menu[1])?"Summon "+ .group1name$:"" )+":"+( (.@menu[2])?"Summon "+ .group2name$:"" )+":"+( (.@menu[3])?"Summon "+ .group3name$:"" )+":"+( (.@menu[4])?"Summon "+ .group4name$:"" )+":"+( (.@menu[5])?"Summon "+ .group5name$:"" )+":"+( (.@menu[6])?"Summon "+ .group6name$:"" )+":"+( (.@menu[7])?"Summon "+ .group7name$:"" )+":"+( (.@menu[8])?"Summon "+ .group8name$:"" )+":"+( (.@menu[9])?"Summon "+ .group9name$:"" )+":"+( (.@menu[10])?"Buy branches":"" )+":Leave this room:Give up this room";

		set .@i, 1;
		while ( .@i <= 9 ) {
			setd ".group"+ .@i +"idsize", getarraysize( getd(".group"+ .@i +"id") );
			if ( .@menu[.@i] && getd(".group"+ .@i +"limit") <= 0 ) {
				set .@j, 0;
				while ( .@j < getd(".group"+ .@i +"idsize") ) {
					setd ".group"+ .@i +"menu$", getd(".group"+ .@i +"menu$") + getmonsterinfo( getd(".group"+ .@i +"id["+ .@j +"]"), 0) +":";
					set .@j, .@j +1 ;
				}
			}
			set .@i, .@i +1 ;
		}
	}
	else {
		setmapflag .@map$, mf_nowarpto;
		setmapflag .@map$, mf_noteleport;
		setmapflag .@map$, mf_nomemo;
		setmapflag .@map$, mf_nosave;
		setmapflag .@map$, mf_nopenalty;



	//	setmapflag .@map$, mf_nowarp;
	//	setmapflag .@map$, mf_noreturn;
	//	setmapflag .@map$, mf_nomobloot;
	//	setmapflag .@map$, mf_nomvploot;
	//	setmapflag .@map$, mf_monster_noteleport;
	//	setmapflag .@map$, mf_noicewall;
	//	setmapflag .@map$, mf_nobaseexp;
	//	setmapflag .@map$, mf_nojobexp;
	//	setmapflag .@map$, mf_novending;
		sleep 1;
		mapannounce .@map$, "Admin has refresh the server, please register the room again.", 1;
		mapwarp .@map$, .respawnmap$, .respawnx, .respawny;
	}
	end;

L_Start: // I hate gotos ... but ...
	set .@dif, strnpcinfo(2);
	if ( .remind[.@dif] == 0 ) {
		set .remind[.@dif], 1;
		initnpctimer;
	}
	mes "[Private Room Assistant]";
	mes "Hi, what can I do for you ?";
	next;
	switch ( select(.menu$) ) {
		case 1:
			mes "[Private Room Assistant]";
			/*
			if ( mobcount("this","") > 0 ) {
				mes "I cannot offer heal service when there are monsters around.";
				close;
			}
			*/
			sc_end SC_STONE;
			sc_end SC_SLOWDOWN;
			sc_end SC_FREEZE;
			sc_end SC_SLEEP;
			sc_end SC_CURSE;
			sc_end SC_SILENCE;
			sc_end SC_CONFUSION;
			sc_end SC_BLIND;
			sc_end SC_BLEEDING;
			sc_end SC_DECREASEAGI;
			sc_end SC_POISON;
			sc_end SC_HALLUCINATION;
			sc_end SC_STRIPWEAPON;
			sc_end SC_STRIPARMOR;
			sc_end SC_STRIPHELM;
			sc_end SC_STRIPSHIELD;
			sc_end SC_CHANGEUNDEAD;
			sc_end SC_ORCISH;
			sc_end SC_BERSERK;
			sc_end SC_SKE;
			sc_end SC_SWOO;
			sc_end SC_SKA;
			percentheal 100,0;
			//specialeffect2 EF_HEAL;
			sleep2 1000;
			skilleffect AL_BLESSING,0;
			sc_start SC_BLESSING,240000,10;
			heal -15,0;
			sleep2 1000;
			skilleffect AL_INC_AGI,0;
			sc_start SC_INC_AGI,240000,10;
			mes "You have completely healed.";
			close;
		default:
			set .@group, @menu -1;
			if ( .floodcontrol && mobcount("this","") > 0 ) {
				mes "[Private Room Assistant]";
				mes "I cannot summon another monster when there are monsters around.";
				close;
			}
			else if ( getd(".group"+ .@group +"itemid") && getd(".group"+ .@group +"itemamount") ) {
				mes "[Private Room Assistant]";
				mes "The cost to summon a "+ getd(".group"+ .@group +"name$") +" is "+ getd(".group"+ .@group +"itemamount") +" "+ getitemname( getd(".group"+ .@group +"itemid") ) +".";
				if ( getd(".group"+ .@group +"limit") < 0 )
					mes "("+( ( ~getd(".group"+ .@group +"limit")+1 - getd(".group"+ .@group +"limit"+ .@dif) <= 0 )?0:( ~getd(".group"+ .@group +"limit")+1 - getd(".group"+ .@group +"limit"+ .@dif) ) )+") more summons for this group.";
				next;
			}
			else if ( getd(".group"+ .@group +"cost") ) {
				mes "[Private Room Assistant]";
				mes "The cost to summon a "+ getd(".group"+ .@group +"name$") +" is "+ callfunc("int__", getd(".group"+ .@group +"cost") ) +" Zeny.";
				if ( getd(".group"+ .@group +"limit") < 0 )
					mes "("+( ( ~getd(".group"+ .@group +"limit")+1 - getd(".group"+ .@group +"limit"+ .@dif) <= 0 )?0:( ~getd(".group"+ .@group +"limit")+1 - getd(".group"+ .@group +"limit"+ .@dif) ) )+") more summons for this group.";
				next;
			}
			else if ( getd(".group"+ .@group +"limit") < 0 ) {
				mes "[Private Room Assistant]";
				mes "("+( ( ~getd(".group"+ .@group +"limit")+1 - getd(".group"+ .@group +"limit"+ .@dif) <= 0 )?0:( ~getd(".group"+ .@group +"limit")+1 - getd(".group"+ .@group +"limit"+ .@dif) ) )+") more summons for this group.";
				next;
			}
			if ( getd(".group"+ .@group +"limit") < 0 && getd(".group"+ .@group +"limit"+ .@dif) >= ~getd(".group"+ .@group +"limit")+1 ) {
				mes "[Private Room Assistant]";
				mes "I'm sorry, but you can't summon any more monster for this group.";
				close;
			}
			else if ( getd(".group"+ .@group +"limit") > 0 ) {
				for ( set .@i, 0; .@i < getd(".group"+ .@group +"idsize"); set .@i, .@i +1 )
					set .@menu$, .@menu$ +( ( getd(".group"+ .@group +"limit"+ .@dif +"["+ .@i +"]") >= getd(".group"+ .@group +"limit") )?"^999999":"^000000" )+ getmonsterinfo( getd(".group"+ .@group +"id["+ .@i +"]"), 0) +" ("+ ( ( getd(".group"+ .@group +"limit") - getd(".group"+ .@group +"limit"+ .@dif +"["+ .@i +"]") <= 0 )?0:( getd(".group"+ .@group +"limit") - getd(".group"+ .@group +"limit"+ .@dif +"["+ .@i +"]") ) ) +")"+":";
				set .@menu, select(.@menu$) -1;
			}
			else
				set .@menu, select( getd(".group"+ .@group +"menu$") ) -1;
			mes "[Private Room Assistant]";
			if ( .floodcontrol == 0 && .inputlimit > 1 ) {
				mes "Input an amount of monsters to summon.";
				next;
				input .@amount;
				if ( .@amount == 0 ) close;
				else if ( .@amount > .inputlimit )
					set .@amount, .inputlimit;
				mes "[Private Room Assistant]";
			}
			else
				set .@amount, 1;
			if ( getd(".group"+ .@group +"itemid") && getd(".group"+ .@group +"itemamount") ) {
				if ( countitem( getd(".group"+ .@group +"itemid") ) < getd(".group"+ .@group +"itemamount") * .@amount ) {
					mes "You don't have enough "+ getitemname( getd(".group"+ .@group +"itemid") ) +" to summon a "+ getd(".group"+ .@group +"name$") +".";
					close;
				}
			}
			else if ( getd(".group"+ .@group +"cost") ) {
				if ( Zeny < getd(".group"+ .@group +"cost") * .@amount ) {
					mes "You don't have enough Zeny to summon a "+ getd(".group"+ .@group +"name$") +".";
					close;
				}
			}
			if ( .floodcontrol && mobcount("this","") > 0 ) {
				mes "I cannot summon another monster when there are monsters around.";
				close;
			}
			else if ( getd(".group"+ .@group +"limit") > 0 ) {
				if ( getd(".group"+ .@group +"limit"+ .@dif +"["+ .@menu +"]") >= getd(".group"+ .@group +"limit") ) {
					mes "I'm sorry, but you already summoned that monster too much. Try summon another.";
					close;
				}
				else if ( getd(".group"+ .@group +"limit"+ .@dif +"["+ .@menu +"]") + .@amount > getd(".group"+ .@group +"limit") ) {
					mes "The amount you input is more than the limit you can summon. Try reduce the amount.";
					close;
				}
			}
			else if ( getd(".group"+ .@group +"limit") < 0 ) {
				if ( getd(".group"+ .@group +"limit"+ .@dif) >= ~getd(".group"+ .@group +"limit")+1 ) {
					mes "I'm sorry, but you can't summon any more monster for this group.";
					close;
				}
				else if ( getd(".group"+ .@group +"limit"+ .@dif) + .@amount > ~getd(".group"+ .@group +"limit")+1 ) {
					mes "The amount you input is more than the limit you can summon. Try reduce the amount.";
					close;
				}
			}
			mes "Summoning "+ .@amount +" "+ getmonsterinfo( getd(".group"+ .@group +"id["+ .@menu +"]"), 0) +".";
			mes "Ok, get ready ?";
			close2;
			if ( .floodcontrol && mobcount("this","") > 0 ) end;
			if ( getd(".group"+ .@group +"itemid") && getd(".group"+ .@group +"itemamount") ) {
				if ( countitem( getd(".group"+ .@group +"itemid") ) < getd(".group"+ .@group +"itemamount") * .@amount ) end;
				delitem getd(".group"+ .@group +"itemid"), getd(".group"+ .@group +"itemamount") * .@amount;
			}
			else if ( getd(".group"+ .@group +"cost") ) {
				if ( Zeny < getd(".group"+ .@group +"cost") * .@amount ) end;
				set Zeny, Zeny - getd(".group"+ .@group +"cost") * .@amount;
			}
			if ( getd(".group"+ .@group +"limit") > 0 ) {
				if ( getd(".group"+ .@group +"limit"+ .@dif +"["+ .@menu +"]") + .@amount > getd(".group"+ .@group +"limit") ) end;
				setd ".group"+ .@group +"limit"+ .@dif +"["+ .@menu +"]", getd(".group"+ .@group +"limit"+ .@dif +"["+ .@menu +"]") + .@amount;
			}
			else if ( getd(".group"+ .@group +"limit") < 0 ) {
				if ( getd(".group"+ .@group +"limit"+ .@dif) + .@amount > ~getd(".group"+ .@group +"limit")+1 ) end;
				setd ".group"+ .@group +"limit"+ .@dif, getd(".group"+ .@group +"limit"+ .@dif) + .@amount;
			}
			monster "this", 0, 0, "--ja--", getd(".group"+ .@group +"id["+ .@menu +"]"), .@amount;
			end;
		case 11:
			if ( mobcount("this","") > 0 ) {
				mes "[Private Room Assistant]";
				mes "I cannot offer this service when there are monsters around.";
				close;
			}
			close2;
			callshop "MVP room#branch", 0;
			end;
		case 12:
			mes "[Private Room Assistant]";
			mes "Are you sure you want to leave this room ?";
			mes "If this room left empty for more than "+ .nobodygiveup +" minutes, you lost ownership for this room.";
			if ( select( "Yes:No") == 2 ) close;
			warp .respawnmap$, .respawnx, .respawny;
			end;
		case 13:
			mes "[Private Room Assistant]";
			getmapxy .@map$, .@x, .@y, 0;
			if ( getmapusers(.@map$) > 1 ) {
				mes "There are still some players in this room. Make sure you are the last member in this room to use this option.";
				close;
			}
			mes "Are you sure you want to give up this room ?";
			if ( .rentcost )
				mes "You will need to pay again to enter this room.";
			next;
			if ( select( "Yes:No" ) == 2 ) close;
			warp .respawnmap$, .respawnx, .respawny;
			set .remaintime[.@dif], -1;
			end;
	}
	close;

OnEnterMap:
	atcommand "@mapflag pvp 0";
	atcommand "@mapflag pvp_noguild 0";
	atcommand "@mapflag pvp_nightmaredrop 0";

	set .@dif, strnpcinfo(2);
	set .remind[.@dif], 0;
	for ( set .@i, 1; .@i <= 9; set .@i, .@i +1 )
		deletearray getd(".group"+ .@i +"limit"+ .@dif), getd(".group"+ .@i +"idsize");
	set .nobodycounter[.@dif], 0;
	getmapxy .@map$, .@x, .@y ,1;
	set .starttime[.@dif], gettimetick(2);
	do {
		set .remaintime[.@dif], .timeout * 60 + .starttime[.@dif] - gettimetick(2);
		set .@hour[.@dif], .remaintime[.@dif] / 3600 ;
		set .@min[.@dif], .remaintime[.@dif] % 3600 / 60 ;
		set .@sec[.@dif], .remaintime[.@dif] % 3600 % 60 ;
		delwaitingroom strnpcinfo(0);
		waitingroom "Time Left = "+( ( .@hour[.@dif] )?( .@hour[.@dif] +":"):"" )+( ( .@min[.@dif] < 10 )?"0"+ .@min[.@dif]: .@min[.@dif] )+":"+( ( .@sec[.@dif] < 10 )?"0"+ .@sec[.@dif]: .@sec[.@dif] ), 0;
		if ( getmapusers(.@map$) )
			set .nobodycounter[.@dif], 0;
		else {
			set .nobodycounter[.@dif], .nobodycounter[.@dif] +1 ;
			if ( .nobodycounter[.@dif] > .nobodygiveup * 60 ) break;
		}
		sleep 995;
	} while ( .remaintime[.@dif] > 1 );
	set .remaintime[.@dif], 0;
	delwaitingroom "Private Room Assistant#"+ .@dif;
	mapwarp .@map$, .respawnmap$, .respawnx, .respawny;
	end;

OnTimer100:
	stopnpctimer;
	npctalk "Hi ~ the bubble above my head is the countdown for using this room.";
	sleep 2000;
	npctalk "Sometimes, I can skip for about 1 second in the countdown.";
	sleep 3000;
	npctalk "That is because the server is experiencing minor lag problem.";
	sleep 3000;
	npctalk "So, don't complain about me cheated for the countdown ~ ^.^";
	sleep 3000;
	npctalk "Have a nice day ~";
	end;
}

morocc,142,100,5	script	Branch Room	4_F_KAFRA6,{
	mes "[Branch Room]";
	mes "Please select a private room.";
	if ( getvariableofnpc(.rentitemid, "Private Room Assistant") && getvariableofnpc(.rentitemamount, "Private Room Assistant") )
		mes "The cost to rent a room for "+ getvariableofnpc(.timeout, "Private Room Assistant") +" minutes is "+ getvariableofnpc(.rentitemamount, "Private Room Assistant") +" "+ getitemname( getvariableofnpc(.rentitemid, "Private Room Assistant") ) +".";
	else if ( getvariableofnpc(.rentcost, "Private Room Assistant") )
		mes "The cost to rent a room for "+ getvariableofnpc(.timeout, "Private Room Assistant") +" minutes is  ^EE8800Personal^000000: "+ callfunc("int__", getvariableofnpc(.rentcost, "Private Room Assistant") ) +" z.  ^70CC11Party^000000: "+ callfunc("int__", getvariableofnpc(.partycost, "Private Room Assistant") ) +" z.  ^0000FFGuild^000000: "+ callfunc("int__", getvariableofnpc(.guildcost, "Private Room Assistant") ) +" z.";

	else
		mes "You can only use the room for only "+ getvariableofnpc(.timeout, "Private Room Assistant") +" minutes.";
	for ( set .@i, 1; .@i <= 8; set .@i, .@i +1 ) {
		if ( getvariableofnpc(.remaintime[.@i],"Private Room Assistant") ) {
			switch ( .type[.@i] ) {
				case 1: set .@color$, "^EE8800"; break;
				case 2: set .@color$, "^70CC11"; break;
				case 3: set .@color$, "^0000FF"; break;
				default: set .@color$, "^000000";
			}
			mes "Room #"+ .@i +" = "+ .@color$ + .whoinuse$[.@i] +"^000000";
		}
	}
	next;
	set .@room, select("Room 1 ["+ getmapusers("pvp_n_1-5") +"]",
		"Room 2 ["+ getmapusers("pvp_n_2-5") +"]",
		"Room 3 ["+ getmapusers("pvp_n_3-5") +"]",
		"Room 4 ["+ getmapusers("pvp_n_4-5") +"]",
		"Room 5 ["+ getmapusers("pvp_n_5-5") +"]",
		"Room 6 ["+ getmapusers("pvp_n_6-5") +"]",
		"Room 7 ["+ getmapusers("pvp_n_7-5") +"]",
		"Room 8 ["+ getmapusers("pvp_n_8-5") +"]");
	if ( getvariableofnpc(.remaintime[.@room],"Private Room Assistant") ) {
		if ( .inuseid[.@room] == getcharid(.type[.@room]) ) {
			if ( getvariableofnpc(.killmonster,"Private Room Assistant") && getmapusers("pvp_n_"+ .@room+"-5") == 0 )
				killmonsterall "pvp_n_"+ .@room+"-5";
			warp "pvp_n_"+ .@room+"-5", 0,0;
			end;
		} else {
			mes "[Branch Room]";
			switch ( .type[.@room] ) {
				case 1: set .@color$, "^EE8800Party "; break;
				case 2: set .@color$, "^70CC11Guild "; break;
				case 3: set .@color$, "^0000FFPlayer ";
			}
			mes "This room is reserved for ";
			mes .@color$ + .whoinuse$[.@room] +"^000000 .";
			if ( getgmlevel() < getvariableofnpc(.gmlvlkick,"Private Room Assistant") ) {
				mes "Please select another.";
				close;
			}
			mes " ";
			mes "Currently there are "+ getmapusers("pvp_n_"+ .@room+"-5") +" players";
			mes "in that room.";
			set .@remaintime, getvariableofnpc(.remaintime[.@room],"Private Room Assistant");
			mes "It still has "+( .@remaintime /60 )+"mn "+( .@remaintime %60 )+"s left.";
			set .@nobodycounter, getvariableofnpc(.nobodycounter[.@room],"Private Room Assistant");
			if ( .@nobodycounter )
				mes "And have left empty for "+( .@nobodycounter /60 )+"mn "+( .@nobodycounter %60 )+"s.";
			mes "Kick them ?";
			next;
			if ( select ( "No:Yes" ) == 1 ) close;
			set getvariableofnpc(.remaintime[.@room],"Private Room Assistant"), -1;
			mes "[Branch Room]";
			mes "Room#"+ .@room +" is empty now.";
			close;
		}
	}
	mes "[Branch Room]";
	if ( getvariableofnpc(.rentitemid, "Private Room Assistant") && getvariableofnpc(.rentitemamount, "Private Room Assistant") ) {
		if ( countitem(getvariableofnpc(.rentitemid, "Private Room Assistant")) < getvariableofnpc(.rentitemamount, "Private Room Assistant") ) {
			mes "[Branch Room]";
			mes "You don't have enough "+ getitemname( getvariableofnpc(.rentitemid, "Private Room Assistant") ) +" to rent a room.";
			close;
		}
	}
	else if ( getvariableofnpc(.rentcost, "Private Room Assistant") ) {
		if ( Zeny < getvariableofnpc(.rentcost, "Private Room Assistant") ) {
			mes "[Branch Room]";
			mes "You don't have enough Zeny to rent a room.";
			close;
		}
	}
	mes "You reserve this room for ...";
	next;
	set .@type, select("For my party members - ^70CC11"+ callfunc("int__", getvariableofnpc(.partycost, "Private Room Assistant") ) +"^000000 z", "For my guild members - ^0000FF"+ callfunc("int__", getvariableofnpc(.guildcost, "Private Room Assistant") ) +"^000000 z", "For personal account use - ^EE8800"+ callfunc("int__", getvariableofnpc(.rentcost, "Private Room Assistant") ) +"^000000 z" );
	set .@roomtype,.@type;
	//mes .@roomtype;
	//close;
	if ( getcharid(.@type) == 0 ) {
		mes "[Branch Room]";
		mes "You do not own a "+( (.@type == 1)?"Party":"Guild" )+".";
		close;
	}
	else if ( getvariableofnpc(.rentitemid, "Private Room Assistant") && getvariableofnpc(.rentitemamount, "Private Room Assistant") ) {
		if ( countitem(getvariableofnpc(.rentitemid, "Private Room Assistant")) < getvariableofnpc(.rentitemamount, "Private Room Assistant") ) {
			mes "[Branch Room]";
			mes "You don't have enough "+ getitemname( getvariableofnpc(.rentitemid, "Private Room Assistant") ) +" to rent a room.";
			close;
		}
	}
	else if ( getvariableofnpc(.remaintime[.@room],"Private Room Assistant") ) {
		mes "[Branch Room]";
		mes "I'm sorry, somebody else has already register this room faster than you.";
		close;
	}
	for ( set .@i, 1; .@i <= 8; set .@i, .@i +1 ) {
		if ( getvariableofnpc(.remaintime[.@i],"Private Room Assistant") && .@type == .type[.@i] && getcharid(.@type) == .inuseid[.@i] ) {
			mes "[Branch Room]";
			mes "You already rented Room#"+ .@i +". Use that room instead.";
			close;
		}
	}
	set .type[.@room], .@type;
	set .inuseid[.@room], getcharid(.@type);
	set .whoinuse$[.@room], strcharinfo( (.@type == 3)?0:.@type );
	if ( getvariableofnpc(.rentitemid, "Private Room Assistant") && getvariableofnpc(.rentitemamount, "Private Room Assistant") ) {
		if ( countitem(getvariableofnpc(.rentitemid, "Private Room Assistant")) < getvariableofnpc(.rentitemamount, "Private Room Assistant") ) end;
		delitem getvariableofnpc(.rentitemid, "Private Room Assistant"), getvariableofnpc(.rentitemamount, "Private Room Assistant");
	}
	else if ( getvariableofnpc(.rentcost, "Private Room Assistant") && .@roomtype == 3 ) {

		if ( Zeny < getvariableofnpc(.rentcost, "Private Room Assistant") ) 
		{
			mes "[Branch Room]";
			mes "You don't have enough Zeny to rent a room.";
			close;
		}
		set Zeny, Zeny - getvariableofnpc(.rentcost, "Private Room Assistant");
		dispbottom ("You reserved a private room for your self. You are charged "+getvariableofnpc(.rentcost, "Private Room Assistant")+"z");
	}
	else if ( getvariableofnpc(.rentcost, "Private Room Assistant") && .@roomtype == 1 ) {

		if ( Zeny < getvariableofnpc(.partycost, "Private Room Assistant") ) 
		{
			mes "[Branch Room]";
			mes "You don't have enough Zeny to rent a room.";
			close;
		}

		set Zeny, Zeny - getvariableofnpc(.partycost, "Private Room Assistant");
		dispbottom ("You reserved a private room for your party. You are charged "+getvariableofnpc(.partycost, "Private Room Assistant")+"z");
	}
	else if ( getvariableofnpc(.rentcost, "Private Room Assistant") && .@roomtype == 2 ) {

		if ( Zeny < getvariableofnpc(.guildcost, "Private Room Assistant") )
		{
			mes "[Branch Room]";
			mes "You don't have enough Zeny to rent a room.";
			close;
		}

		set Zeny, Zeny - getvariableofnpc(.guildcost, "Private Room Assistant");
		dispbottom ("You reserved a private room for your guild. You are charged "+getvariableofnpc(.guildcost, "Private Room Assistant")+"z");
	}
	warp "pvp_n_"+ .@room+"-5", 0,0;
	killmonsterall "pvp_n_"+ .@room+"-5";
	donpcevent "Private Room Assistant#"+ .@room +"::OnEnterMap";
	end;

OnInit:
	waitingroom "Branch Rooms",0;
end;
}

office,124,18,0	duplicate(Branch Room)	Branch Room#of	4_F_KAFRA6

pvp_n_1-5,99,100,4	duplicate(Private Room Assistant)	Private Room Assistant#1	4_F_KAFRA6
pvp_n_2-5,99,100,4	duplicate(Private Room Assistant)	Private Room Assistant#2	4_F_KAFRA6
pvp_n_3-5,99,100,4	duplicate(Private Room Assistant)	Private Room Assistant#3	4_F_KAFRA6
pvp_n_4-5,99,100,4	duplicate(Private Room Assistant)	Private Room Assistant#4	4_F_KAFRA6
pvp_n_5-5,99,100,4	duplicate(Private Room Assistant)	Private Room Assistant#5	4_F_KAFRA6
pvp_n_6-5,99,100,4	duplicate(Private Room Assistant)	Private Room Assistant#6	4_F_KAFRA6
pvp_n_7-5,99,100,4	duplicate(Private Room Assistant)	Private Room Assistant#7	4_F_KAFRA6
pvp_n_8-5,99,100,4	duplicate(Private Room Assistant)	Private Room Assistant#8	4_F_KAFRA6


