Item Regen on Weapon Equip

Hey everybody, I have a small request

The title says the basics of what I want to say, but there is a bit more to it.

I'm looking for a script that constantly keeps track of the PLAYER's weapon.  (This must be the Player, regardless of which actor serves as the current Player).  
When it finds out what weapon you have then it should check the script and add 'Item x' every 'y amount of frames' as long as that weapon is equipped.

I would like this to have a small area where I can edit and add weapons to script, a simple setup like this would do

(Weapon ID, Item to Regen ID, Item Amount, Frames Between Updates)
(01, 401, 3, 120)

This would make Weapon 1 when equipped add Item 401 x3 the inventory every 120 frames. (I use an ABS so my combat is all on the map, there is no battle scenes and you can attack many times per 60 frames depending on the weapon - if you're wondering why such a short frame time - I'm trying to make guns with self-recharging ammo as a perk)  
 
I have a similar solution.

Install the following script

http://himeworks.com/2013/03/event-page-conditions/

Make a common event that's a parallel process with a switch that will always be on (either a dummy switch or a switch that should be on by the point in the game in which you receive this gun) 

put in a comment

<page condition>then make a conditional script call

#Separate applicable ammo-regen-type weapons with commas and put in brackets[1,2,3,4,5,6].any? {|i| $game_party.members[0].equips[0] == $data_weapons}call the event command Wait 120 frame(s)

then, make the script call

case $game_party.members[0].equips[0].id #for weapons 1, 2, and 3, gain 3 basic bullets per 2 seconds when 1,2,3 $game_party.gain_item($data_items[1], 3) #for weapons 4,5, and 6, gain 2 heavy bullets per 2 seconds when 4,5,6 $game_party.gain_item($data_items[2], 2)endYou could adjust the wait time and the item obtain amount ratios as you see fit.

For example, you could make 4 second wait intervals but have larger ammo gain for each of those 4 seconds so that you could have more diversity in ammo gain rates.

The reason why referencing $game_system.playtime or Graphics.frame_count is undesirable is because that means that if you spent 120 frames/ 2 seconds on the main menu, you'd be able to get your ammo regen simply from that. So players could abuse this simply by doing a open menu->wait->exit->repeat exploit.
I appreciate the solution, but Common Events are part of my issue.

I currently have this as a full working Common Event already - the problem is the Wait Command creates a frame stutter every time it happens if set to Parallel Process, which is why I'm opting to try a purely scripted solution if I can.  

Additionally I get an error with a line referring to "Game Time" within your script. :/  I think because it is RGSS3 and VX uses RGSS2
Bumping because I know somebody out there is super awesome and probably capable of saving my game's framerate. 

This is one of the last 2 fixes I need to make it the experience I want it to be.  

I really need a script because parallel common events just do no play well with my ABS and other systems like weather, the frameskip lowers the quality of the game too much.  

Original thread: https://forums.rpgmakerweb.com/threads/item-regen-on-weapon-equip.43596/