I have this script for spawning a creature on the onenter script for my .are file:
void main() {
CreateObject(OBJECT_TYPE_CREATURE, "n_xyz", Location(Vector(6.00,-62.06,11.02), 0.0));
object oNPC = GetObjectByTag("xyz");
object oItem = CreateItemOnObject("mask", oNPC);
AssignCommand(oNPC, ActionEquipItem(oItem, INVENTORY_SLOT_HEAD, TRUE));
}
I only want the creature to spawn the first time you enter the module. I assume I need to establish a local variable/boolean. How do I modify this script to do that. Just fyi, the spawned npc will be killed in battle after entering the first time.
You can do it with local variables/booleans are the easiest. I personally like to use booleans since I can see all the variables that I'm working with. So you need to open globalcat.2da file and add a new boolean at the bottom.
Then you need to change your script to something like this:
void main () {
if (GetGlobalBoolean("boolean name") == TRUE) {
CreateObject(OBJECT_TYPE_CREATURE, "n_xyz", Location(Vector(6.00,-62.06,11.02), 0.0));
object oNPC = GetObjectByTag("xyz");
object oItem = CreateItemOnObject("mask", oNPC);
AssignCommand(oNPC, ActionEquipItem(oItem, INVENTORY_SLOT_HEAD, TRUE));
SetGlobalBoolean("same boolean name", FALSE); }
}
You must somehow make the boolean say True, they always start out as false. Then attack this script to the onEnter field in the .are file. At that point the npc is spawned and then the boolean is set back to False so that when you re-enter the module, you don't see two npcs.
Yell at me if this doesn't do what you want, good luck chief.
Try this it will check and see of the creature exists in the module before spawning him so it will only create him once.
void main() {
object object1 = GetObjectByTag("creatures tag", 0);
if ((!GetIsObjectValid(object1))) {
CreateObject(OBJECT_TYPE_CREATURE, "n_xyz", Location(Vector(6.00,-62.06,11.02), 0.0));
object oNPC = GetObjectByTag("xyz");
object oItem = CreateItemOnObject("mask", oNPC);
AssignCommand(oNPC, ActionEquipItem(oItem, INVENTORY_SLOT_HEAD, TRUE));
}
Thanks guys....I got it working.