UseInventory

From ZDoom Wiki
Jump to navigation Jump to search

int UseInventory (str classname)

Forces the activator to use the specified inventory item, if he has it. The return value is true if the item was used successfully, or false if not.

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.

Examples

This example creates a hotkey based function that will use the most powerful healing item in the player's possesion.

script "BestHealing" (void) net
{
 If (UseInventory("UltimateHealingPotion"))
 {
    terminate;
 }
 If (UseInventory("MajorHealingPotion"))
 {
    terminate;
 }
 If (UseInventory("HealingPotion"))
 {
    terminate;
 }
 If (UseInventory("MinorHealingPotion"))
 {
    terminate;
 }
}