I didn't read your code, just let me tell you how I kind of solved it: All possible weapons of the player are loaded at startup, then hide them. Every weapon has its shooting and reloading animations. Switching weapons will become as easy as showing and hiding a weapon. I added a "turn weapon out of view" job that is started as a polling process (fake parallel thread). When the current weapon is turned out of the camera view (some frames later), the current weapon becomes hidden and the wanted gun will unhide. This new current gun starts another polling process that will turn the weapon to the default aiming position. If all these parallel jobs are complete, the player may use the next gun. During switching weapons, they are deactivated.
Of course, instead if turning the guns away/back using some variables and polling jobs, you could also use a simple animation, "turn-mp5-outofview.b3d" or something. By checking the current animation state you could decide when to switch the guns effectively.
I hope this makes sense.
Of course, instead if turning the guns away/back using some variables and polling jobs, you could also use a simple animation, "turn-mp5-outofview.b3d" or something. By checking the current animation state you could decide when to switch the guns effectively.
I hope this makes sense.