GiveInventory

From ZDoom Wiki
Jump to navigation Jump to search
Note: This function is for ACS. For the ZScript function of the same name see GiveInventory (Actor).


void GiveInventory(str inventory_item, int amount);

Usage

This function will give the number of items specified to the activator. In the case of ammo, health and armor it will give the total number (so GiveInventory("Shell", 5) and GiveInventory("ShellBox", 5) will both give the player five shells.)

If the function is run with no activator (for example an OPEN script or removing an existing activator with SetActivator), it will run for and affect all active players in the game.

See the Inventory page for a list of items in ZDoom.

Examples

This script gives the player some equipment. It could be run some time after script 50 in ClearInventory, as an example.

script 51 (void)
{
	PrintBold(s:"Security issues the standard kit.");
	GiveInventory("Pistol", 1);
	GiveInventory("Clip", 50);
	GiveInventory("GreenArmor", 1);
}

This will result in the player gaining 70 bullets, as the pistol comes with 20. To set an exact number of ammo after giving a weapon, either use TakeInventory to remove all the player's ammo, or subtract the amount given with the weapon.