Remove all party members but the actor

ive been looking for a script to remove all party members except the main actor during certain events. The game consists of a few different characters and at times it will require the party to be cleared except for a single character. so is there a script call that can help me accomplish this
I have moved this thread from RGSS3 Scripts (RMVX Ace) to RGSS3 Script Requests.
Do you mean the party leader? Or a designated actor? Ie, Actor 1 in the database.
There's no single script call you can use because Game_Party's @actors variable isn't exposed outwith the class. If you wanted a script-based solution, you could do:

Ruby:
$game_party.members.each_with_index { |member, index|
  $game_party.remove_actor(member.id) if index > 0
}
If you prefer to add a snippet that will let you use a short script call, here's a solution:

FIXED & EXPANDED

Both are based on that actor's current position starting at 0.

Without Refresh
Ruby:
class Game_Party
  def one_member_only!(n=0)
    @actors = [@actors[n]]
  end
end

With Refresh Included
Ruby:
class Game_Party
  def one_member_only!(n=0)
    @actors = [@actors[n]]
    $game_player.refresh
    $game_map.need_refresh = true
  end
end

Keep the leader:
$game_party.one_member_only!

Keep another member:
$game_party.one_member_only!(2)
If you prefer to add a snippet that will let you use a short script call, here's a solution:

Ruby:
class Game_Party
  def keep_leader_only!
    @actors = @actors[0]
  end
end

$game_party.keep_leader_only!
If you're going down that route you should probably add a player and map refresh like remove_actor does, or I don't think the followers will update properly when you call it.

Edit: It actually causes a crash, though I'm not sure why as I thought that would work too.
1706054860198.png


What does work is this:

Ruby:
def keep_leader_only!
    @actors = @actors.take(1)
    $game_player.refresh
    $game_map.need_refresh = true
  end

Ohh. The reason yours didn't work is that you turned it from an array into a single value. It would have worked if you'd put @actors = [@actors[0]]
Well, I included the edited version to allow the player to refresh the visual part of the game.
If for any unforeseen reason the game developer doesn't need to do that, there's still the original version on my previous post. Yet, I won't be held responsible for any inconsistencies the dev might find later on.

EDIT

I forgot to use the square brackets there...
Yes, Trihan, I knew that the moment I checked that there was just an Integer assignment being done there. Just a minor inconvenience that can be easily spotted after thinking about it for a few moments.
Well, I included the edited version to allow the player to refresh the visual part of the game.
If for any unforeseen reason the game developer doesn't need to do that, there's still the original version on my previous post. Yet, I won't be held responsible for any inconsistencies the dev might find later on.

EDIT

I forgot to use the square brackets there...
Yes, Trihan, I knew that the moment I checked that there was just an Integer assignment being done there. Just a minor inconvenience that can be easily spotted after thinking about it for a few moments.
Yes, which is what I did and how I also came to the same conclusion as you did. You realised and edited it, so it's all good and we've provided OP with two potential solutions to the query. Go us.
I even expanded the scriptlet because I can't tell for sure whether the actor being kept in the OP's game will always be the so called leader of the gang or not. So now it's possible to keep anybody else as well. It's based on that actor's current position starting at 0.
I even expanded the scriptlet because I can't tell for sure whether the actor being kept in the OP's game will always be the so called leader of the gang or not. So now it's possible to keep anybody else as well. It's based on that actor's current position starting at 0.
Good idea. Between us I think we've provided every possible angle of attack on this. 😛
man i left and came back and you guys did this so fast! i appreciate it, you guys are amazing! im going to test these out now!

EDIT
the solutions work great. thanks guys!
Adding and removing characters from the party can be done in events, you don't need a script unless you have a reason specifically to use a script instead of the event.
Adding and removing characters from the party can be done in events, you don't need a script unless you have a reason specifically to use a script instead of the event.
Presumably to have something easily reusable that doesn't require several event commands.

The remove party member event command also requires a specific ID for the member you're taking out, so there's no easy way to make that work to remove "all but the party leader" unless you specifically know who's in the party and in what order. To get a specific party index, you need to use a script, at which point it's far easier to use either kyonides's or my solution.
The remove party member event command also requires a specific ID for the member you're taking out, so there's no easy way to make that work to remove "all but the party leader" unless you specifically know who's in the party and in what order.

Ah! Yeah, that makes sense
additionaloly, if you need such thing often you might want to consider using Tsukihime's party manager.
that allows you to define several different parties and switch between them, which might be even easier than removing and adding actors all the time.
Ah! Yeah, that makes sense
yeah as Trihan said that was my issue especially considering any actor can be in the party at any given moment, the script was a easy quick solution to accomplish what i needed

Original thread: https://forums.rpgmakerweb.com/threads/remove-all-party-members-but-the-actor.165071/