Ok, this is gonna be confusing, I'll explain it in detail if you'd like to know how each part is working, but for starters I'll just give you a method for getting this done.
Assume that Game Variable 1 is holding the Actor's ID
Assume that Game Variable 2 is holding the ID of the Skill you're checking for.
Create a conditional branch. It's condition will be a script call. The script call is as follows
$gameActors.actor($gameVariables.value(1)).skills().length <= 4
The above script call checks to make sure that 4 skills are learned. It may vary for you, depending on whether or not you have the Attack or Defend skills enabled for certain actors. My actor has Attack learned, so I used <= 4 instead of == 4, to accomodate for that. It may be different for your situation.
INSIDE of that conditional Block, create another conditional branch, with a script call condition. The script call is as follows
$gameActors.actor($gameVariables.value(1)).skills().filter(function(obj){return obj.id == $gameVariables.value(2)}).length == 0
This filters the array of skills and returns an array of all of the skills whose id matches the one stored in Game Variable 2. If the list is longer than
0, it means a match was found. Meaning this skill is already learned by that actor.
Finally, INSIDE of the
that conditional block, you add the skill.
Select the Script command on the third tab of the event commands and enter the following
$gameActors.actor($gameVariables.value(1)).learnSkill($gameVariables.value(2));
The above line adds the skill with with the id store in variable 2 to the actor, whose id is stored in variable 1.
Make sense?
EDIT: Since this
is in the Learning JavaScript Boards, I'll gladly explain what's going on in detail there, for example the .filter method if you aren't familiar.