What's wrong with this encounter script?

I got bits and pieces of scripts and made this and was feeling very proud of myself when it compiled… But it doesn’t work !

void main()
object oPC=GetEnteringObject();
int nInt;
if (nInt<5)
  object oTrigger = OBJECT_SELF;
 string sEncounter = GetLocalString(oTrigger, "bsskel_docks");
 SetEncounterActive(TRUE, GetNearestObjectByTag(sEncounter));

Is there something missing ?

Is it the encounter trigger ? Are their settings on that which are important ? It’s not set to active and it’s a player only spawn once thing.

Is there a simpler way without the journal stuff that enables me to just activate it from another area ?

All suggestions welcomed like “stay away from scripting Tsongo you haven’t got a clue what you’re doing !”

I just noticed I put the \\C things in but it wont go in a box either ! I put in three of the \ but only two show up and I had to press the preformatted tab why is that ?

// Place this on the encounter trigger's OnEnter event.
// Ensure the encounter trigger's Active property is set to FALSE.

void main()
	object oPC = GetEnteringObject();
	if (!GetIsPC(oPC)) return;
	if (GetJournalEntry("city_ogres", oPC) == 5)
		TriggerEncounter(OBJECT_SELF, oPC, 0, -1.0f);

travus… Thanks that did the trick and looks so much simpler than my effort.

Has it got something to do with my one activating the trigger but you’re already in it so that counts as it’s once only and therefore nothing happens, but your script actually fires the trigger ?

That line be sure it’s set above 5 or you won’t pass your check.

Try to add SendMessageToPC("nint = " + IntToString(“nint” ));

To see if you set your value correctly.

The problem could also comme from ```
GetNearestObjectByTag(sEncounter), trigger can sometime be problematic if used as “nearest object”


The TriggerEncounter is necessary to fire the encounter in this case as your character is already in the trigger when this script fires to activate the trigger. Otherwise your character would have to move into it again in order to fire the encounter.


Shallina… Thanks for the info I like the idea of sending messages to see what’s going on and you could be right about the GetNearestObject… Then again I’m looking for excuses why my scripting masterpiece didn’t work.

travus… I ran into it a few times and it still didn’t work ! But I prefer your script, not just because it works but because it goes directly to the point…

Is it the player ? Have they done this ? Turn it on and fire… Short but sweet.

1 Like