Author Sticky: Post Working Scripts Here
Dishonru Posted: Monday, 24 June 02:07AM
NPC yell something to you when you come into their range

Inside of the OnSpawn script un-comment the line that has //Optional behavior - Fire User Defined Event 1002, then do save as and use that for the npc you want to speak.

Then for the OnUserDefined add this:

NWScript:
int nUser = GetUserDefinedEventNumber();

if(nUser == 1002)

{

if (GetLocalInt(OBJECT_SELF, "spoken") != 2)

{

SpeakString("Leave me alone, peasant");

SetLocalInt(OBJECT_SELF,"spoken",2);

}

}



And then save it as whatever and use it for that npcs user defined. It results in the npc yelling out "Leave me alone, peasant" when you enter his perception. It only happens once.