Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: Xmair on Sep 25, 2015, 05:24 AM

Title: Ammo
Post by: Xmair on Sep 25, 2015, 05:24 AM
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
Title: Re: Ammo
Post by: Thijn on Sep 25, 2015, 05:46 AM
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.
Title: Re: Ammo
Post by: Xmair on Sep 25, 2015, 08:08 AM
Will this work? player.SetWeapon(32,player.Ammo.tointeger() 1500);
Title: Re: Ammo
Post by: Xmair on Sep 25, 2015, 08:25 AM
Just tested it, and it worked. Locked and marked as solved.
Title: Re: Ammo
Post by: Thijn on Sep 25, 2015, 03:16 PM
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.