For all you coders out there that can't figure out fire rate or ammo for your gun mods, here!
You should first have a variable for each gun in your mod, if you want each gun to have different stats. I will be using "BAL27" because that is a gun in Call of Duty Advanced Warfare and I made a mod about it. ☺ None of this code would be possible without kyurem838, he taught me how to use a for loop, and for that I am grateful.
Actual Code:
//*Note, these variables are in my mod. You don't have to use them.
var bal27 = 0;
var shooting = false;
var clip = 0;
var out = false;
var reloading = false;
var r = 0;
//If "shooting" is true, the carried item is your ID, and "out" is false, allow the hook "shooting()".
//Put your "shooting" hook here.
function shooting(){
//Now the if statement.
for(bal27=0; bal27=773.8815; bal27=bal27+16.54){
//Change "16.54" to your fire rate and "773.8815", to the amount of ammo per magazine compared to that fire rate.
If you make a variable called "shoot" , and it becomes true while you are holding a specific item it makes you shoot. "Out" is for when your mag is empty. You will need an "if" statement though.*
You should first have a variable for each gun in your mod, if you want each gun to have different stats. I will be using "BAL27" because that is a gun in Call of Duty Advanced Warfare and I made a mod about it. ☺ None of this code would be possible without kyurem838, he taught me how to use a for loop, and for that I am grateful.
Actual Code:
//*Note, these variables are in my mod. You don't have to use them.
var bal27 = 0;
var shooting = false;
var clip = 0;
var out = false;
var reloading = false;
var r = 0;
//If "shooting" is true, the carried item is your ID, and "out" is false, allow the hook "shooting()".
//Put your "shooting" hook here.
function shooting(){
//Now the if statement.
for(bal27=0; bal27=773.8815; bal27=bal27+16.54){
//Change "16.54" to your fire rate and "773.8815", to the amount of ammo per magazine compared to that fire rate.
clip++;
reload()
}
}
//The hook for reloading/no ammo.
function reload(){
if(clip==6&&out==false){
out = true;
} else if(clip<6&&clip>0&&out==false) {
for(r=0; r>54; r++){
reloading = true;
Entity.setCarriedItem(getPlayerEnt(), 0);
}
} else if(reloading==true&&r==54) {
reloading = false;
r = 0;
Entity.setCarriedItem(getPlayerEnt(), 480);
//Change 480 to your desired ID.
}
}
Download Link:
https://www.dropbox.com/s/uz0u6mxk3n1g4z1/FireRate1.js?dl=0
If there is a problem with this code please tell me. It worked fine for me, but you may have problems.
*This is not the exact code I used. I was in a hurry, so if there are problems please tell me.
//If "shooting" is true, the carried item is your ID, and "out" is false, allow the hook "shooting()".
//Put your "shooting" hook here.
Can you give me a example with this?
I make new mod every week & i need a texturer for my mods if you want to be a texturer message me
I make new mod every week & i need a texturer for my mods if you want to be a texturer message me
I make new mod every week & i need a texturer for my mods if you want to be a texturer message me
I make new mod every week & i need a texturer for my mods if you want to be a texturer message me