Variable equal to party's total level

hello community!
I'm trying to make Etrian Odyssey remake in VX Ace
but I'm having trouble in Inn event
I want to make the variable equal to party's total level
because the cost of staying at the Inn
on that game is party's total level x 2
(but I think it's the 1st 4 members' total level only)

I know how to make it when party leader's level only
but I don't know what to do when party's total level.

thanks in advance!
If your group has fixed members it is easy. I mean, if you know exactly which members will be on the team, just set individual variables with the level of each, then add them up and multiply the result. I had to create something similar to set the average team level. This is what I use to restrict certain areas according to the "strength" of the player. The commands are almost identical. Look:

QVbzvY9.png


Membros na Equipe means the number of team members. Now, if you do not know which characters might be in the group, you'd have to figure it out first. Create another variable to find the ID of the members in a given position. One by one you discover the ID, compare it with your ID in the database - by means of a condition - and set the character's level in the corresponding variables. Here you check the ID of the characters in the group:

Spoiler
l3olxEg.png
If you don't mind installing Yanfly's Enemy Level script, you can use this code instead:

Control variables: Variable (whatever you want to use);

Script: $game_party.average_level

However, you need Yanfly's Enemy Level Script to use that command, as average_level doesn't exist outside of it. Though, if you just install this code in a script, it will still work:

class Game_Party < Game_Unit
#Average level function is from Yanfly's Enemy Levels script (thanks Yanfly!),
#Pasted here so as to not require the enemy level script for this script to work.
def average_level
lv = 0
for member in all_members; lv += member.level; end
lv /= all_members.size
return lv
end

end #End Game_Party Class

Credit Yanfly as it is their code (as you can see per the comments), I just pulled it out of their enemy level script for you. Yanfly's terms of use are posted here: https://yanflychannel.wordpress.com/terms-of-use/
Making a few changes from Faherya's example, here's what you can try:
Code:
Control Variables 1 = Party Members //this will the number of current party members
Control Variables 2 == $game_party.members[0].level //this is the leader
Control Variables 2 += $game_party.members[1].level //this is the 1st follower
Control Variables 2 += $game_party.members[2].level //this is the 2nd follower
Control Variables 2 += $game_party.members[3].level //this is the 3rd follower

If Control Variables 1 == 1
   Control Variables 2 == $game_party.members[0].level
end/else
If Control Variables 1 == 2
   Control Variables 2 == $game_party.members[0].level
   Control Variables 2 += $game_party.members[1].level
end/else
If Control Variables 1 == 3
   Control Variables 2 == $game_party.members[0].level
   Control Variables 2 += $game_party.members[1].level
   Control Variables 2 += $game_party.members[2].level
end/else
If Control Variables 1 == 4
   Control Variables 2 == $game_party.members[0].level
   Control Variables 2 += $game_party.members[1].level
   Control Variables 2 += $game_party.members[2].level
   Control Variables 2 += $game_party.members[3].level
end //and so on...

//Variables 1 and the Conditional Branches will not be necessary if you have a fixed amount of party members in your party. The conditional branches are there to prevent the game from throwing an error in case the number of party members are less than the script is trying to call.

From there, you can take Variable 2 and multiply it to get your Inn cost.
The only reason why I had to change Variable 2 multiple times is because the script box in "Control Variables" accepts a limited amount of letters.
thanks for the replies
I did susan's method and it worked!
using a conditional branch, if members are 5 or more,
it should be If control variables is 4 or greater.

Original thread: https://forums.rpgmakerweb.com/threads/variable-equal-to-partys-total-level.83227/