Several Merchant Skills

First of all apologyzes if this is not the place to set my questions, please move it if it's neccesary.

I am trying to create 2 differents skills, but I don't have too much knowledge of coding so I need help:

First is "All or Nothing", there's a 50% probabilities to make with double damage, and 50% with no damage.

In Ace I used this in the damage formula:

rand(100) >= 50 ? (a.atk * 4 - b.def * 2)*2 : 0but I think that now it doesn't work. How should I write a random in a damage formula?

Second is "Pay per cure", you heal an enemy and earn as much money as healed.

I set a Recover HP Skill with b.mhp in the formula, and used the Yanfly Engine Plugin - Skill Core to modify the amount of gold earned:

<Custom Execution>$gameParty.gainGold(target.mhp - target.hp);</Custom Execution>When I try in the game it says that "target" is not defined, but the attack has a range of "1 enemy"

Any help is welcome
Thank you  for all
I solved both question:
For the first situation just using the following code:

d = (Math.randomInt(100)); if (d > 50) {(a.atk * 4 - b.def * 2) * 2} else 0 For the second with this in the attack formula:

Code:
c=b.mhp - b.hp; $gameParty.gainGold(c); c

Original thread: https://forums.rpgmakerweb.com/threads/several-merchant-skills.53917/