Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
Capjerahya

identical weapon switching?

Recommended Posts

I have a script that runs in loop will switch player weapon to identical one and switch back.

Something like thing

_lastweap = primaryWeapon player
Player removeweapon _lastweap
Player addweapon "identical weapon"

;the reverse to return the last weapon

Problem is when I call this inside player init, I must press space everytime for it to recognize that I changed weapon. Worst part is weapon automaticaly reloads by it self giving me full clip after switching.

Does anyone have a solution for this? For the space pressing thingy I haven't tried selectweapon yet. But for the ammo thing I really like to keep the number of ammo in a clip everytime weapon is switched as if it's still the same weapon.

Thanks!

Share this post


Link to post
Share on other sites
I have a script that runs in loop will switch player weapon to identical one and switch back.

Something like thing

_lastweap = primaryWeapon player
Player removeweapon _lastweap
Player addweapon "identical weapon"

;the reverse to return the last weapon

Problem is when I call this inside player init, I must press space everytime for it to recognize that I changed weapon. Worst part is weapon automaticaly reloads by it self giving me full clip after switching.

Does anyone have a solution for this? For the space pressing thingy I haven't tried selectweapon yet. But for the ammo thing I really like to keep the number of ammo in a clip everytime weapon is switched as if it's still the same weapon.

Thanks!

after addweapon you need another line for "selectweapon"

Share this post


Link to post
Share on other sites

That fixed weapon selecting but I still couldn't think of a solution for the magazine thing. I have few ideas in mind but don't know how to emplement them and not certain if it does the trick.

1st idea I have is to use action take weapon from a weapon holder instantly without performing the animation. I remember using this idea before but I lost the script when my hard drive died. And I'm not sure if it does work.

2nd is still not certain solution and I don't know how to implement it aswell.

Idea is

check the number of mags player have for that weapon

Remove the magazines except for the one that has less ammo(I'm stuck here)

Remove weapon

Add weapon

Select weapon(so weapon is loaded with used mag)

Add the deleted mags.

3rd one is not efficient as it requires separate magazine class for the number of ammo left in a mag. 1 mag 30bullets=30 class. MG mag 100class. XD. Bad idea.

I find the 2nd solution more efficient but I'm stuck on how to implement it. Anyone know how to do the 1st and 2nd idea?

Edited by Capjerahya

Share this post


Link to post
Share on other sites

Ofp is limited in what you can do with this. Arma / A2 has more script options for weapons and magazines

Not tested but try this:

_lastweap = primaryWeapon player
_mags = magazines player
Player removeweapon _lastweap
Player removemagazines _mags
Player addweapon "identical weapon"
Player addMagazine "identical magzine";
or (Player addMagazine ["identical magazine", 4];)
player selectWeapon "identical weapon";

If you add the magazine after adding the weapon the selected weapon will come up empty and requires reloading. If magazine is added before the weapon then the weapon comes up with a full clip.

Edited by Zulu1

Share this post


Link to post
Share on other sites

I already used that. Apparently Ammo only tells the number of bullet in a mag, magazine tells the number of mags regardless of the ammo it has, to remove mag we use removemagazine which removes the magazine in the first array which is the one loaded to the current weapon. So it removes the one that I want to keep instead. I use remove and addweapon to change the weapon. New added weapon will always load a full mag first so used mag is ignored until player runs out of bullet.

I gave up to the 3D sight last time because I can't figure out how to prevent the weapon clipping. Now I finally manage to fix that issue and wen't back through the idea, another problem apears. :(

But I'm not ready to give yup yet. I may have to make a dummy magazine for each type of magazine that ain't compatible with the weapon. That way i just have to add one valid mag and change other mags with incompatible mags, and everytime player runs out of ammo and there are still available dummy mags in the inventory then script replace one with valid mag allowing player to reload.

That idea still has it's downside though. Player is unable to switch from half used mag to a full one. He should use all the rounds first before being able to reloading.

Share this post


Link to post
Share on other sites

There is sort of a bug in OFP when you change weapons you start with a full mag. I think the only time you can get a partial mag is when you pick up a weapon from a dead body where the soldier fired some rounds before he was killed.

Share this post


Link to post
Share on other sites

I know from the back of my head there is a way to pickup a weapon from a dead body without performing the animation. I have to go with dummy mags then.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×