Author Topic: How many times you use a weapon?  (Read 1756 times)

Is there a way to count the amount of times you use a weapon. I thought backwards energy starting from zero would work. But it regenerates and starts from 100... Any help is deeply appreciated.

Amount of times as in, fires? mounts? something else?

Amount of times you fire like a wand how many times you fire the wand


Use the onFire function to bump up a variable by one.

Basic onFire:

Code: [Select]
function WeaponImage::onFire(%this, %obj, %slot){}
%this is the datablock of the weapon calling the function
%obj is the player shooting the weapon
%slot is the slot in the inventory I think.

Make sure to change WeaponImage to your weapon's image otherwise it will effect all weapons, including hammer, wrench, printer etc.

Also, I'm not sure whether you have to parent and package it.

I have another way that I am using right now but I'll see which is better.  :cookie:

My idea: backwards energy usage giving +1 energy per fire. Is that good?

I would advise against it, if a player is playing in with fuel jet player then it would mess it up.

Yeah, you really need to do it using the onFire() method that MrPickle suggested.

I don't know how to do it using Pickle's method  :panda: He only gave me the onfire code too...

Make %obj.fires increase by one every time it fires:

%obj.fires++;

I'm gonna keep mine for now because it really works/looks good.