Jump to content

Home

Making something spawn once through heartbeat tag?


Canderis

Recommended Posts

Posted

If I put in a modified version of the OnHeartBeat to spawn something will it keep spawning or will it only spawn once? If it does spawn more than one how can I make it so it does only spawn once in that module?

Posted

You can add a conditional before spawning to check for the existence of the object, something like this:

 

void main() {
  if( GetObjectByTag( "xxxxx" ) == OBJECT_INVALID ) {
  // Spawn Stuff
  }
}

 

xxxxx is the tag of the item you want to spawn.

 

- Star Admiral

Posted

The check didn't work they kept spawning. But at least they spawned. They didn't before...

 

  if( GetObjectByTag( "p_t4m8" ) == OBJECT_INVALID ) {
  // Spawn Stuff
  CreateObject( OBJECT_TYPE_CREATURE, "p_t4m8", GetLocation(GetFirstPC())); 
  }

This is also only a part of the whole script, i decided not to post that cuz its the default heartbeat stuff.

 

EDIT: This is for k1

Posted

Is the creature supposed to be a puppet of some sort? And does the creature not respawn when you re-enter a module you already visited, or does the creature not respawn when you enter all modules?

 

- Star Admiral

Posted

I'm not sure if its a script problem or not. Could you change the heartbeat script to something like this:

 

SendMessageToPC( GetFirstPC(), "I did not spawn." );
if( GetObjectByTag( "p_t4m8" ) == OBJECT_INVALID ) {
  CreateObject( OBJECT_TYPE_CREATURE, "p_t4m8", GetLocation(GetFirstPC()));
  SendMessageToPC( GetFirstPC(), "I spawned." );
}

 

Which of the two messages shows up in your feedback page?

 

- Star Admiral

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...