Meteor Scripting Functions
Inventory
void giveItem(int playerID, string itemName, int amount)
Give items to a player (server only).

Example
if(isServer())
{
    // give all players 100 bullets
    for(int i=0; i<getPlayersCount(); i++)
    {
        int playerID = getPlayerAtIndex(i);
        giveItem(playerID, "Bullet", 100);
    }
}

Comments
Cannot run on client.
Pass a negative amount to take items.
Final item counts are clamped between 0 and max specified in base\itemdefs.txt.

See also
getItemCount resetItems clampPlayerWeapon

int getItemCount(int playerID, string itemName)
Get amount of an item a player has.

Example
// show how many bullets each player has
for(int i=0; i<getPlayersCount(); i++)
{
    int playerID = getPlayerAtIndex(i);
    print("Player " + getUnitDisplayName(playerID) + " has " + getItemCount(playerID, "Bullet") + " bullets");
}

See also
giveItem resetItems

void resetItems(int playerID, bool mapStartItemsOnly)
Reset a player's items (server only).

Example
if(isServer())
{
    // reset all player loadouts to basics only
    for(int i=0; i<getPlayersCount(); i++)
    {
        int playerID = getPlayerAtIndex(i);
        resetItems(playerID, false);
        clampPlayerWeapon(playerID);
    }
}

Comments
set mapStartItemsOnly to true to keep weapons and ammo but loose keys etc.
set mapStartItemsOnly to false to keep only default starting items like starting a new game (e.g. pistol and some bullets).

See also
giveItem getItemCount clampPlayerWeapon

string getItemTypeName()
Get the name of an item type by index.

Example
print(getItemTypeName(0));

See also
getAllItemsTypesCount getAllItemTypeNames

int getAllItemsTypesCount()
Get the amount of item types.

Example
print("There are " + getAllItemsTypesCount() + " item types.");

See also
getItemTypeName getAllItemTypeNames

int getAllItemTypeNames()
Get the names of all the item types.

Example
// show how many of each item the local player has
array<string> itemTypeNames = getAllItemTypeNames();
for(int i=0; i<getAllItemsTypesCount(); i++)
{
    print(itemTypeNames[i] + ": " + getItemCount(getPlayer(), itemTypeNames[i]));
}

See also
getItemTypeName getAllItemsTypesCount


Index