| Author |
Sticky:
Post Working Scripts Here |
|
Elwyn
|
Posted: Thursday, 27 June 07:25AM
|
// Script Name: Cheers // // This purpose of this script is to have the NPC's to recognize and greet them // when they enter a bar (or any other area...) // // There are two scripts needed. The first is used on the "OnEnter" Event of the area. // The second is placed on the OnPerception event of each patron who will recognize PC's. // // It uses the name of the PC as a Local for each NPC, so every time you enter the area, // you will receive a warm greeting where everybody knows your name. Norm!!! // by Chaz Mead
Area OnEnter Event script:
NWScript:
void main()
{
object oPC = GetEnteringObject();
string sName = GetName(oPC);
int i = 1;
object oCustomer = GetNearestCreature (CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_NOT_PC, oPC, i);
while (GetIsObjectValid(oCustomer))
{
SetLocalInt(oCustomer, sName, 0);
i = i + 1;
oCustomer = GetNearestCreature (CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_NOT_PC, oPC, i);
}
}
NPC OnPerception Script:
NWScript:
void main()
{
object oPC = GetLastPerceived();
string sName = GetName(oPC);
int BarState = GetLocalInt( OBJECT_SELF, sName);
if (BarState < 1)
{
switch(Random(4))
{
case 0:
ActionSpeakString ("Hello " + sName + "!");
break;
case 1:
ActionSpeakString ("Hey there " + sName + ".");
break;
case 2:
ActionSpeakString ("Welcome back " + sName + "!");
break;
case 3:
ActionSpeakString (sName + "!!!");
break;
}
SetLocalInt( OBJECT_SELF, sName, 1);
}
}
|
|