Inn room auto dispatch function

What it does
It dispatches aPC to a free inn room in and make him rest.

If you have a personal include file, put this function in it, so it will work for all your inn. First, create an area with 1 room per tile. In each room, place a waypoint. To make this work, you must first choose a prefix for all your inn's waypoint (mine is "h_wpt_inn_"), and each single inn will have a unique ID (like "01","01".."FF"). Each waypoint from the same inn will have the exact same tag (example "h_wpt_inn_01" for all waypoints from a single inn). Returns FALSE if no room's free.

The Script
int InnRest(string aInnID,object aPC) { int bFoundPlace = FALSE; int iCounter = 1; object oWpt; object oPC; do { oWpt = GetObjectByTag("h_wpt_inn_" + aInnID,iCounter); if (oWpt != OBJECT_INVALID) {     // It can be easly modified to work with any char, not just PCs oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR,                              PLAYER_CHAR_IS_PC,                               oWpt); // If the room isn't 1 tile large, put another number instead of 5.0 if ((oPC==OBJECT_INVALID) || (GetDistanceBetween(oWpt,oPC) > 5.0)) bFoundPlace = TRUE; }  iCounter++; } while ((!bFoundPlace) && (oWpt != OBJECT_INVALID)); if (bFoundPlace) {   AssignCommand(aPC,ClearAllActions); if (oWpt != OBJECT_INVALID) AssignCommand(aPC,ActionJumpToObject(oWpt)); AssignCommand(aPC,DelayCommand(3.0,ActionRest)); } return bFoundPlace; }

NOTE
THIS IS AN INCLUDE FILE TO BE USED WITH OTHER INN SCRIPTS…HERE IS A void main AS AN EXAMPLE

void main { object oPC = GetPCSpeaker; if (InnRest("01",oPC)) TakeGoldFromCreature(10,oPC); else ActionSpeakString("You don't have enough money!"); }