I broke it up into separate functions, in case you wanted to store the variable in a different way, but something like this would work:
// Retrieves the string for storing visited areas.
string GetVisitedAreaList(object oPC);
// Saves the visited area list.
void SetVisitedAreaList(object oPC, string sList);
// Checks if the PC has entered that area before.
// returns FALSE if oPC is not a PC, or they aren't in a valid area.
// Area list is updated automatically if the area hasn't been visited before.
int GetPCFirstTimeEnteringArea(object oPC);
string GetVisitedAreaList(object oPC)
{
// Using PC skin method for the example.
object oSkin=GetItemInSlot(INVENTORY_SLOT_CARMOUR, oPC);
return GetLocalString(oSkin, "VISITED_AREA_LIST");
}
void SetVisitedAreaList(object oPC, string sList)
{
// Using PC skin method for the example.
object oSkin=GetItemInSlot(INVENTORY_SLOT_CARMOUR, oPC);
SetLocalString(oSkin, "VISITED_AREA_LIST", sList);
}
int GetPCFirstTimeEnteringArea(object oPC)
{
// Sanity checks. Must be a PC in a valid area, with a set (non-blank) tag.
if(!GetIsPC(oPC))return FALSE;
object oArea=GetArea(oPC);
if(oArea==OBJECT_INVALID)return FALSE;
string sTag=GetTag(oArea);
if(sTag=="")return FALSE;
string sList = GetVisitedAreaList(oPC);
// This will equal -1 if the area tag isn't found in the list,
if(FindSubString(sList, sTag)== -1)
{
SetVisitedAreaList(oPC, sList+"_"+sTag);
return TRUE;
}
return FALSE;
}
void main()
{
object oPC=GetEnteringObject();
// PC only exploration XP section.
// Function cotains PC only sanity check.
if(GetPCFirstTimeEnteringArea(oPC))
{
// Give 25 experience to the PC.
GiveXPToCreature(oPC, 25);
}
}
The main body would have to go into the area's OnEnter, though the other functions could stay above it in the same script or be moved into an include.