Reload code help
Moderator: InsideQC Admins
7 posts
• Page 1 of 1
Reload code help
Hey i added this reload code in and been trying to make it so when the gun starts reoading the player cannot shoot 3 seconds after the gun is reloaded. It doesn't work could someone help me here's the code
- Code: Select all
void() Reload =
{
local float x;//Establishes a float to calculate the shots fired.
local .float ammo_weapon;//Establishes a .float for the clip ammo.
local .float exam_weapon;//Establishes a .float for the inventory ammo.
if(self.weapon == IT_AUG)
{
x = (30 - self.ammo_aug);//Sets the float to the size of the clip, minus whatever is left in the gun.
self.ammo_weapon = self.ammo_aug;//The clip ammo is the clip ammo for the AUG.
self.exam_weapon = self.exam_aug;//The inventory ammo is the inventory ammo for the AUG.
self.attack_finished = time + 3;// 3 seconds till you can shoot again
}
else if(self.weapon == IT_M249)
{
x = (100 - self.ammo_m249); //Sets the float to the size of the clip, minus whatever is left in the gun.
self.ammo_weapon = self.ammo_m249; //The clip ammo is the clip ammo for the M249.
self.exam_weapon = self.exam_m249; //The inventory ammo is the inventory ammo for the M249.
}
//The part below actually adds the ammo back into the clip.
if(self.exam_weapon >= x)//If the inventory ammo is greater or equal to the shots fired.
{
self.ammo_weapon = (self.ammo_weapon + x);//Refills the weapon's clip.
self.exam_weapon = (self.exam_weapon - x);//Takes the shots fired away from the inventory.
}
else //If the inventory ammo is less than one full clip.
{
self.ammo_weapon = self.exam_weapon;//Sets the clip ammo to whatever the player has left.
self.exam_weapon = 0;//Sets his inventory ammo to zero.
}
W_SetCurrentAmmo();
return;
};
- sniperz227
- Posts: 112
- Joined: Sat Apr 09, 2011 3:19 am
that code doesn't support reload animations. Does anybody know how to add them?
It would be helpful for me too
It would be helpful for me too
- toneddu2000
- Posts: 1352
- Joined: Tue Feb 24, 2009 4:39 pm
- Location: Italy
It would have at least stopped him from attacking for 3 seconds with "self.attack_finished = time + 3" I talked to him on xbox live, he wasn't calling "Reload();" anywhere. I simply told him to have an ammo check in W_attack, if there is no ammo in the clip, don't shoot and reload.
- Ghost_Fang
- Posts: 336
- Joined: Thu Nov 12, 2009 4:37 am
toneddu2000 wrote:that code doesn't support reload animations. Does anybody know how to add them?
It would be helpful for me too
1. make an impulse do a certain animation
2. in that certain animation, make the last frame call your reload function
ie this is your animation code:
void() army_paind1 =[ $death1, army_paind2 ] {};
void() army_paind2 =[ $death2, army_paind3 ] {};
void() army_paind3 =[ $death3, army_paind4 ] {};
void() army_paind4 =[ $death4, army_paind5 ] {};
void() army_paind5 =[ $death5, army_paind6 ] {};
void() army_paind6 =[ $death6, army_paind7 ] {};
void() army_paind7 =[ $death5, army_paind8 ] {};
void() army_paind8 =[ $death4, army_paind9 ] {};
void() army_paind9 =[ $death3, army_paind10] {};
void() army_paind10=[ $death2, army_paind11] {};
void() army_paind11=[ $death1, army_paind12] {};
void() army_paind12=[ $painc1, army_paind13] {};
void() army_paind13=[ $painc2, army_paind14] {};
void() army_paind14=[ $painc3, army_paind15] {};
void() army_paind15=[ $painc4, army_paind16] {};
void() army_paind16=[ $painc5, army_paind17] {};
void() army_paind17=[ $painc4, army_paind18] {};
void() army_paind18=[ $painc3, army_paind19] {};
void() army_paind19=[ $painc2, army_paind20] {};
void() army_paind20=[ $painc1, army_run1] {PUTNAMEOFRELOADFUNCTIONHERE()};
make sure you define the function if you get an unknown error.
hope that helps
-

behind_you - Posts: 237
- Joined: Sat Feb 05, 2011 6:57 am
- Location: Tripoli, Libya
1. make an impulse do a certain animation
2. in that certain animation, make the last frame call your reload function
ie this is your animation code:
void() army_paind1 =[ $death1, army_paind2 ] {};
void() army_paind2 =[ $death2, army_paind3 ] {};
void() army_paind3 =[ $death3, army_paind4 ] {};
void() army_paind4 =[ $death4, army_paind5 ] {};
void() army_paind5 =[ $death5, army_paind6 ] {};
void() army_paind6 =[ $death6, army_paind7 ] {};
void() army_paind7 =[ $death5, army_paind8 ] {};
void() army_paind8 =[ $death4, army_paind9 ] {};
void() army_paind9 =[ $death3, army_paind10] {};
void() army_paind10=[ $death2, army_paind11] {};
void() army_paind11=[ $death1, army_paind12] {};
void() army_paind12=[ $painc1, army_paind13] {};
void() army_paind13=[ $painc2, army_paind14] {};
void() army_paind14=[ $painc3, army_paind15] {};
void() army_paind15=[ $painc4, army_paind16] {};
void() army_paind16=[ $painc5, army_paind17] {};
void() army_paind17=[ $painc4, army_paind18] {};
void() army_paind18=[ $painc3, army_paind19] {};
void() army_paind19=[ $painc2, army_paind20] {};
void() army_paind20=[ $painc1, army_run1] {PUTNAMEOFRELOADFUNCTIONHERE()};
make sure you define the function if you get an unknown error.
Thanks, I'll try it!
- toneddu2000
- Posts: 1352
- Joined: Tue Feb 24, 2009 4:39 pm
- Location: Italy
7 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest