Vice City: Multiplayer

Server Development => Scripting and Server Management => Script Showroom => Topic started by: [TDA]Speed on Mar 27, 2025, 08:07 PM

Title: New function GiveAmmoToWeapon()
Post by: [TDA]Speed on Mar 27, 2025, 08:07 PM
what this function used for ?
this function used to give the player ammo or weapon without changing his current weapon

GiveAmmoToWeapon(player, WeaponID, ammo);


place this function anywhere
function GiveAmmoToWeapon(player, weapon, amount)
{
local currentwep = player.Weapon;
local currentammo = player.GetAmmoAtSlot(player.Slot);
local weapon = weapon;
amount = amount;
player.GiveWeapon(weapon,amount);
if (currentwep != weapon ) player.SetWeapon(currentwep,currentammo);
}


example usage

if (player.GetWeaponAtslot(6) == 26) GiveAmmoToWeapon(player, 26, 30);

if player holding shotgun and picked m4 it will not change his weapon and will give him ammo for m4 without changing his weapon