Hi im new to programming but im needing help inside my if.
in the game it works it makes it so i dont have to reload and it sets the ammo amount everytime it reloads the gun, but once it gets to 0 ammo left it still reloads and freezes the game. this is what i have below.
Thanks for your time.
I am not try to criticize or help you but I feel your liberal use of * will make program maintenance much harder in future. Is it a pure C or C++ program? If C++, I am sure some of the pointer variables can be replaced with reference variables instead.
Well, on line 1/2 you ensure that 'NoReload9' and 'Ammo9' are actually 0. It does not make sense to check them against other values within that if clause where you know it's 0.
So the (*(int*)Ammo9 > 0) will never be true on line 4
Ok i have tryed to redo my code.
But what happens is when i get down to my last shot left the game freezes.
1 2 3 4 5 6
if((*(int*)NoReload9 == 0) && (*(int*)Ammo9 >= 10)){ //Checks If needs reload & Checks if ammo is more then 10 or =
if(SR25){ //Checks Weapon
*(int*)Ammo9 = *(int*)Ammo9-10; //Checks amount of ammo then takes 10 off
*(int*)NoReload9 = 10; //Sets amount of ammo in the gun
}
}
NoReload9 is the amount of ammo in gun
Ammo9 is the amount of ammo left to use, so really the ammo in the clip.