-	script	Loot Manager	FAKE_NPC,{
	end;

OnInit:
	bindatcmd("alootid", strnpcinfo(NPC_NAME)+"::OnAtCommand");
	end;

OnAtCommand:
	function ManageLoots;
	mes("What would you like to do?");
	if(select("Autoloot Item:Select a Loot Loadout")==1){
		mes("Maximum 10 Ids");
		mes("Input Item ID:");
		for (.@x = 0; .@x < 10; .@x++){
			while (@AlootID[.@x] > 0){
				.@x++;
			}
			if (.@x >= 10) {
				mes "10 Items inserted.";
				break;
			}
			mes("Loot# : "+ (.@x + 1));
			do {
				input(@AlootID[.@x]);
			} while(getitemname(@AlootID[.@x]) == "null");
			atcommand("@alootid +"+@AlootID[.@x]);
			next;
			mes("Add another?");
			if (select("Yes:No") == 2) {
				break;
			}
		}
	}
	next;
	mes("Select a Loot loadout.");
	for (.@i = 1; .@i <= 5; .@i++)
		.@Menu$ += (( getd( "ASlot_"+.@i+"$" ) == "" )?"^FF0000Empty Slot^000000":getd( "ASlot_"+.@i+"$" ) )+":";
	.@ASlot = select(.@Menu$);
	do {
		next;
		mes("Autoloots:");
		for(.@x = 0; .@x < getarraysize(@AlootID); .@x++) {
			mes(getitemname(@AlootID[.@x]) +", ");
		}
		if (getd( "ASlot_"+.@ASlot+"$" ) == "") {
			.@option = select("", "Save", "");
		} else {
			.@option = select("^0000FFLoad", "", "^FF0000Clear");
		}
		ManageLoots( .@ASlot,.@option);
	} while(.@option != 1);
	close();

	function	ManageLoots{
		.@slot = getarg(0);
		.@option = getarg(1);
		switch(.@option) {
			case 1: // Switch Loot
				atcommand("@alootid reset");
				.@var$ = getd("LootID_"+ .@slot +"$");
				explode(.@Tmp_array, .@var$, ":");
				for(.@x = 0;.@x < getarraysize(.@Tmp_array); .@x++)
					atcommand("@alootid +"+.@Tmp_array[.@x]);
				message strcharinfo(0),"Loot Loadout has been ^FF0000Loaded^000000.";
				break;
			case 2: // Save Loot
				message strcharinfo(0),"Loot Loadout has been ^FF0000Saved^000000.";
				for(.@x = 0;.@x <getarraysize(@AlootID); .@x++){
					.@lootIds$ += @AlootID[.@x]+":";
				}
				setd("LootID_"+ .@slot +"$", .@lootIds$);
				break;
			case 3: // Clear Loot
				message strcharinfo(0),"Loot Loadout has been ^FF0000Cleared^000000.";
				setd(("LootID_"+ .@slot +"$"),"");
				break;
		}
	return;
	}
}