Jump to content

Missiongroup and cleanup


Hodo33

Recommended Posts

As @Happenstance missionGroup gets deleted when the server ends. If you want a parentgroup which lasts through multiple missions you can test to see if it needs creating at either missionLoad/StartGame or mainMenu::onWake().


I tend to have a check in mainMenu::onWake() and create the group if it does not already exist or empty all the objects if the group is found (eg: you're back at the mainMenu because the whole game is over, so delete all the data that you've been saving in the group which will mostly be scriptObjects)


eg:

function MainMenuGui::onWake(%this)
{
   %group = masterCleanUp;
   if(!isObject(%group))
   {
      %strat = new SimGroup(masterCleanUp);
		echo("\c4New masterCleanUp");
	}
	else
	{
      %count = %group.getCount();
	   echo("\c4masterCleanUp already exists, empty it " @ %count);
	   if(%count > 0)
	   {
	      while(%count != 0)
	      {
	         %index = %group.getObject(0);
	         if(isObject(%index))
	         {
	            //echo("deleting " @ %index SPC %index.getName());
	            %index.delete();
	         }
 
	         //remember the escape
	         %count = %group.getCount();
	      }
	      echo("masterCleanUp emptied");
	   }
	}
}

 

Using that while() loop is actually a terrible way of doing this but hey :lol:


edit: should just use %group.deleteAllObjects();

 

function MainMenuGui::onWake(%this)
{
   %group = masterCleanUp;
   if(!isObject(%group))
   {
      %strat = new SimGroup(masterCleanUp);
		echo("\c4New masterCleanUp");
	}
	else
	{
      %count = %group.getCount();
	   echo("\c4masterCleanUp already exists, empty it " @ %count);
	   if(%count > 0)
	   {
	      %group.deleteAllObjects();
	      echo("masterCleanUp emptied");
	   }
	}
}

 

I'm gonna go change my code now ... :oops:

Link to comment
Share on other sites

simSets are lists of refs. simGroups are lists of actual objects. Kill a set, all you're doing is killing of a bunch of pointers. kill a group, everything's gone. (it's why stuff can be in multiple sets, but only one group)

Edited by Azaezel
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...