Aller au contenu

Photo

How do I clean up a module when the player leaves it


  • Veuillez vous connecter pour répondre
4 réponses à ce sujet

#1
Darin

Darin
  • Members
  • 282 messages

on Client Leave isn't working, nor in an action on conversation when in the transfer conversation.  Trying to run a script that limbos/removes all the npcs when the player leaves a module (to cut down on overhead).  is there a way to run when the player leaves the module?  (I know the general code works, since when I run it on the PC it removes the extra npcs that running the onclient on the pc created).

 

 



#2
Tchos

Tchos
  • Members
  • 5 063 messages

Correct me if I'm wrong, but my impression is that when you leave a module, nothing in that module is running anymore, because only one module is loaded into memory at a time.



#3
Darin

Darin
  • Members
  • 282 messages

You may be right, but for some reason I thought otherwise... if they are still doing something, it's minor in comparison to whatever the current module is doing, but I'm not 100% on that.



#4
AGhost_7

AGhost_7
  • Members
  • 62 messages

If you still want to test it out here's what I think you'll need to do:

 

object oArea = GetFirstArea();
object oNPC;
while(GetIsObjectValid(oArea))
{
    oNPC = GetFirstObjectInArea(oArea);
    while(GetIsObjectValid(oNPC))
    {
        if(GetObjectType(oNPC) == OBJECT_TYPE_CREATURE 
            && !GetIsPC(oNPC))
        {
            // Place your logic to send the creatures
            // or to destroy them
        }
        oNPC = GetNextObjectInArea(oArea);
    }
    oArea = GetNextArea();
}


#5
Loki_999

Loki_999
  • Members
  • 430 messages

You could try attaching to the on area exit event.  I think this also fires when you quit.