Get Actor ID of first party member?

I'm trying to make a simple plugin, any idea what the syntax is to get the Actor ID of the first member in the player's party?
$gameParty.leader().actorId()
$gameParty.leader().actorId()

Thanks.
$gameParty.leader().actorId()

Just tried it in a plugin, it doesn't seem to be doing anything.

Code:
$gameVarables.setValue(10, $gameParty.leader().actorId())
Just tried it in a plugin, it doesn't seem to be doing anything.



$gameVarables.setValue(10, $gameParty.leader().actorId())



Make sure to spell variables correctly. And make sure to use that in 'script' event command and not 'plugin' event command


$gameVariables.setValue(10,$gameParty.leader().actorId());
Make sure to spell variables correctly. And make sure to use that in 'script' event command and not 'plugin' event command


$gameVariables.setValue(10,$gameParty.leader().actorId());

Got it working via a plugin.
it's not a plugin though.  That's a script call.  If you got it to work via a plugin call, you're lucky, but you could just as easily have other problems with it.


You could also have done this with the Control Variables event command - you don't need to use either a plugin or a script call: Control Variables > Game Data> Party Member #1's Actor ID
it's not a plugin though.  That's a script call.  If you got it to work via a plugin call, you're lucky, but you could just as easily have other problems with it.


You could also have done this with the Control Variables event command - you don't need to use either a plugin or a script call: Control Variables > Game Data> Party Member #1's Actor ID

Yeah. But I needed a plugin that constantly sets a variable of choice to the first leader of the party. Should I release my work? I kinda edited another plugin to see how RPG Maker MV initalizes it, but I just deleted the code from that and inserted mine.
But I needed a plugin that constantly sets a variable of choice to the first leader of the party.

Why code that way? That would only cause lag, and the formation doesn't change by itself.


Formation can only be changed by event commands (in which case you could add the control variable there) or by formation screen (either original or a plugin replacement for it).


So it would be much easier to check if the formation command was used (for example by adding a command to switch ON a special game switch whenever that command is accessed) and then condition a common event autorun to exactly that switch, loading the ID once and then switching itself off again.
Why code that way? That would only cause lag, and the formation doesn't change by itself.


Formation can only be changed by event commands (in which case you could add the control variable there) or by formation screen (either original or a plugin replacement for it).


So it would be much easier to check if the formation command was used (for example by adding a command to switch ON a special game switch whenever that command is accessed) and then condition a common event autorun to exactly that switch, loading the ID once and then switching itself off again.

Ok
Why code that way? That would only cause lag, and the formation doesn't change by itself.


Formation can only be changed by event commands (in which case you could add the control variable there) or by formation screen (either original or a plugin replacement for it).


So it would be much easier to check if the formation command was used (for example by adding a command to switch ON a special game switch whenever that command is accessed) and then condition a common event autorun to exactly that switch, loading the ID once and then switching itself off again.



There's no guarantee that formation can't be changed through other means.


Of course, it isn't possible to future-proof code from any number of infinite possibilities, but I always recommend using $gameParty.swapOrder(index1, index2) to change formation, and would therefore execute my logic from that method, but there are a number of other common ways to change formation, such as


1. Directly editing the actors array (not recommended, but some people will probably do it for whatever reasons they may have)


2. Different way of determining leader

Original thread: https://forums.rpgmakerweb.com/threads/get-actor-id-of-first-party-member.60767/