Friend, help with advice! All with the same trigger in the Rest Area. I want the character, when I went into it, start to itch, well, loop through the animation …
AssignCommand (oPC, ActionPlayAnimation (ANIMATION_FIREFORGET_PAUSE_SCRATCH_HEAD, 1.0,1.0));
And he finished playing it when he left the zone.
How to create a create loop on an entry trigger? And how to stop it on exiting the trigger?
On Entry:
void main()
{
object oPC = GetEnteringObject();
if (!GetIsPC(oPC)) return;
object oRe = OBJECT_SELF;
SetLocalInt (oRe, "IN", TRUE);
if (GetLocalInt(oRe, "ENABLED") != TRUE)
{
FloatingTextStringOnCreature("Я должн спросить разрешение на отдых.", oPC, FALSE);
return;
}
SetLocalInt(oPC, "RESTZONE", 1);
FloatingTextStringOnCreature("Вы в зоне отдыха. Можно отдыхать.", oPC, FALSE);
string sMess = GetName(oRe);
if (sMess == "") return;
DelayCommand(1.4, AssignCommand(oPC, SpeakString(sMess)));
}
On Exit:
void main()
{
object oPC = GetExitingObject();
if (!GetIsPC(oPC)) return;
object oRe = OBJECT_SELF;
SetLocalInt (oRe, "IN", FALSE);
if (GetLocalInt(oRe, "ENABLED") != TRUE) return;
DeleteLocalInt(oRe, "ENABLED");
DeleteLocalInt(oPC, "RESTZONE");
AssignCommand(oPC,ActionPlayAnimation(ANIMATION_FIREFORGET_PAUSE_SCRATCH_HEAD,1.0,1.0));
FloatingTextStringOnCreature("Фу, воняет!.. Как бы не подхватить чего...", oPC);
}
This is what I need? 
For Loop: https://nwnlexicon.com/index.php?title=For_Loop
Do Loop: https://nwnlexicon.com/index.php?title=Do_Loop
or While Loop: https://nwnlexicon.com/index.php?title=While_Loop
I created Do Loop in Entry, but it does not work…
void main()
{
object oPC = GetEnteringObject();
if (!GetIsPC(oPC)) return;
object oRe = OBJECT_SELF;
SetLocalInt (oRe, "IN", TRUE);
if (GetLocalInt(oRe, "ENABLED") != TRUE)
{
FloatingTextStringOnCreature("Я должн спросить разрешение на отдых.", oPC, FALSE);
return;
}
SetLocalInt(oPC, "RESTZONE", 1);
FloatingTextStringOnCreature("Вы в зоне отдыха. Можно отдыхать.", oPC, FALSE);
string sMess = GetName(oRe);
if (sMess == "") return;
DelayCommand(1.4, AssignCommand(oPC, SpeakString(sMess)));
return;
int i;
do
{
PrintInteger(i);
AssignCommand (oPC, ActionPlayAnimation (ANIMATION_FIREFORGET_PAUSE_SCRATCH_HEAD, 1.0,1.0));
AssignCommand (oPC, ActionWait (2.0));
i++;
} while (i < 5);
}