How to check if the player have x item?

So i want to make a mining system. First, I need to check if the player have a pickaxe, if yes then the player can dig stuff.
Second, the digging spot will be gone after 3 tries ( after digging 3 times, it cant be digged anymore until player go to worldmap )
Third, the materials that can be digged have different difficulty to get. For example bronze ore - 90% chance and iron ore - 10% chance. You can only get 1 item
Any suggestion?

Edit : Already know how to do 1 and 2, now the 3 one im stuck. Ho do you generate random item probability?
Code:
$gameParty.hasItem($dataItems[itemId])

Use the above script in a conditional branch to check for pickaxe. Pickaxe is an item, right? Not a weapon? And do you require the player to equip it? If so, then use the later script call.

Code:
$gameParty.leader().equips()[0] && ($gameParty.leader().equips()[0].id === pickaxeId)

For the 3 tries thing, have a variable increase every time the player digs the spot. If you don't like wasting your variables on something so trivial, you could use a self variable plugin (Yanfly or Hime). After the variable hits 3, flip a self-switch to disable the event.

As for the percentage chance, under the game's Control Variables, there's a random number generator. Just roll a random number from 1-10, and check if the variable value is 1-9 (i.e. variable < 10, 90% chance), then give bronze ore. If the value is 10 (10% chance), give iron ore.

EDIT: didn't see your edit 😛
You can generate random item probability with variables. I'm currently doing that with both my "Thieving" and "Pillaging" system.

Just create a variable named something like, "Ore Chance" and then tell the game to roll a random number on that variable between two numbers. You then just create a conditional branch for each item.

"If Ore Chance is 72 or less"
"Give player 1 Copper Ore."
Else Case:
"If Ore Chance is 73 or greater"
"Give player 1 Iron Ore."

I'm including a screenshot for you of my own method of doing it. Keep in mind, much of this is extraneous information due to it being rolled for a chest opening. The basics of how to handle the variable and the event are there, however.
upload_2017-10-5_1-9-56.png
Thanks for the help! Solved my problems

Original thread: https://forums.rpgmakerweb.com/threads/how-to-check-if-the-player-have-x-item.85237/