its defined by the order in the entity file e.g.
NumWeapons 2
Weapon
WeaponType "Beam"
damageEnums
AttackType "CAPITALSHIP"
DamageAffectType "AFFECTS_SHIELDS_AND_HULL"
DamageApplyType "BACKLOADED"
DamageType "ENERGY"
WeaponClassType "BEAM"
DamagePerBank:FRONT 425.000000
DamagePerBank:BACK 0.000000
DamagePerBank:LEFT 0.000000
DamagePerBank:RIGHT 0.000000
Range 4800.000000
PreBuffCooldownTime 7.000000
CanFireAtFighter FALSE
SynchronizedTargeting TRUE
PointStaggerDelay 0.500000
TravelSpeed 0.000000
Duration 0.750000
Weapon
WeaponType "Projectile"
damageEnums
AttackType "ANTIVERYLIGHT"
DamageAffectType "AFFECTS_SHIELDS_AND_HULL"
DamageApplyType "BACKLOADED"
DamageType "ENERGY"
WeaponClassType "LASERPSI"
DamagePerBank:FRONT 79.500000
DamagePerBank:BACK 79.500000
DamagePerBank:LEFT 79.500000
DamagePerBank:RIGHT 79.500000
Range 4900.000000
PreBuffCooldownTime 6.000000
CanFireAtFighter TRUE
SynchronizedTargeting FALSE
PointStaggerDelay 0.200000
TravelSpeed 4000.000000
Duration 0.000000
For that example the "Beam" weapon is automatically assigned to the "Weapon-0" helpers, helperS because you have 1 "Weapon-0" helper you get one copy of the gun, 2 "Weapon-0" helpers and you get two copies of the gun, and so on.
The "Projectile" weapon is automatically assigned to the "Weapon-1" helpers, and works as i just explain
and similarly any third weapon would be assigned to "Weapon-2" helpers.
For each of the three possible weapons (3 is the max number of weapons, atleast i couldnt get 4 to work) you need to have the relevant helper on the mesh
EDIT: Removed superfluous coding to make it easier to look at