Ammo

Started by Xmair, Sep 25, 2015, 05:24 AM

Previous topic - Next topic

Xmair

I know this is a bit stupid but still, How to + the ammo of someone when he already is carrying the weapon?
Tried using the player.Ammo+= but it gives error lol

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

Thijn

Use a combination of player.GetAmmoAtSlot and player.GiveWeapon.
Let's say you want to give 100 stubby ammo.

local currentAmmo = player.GetAmmoAtSlot( 5 );
player.GiveWeapon( 21, currentAmmo + 100 );
Untested

Note there's also a function called player.GetWeaponAtSlot. So you can just give 100 ammo of whatever weapon the player is holding in a particular slot.

Xmair

Will this work? player.SetWeapon(32,player.Ammo.tointeger() 1500);

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

Xmair

Just tested it, and it worked. Locked and marked as solved.

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

Thijn

Quote from: Xmair on Sep 25, 2015, 08:08 AMWill this work? player.SetWeapon(32,player.Ammo.tointeger() 1500);
I doubt that will work if you have another weapon current equipped. It will that ammo, not the weapon you want to increase.