GainTP; How to use it?

Greetings and salutations, scholars and sages of RPG Maker forums!
I was trying to make a little more complex damage formulas lately, with help of the "Damage Formulas 101" thread, when I stumbled upon "GainTP" command. Ever since then, I have been trying to use it but it never seems to work. Since I always mess up somewhere when making formulas, I hope you could help me.

The formula looks as follows.

if (a.isStateAffected(26)) { a.gainTP(30); a.mat * 2 } else { a.gainTP(15); a.mat }

The idea behind it, is that this ability would affect all allies and add MP alongside TP. I realize the "a." before "gainTP" has no place, as it would apply the boost only to the caster. It was just a desperate attempt at fixing the issue.
I thank for all the responses in advance.
it's "gainTp" not "gainTP".
If you want to give all alive allies mp/tp you could try this adding this in your formula.

JavaScript:
// All alive allies in the party gain Mp
$gameParty.aliveMembers().forEach(member => member.gainMp(10));

// All alive allies in the party gain Tp
$gameParty.aliveMembers().forEach(member => member.gainTp(10));
it's "gainTp" not "gainTP".
If you want to give all alive allies mp/tp you could try this adding this in your formula.

JavaScript:
// All alive allies in the party gain Mp
$gameParty.aliveMembers().forEach(member => member.gainMp(10));

// All alive allies in the party gain Tp
$gameParty.aliveMembers().forEach(member => member.gainTp(10));
What if I wanted it to add both Mp and Tp? Do I put the other code and tie them together with an &&?
Do be wary about using game mechanics within the damage formula, though; as this article: http://www.yanfly.moe/wiki/Stop_Putting_Mechanics_in_Damage_Formulas explains, if you're not careful your mechanics will trigger when you don't want them to, as the game will automatically run the damage formulae to see who should be targeted, etc.
What if I wanted it to add both Mp and Tp? Do I put the other code and tie them together with an &&?
No, you just separate them with a ";".
"&&" is used for conditional checks, so you won't be needing it in this case.

Original thread: https://forums.rpgmakerweb.com/threads/gaintp-how-to-use-it.174089/