Author Topic: CreateObjectVoid() fires multiple times on Area OnEnter  (Read 393 times)

Legacy_Zeke

  • Jr. Member
  • **
  • Posts: 86
  • Karma: +0/-0
CreateObjectVoid() fires multiple times on Area OnEnter
« on: December 07, 2015, 09:33:52 pm »


               

It seems that when the following script is attached to an Area OnEnter event, it fires infinitely:



void CreateObjectVoid(int nObjectType, string sTemplate, location lLoc, int bUseAppearAnimation = FALSE)
{
    CreateObject(nObjectType, sTemplate, lLoc, bUseAppearAnimation);
}

void main()
{
    object oSpawn = GetWaypointByTag("WP_Spawn");
    location lSpawn = GetLocation(oSpawn);

    DelayCommand(0.4, CreateObjectVoid(OBJECT_TYPE_CREATURE, "cityguard", lSpawn));
}

Is this wanted behaviour?


 


Oh, and ff there is no DelayCommand() the game freezes on the loading screen...


               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
CreateObjectVoid() fires multiple times on Area OnEnter
« Reply #1 on: December 07, 2015, 09:52:57 pm »


               

Creating a creature in an area fires the on enter script I believe. Your results are not really that surprising...


 


If you want that to fire only if a PC enters you will want to check that before doing the spawn.



if (!GetIsPC(GetEnteringObject()) return;

Somewhere in main before you spawn should help.


               
               

               
            

Legacy_Zeke

  • Jr. Member
  • **
  • Posts: 86
  • Karma: +0/-0
CreateObjectVoid() fires multiple times on Area OnEnter
« Reply #2 on: December 07, 2015, 10:08:26 pm »


               

Oh.....


 


Sorry for the stupid question.


 


Thank you for the quick answer!