Keep current weapon ammo even when swapped?
#1

i've found this dayZ server i played like 1-2 months ago (forgot the specific name) And i like the concept where even if you change your weapon (with Q, E, NUMPAD ENTER and stuff) it still keeps the current ammo it has when you go back to it, for example:

i used up only 20 ammo on my M4A1, so i have 30 left. I swapped to my deagle, and swapped back to my M4A1 and still have 30 ammo left to shoot.

How do i do this? It is possibru as i saw it in another server
Reply
#2

Did you have only 20 ammo in the magazine (and only that mag) or still ammo left in total?

So if you have 150 ammo in total it shows 100-50. If you shoot 20 and switch forth and back it will show 80-50.
If the server however only gives you the ammo for the magazine it will be 0-30.
I guess that's how it was done, by simply only giving you one magazine for each weapon at once.

There's a way to achieve this actually, but it's kind of laggy.

Say the player has 30-30 M4 ammo (50 is the mag capacity) and switches to another gun, you save those values for later.
When he switches back, you remove 30 ammo using GivePlayerWeapon with a negative ammo value (so there is 30 ammo left, which makes it 0-30).
After that give the player 30 ammo using SetPlayerAmmo, which will add 30 to the "backpack" ammo and it will be 30-30 again.

GivePlayerWeapon will affect all ammo and also reload the gun. SetPlayerAmmo will only affect the "backpack" ammo so you can give someone ammo without reloading the gun. With the combination of these 2 you can do it.

The side effect however can be that when switching guns fast it will set your gun to M4 (because GivePlayerWeapon will switch your gun) or not be detected at all.

A much easier solution would be just giving the player one mag at a time, but not sure how you would implement reloading. On some DayZ servers I saw that you have to manually reload each mag which I find annoying, but it's a way to achieve it as well.
Reply
#3

Quote:

i used up only 20 ammo on my M4A1, so i have 30 left. I swapped to my deagle, and swapped back to my M4A1 and still have 30 ammo left to shoot.

Isn't that the default behavior?
Reply
#4

Quote:
Originally Posted by iLearner
Посмотреть сообщение
Isn't that the default behavior?
Weapons are reloaded when switching, if there is more ammo left. That's how 2-shoot and C-bugging without reloading works.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)