Meteor 2 Scripting Functions
Inventory
void givePlayerItem(int playerID, string itemName, int amount)
Give items to a player.

Example
if(isServer())
{
    // give all players 1 rifle mag
    for(int i=0; i<getPlayersCount(); i++)
    {
        int playerID = getPlayerAtIndex(i);
        givePlayerItem(playerID, "Rifle Mag", 1);
    }
}

Comments
Pass a negative amount to take items.
Final item counts are clamped between 0 and max specified in base\game\items.ini (depending on game mode)
Can be called from server or client.

See also
getPlayerItemCount resetPlayerItems clampPlayerWeapon

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

Example
// show how many rifle mags player has
for(int i=0; i<getPlayersCount(); i++)
{
    int playerID = getPlayerAtIndex(i);
    print(getPlayerName(playerID) + " has " + getPlayerItemCount(playerID, "Rifle Mag") + " rifle mags");
}

See also
givePlayerItem resetPlayerItems

void resetPlayerItems(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);
        int playerObjectID = getPlayerObject(playerID);
        resetPlayerItems(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
givePlayerItem getPlayerItemCount clampPlayerWeapon

void addItem(int objectID, string itemName, int count)
Add item to an object's inventory (server and clients).

Example
addItem(PLAYER_OBJECT, "Rifle Mag", 1);

See also
removeItem getItemCount

void removeItem(int objectID, string itemName)
Remove an item from an object's inventory (server and clients).

Example
removeItem(PLAYER_OBJECT, "Rifle Mag");

See also
addItem getItemCount

void getItemCount(int objectID, string itemName)
Get the count of an item from an object's inventory (server and clients).

Example
print(getItemCount(PLAYER_OBJECT, "Rifle Mag"));

See also
addItem removeItem

string getItemTypeNumber()
Get the index of an item type.

Example
print(getItemTypeNumber("Chocolate Bar"));

Comments
Returns 0 (default item) if the item does not exist.

See also
getItemTypeName

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

Example
print(getItemTypeName(0));

See also
getItemTypeNumber getItemTypesCount getItemTypeNames

int getItemTypesCount()
Get the amount of item types.

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

See also
getItemTypeName getItemTypeNames

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

Example
// show how many of each item the local player has
array<string> itemTypeNames = getItemTypeNames();
for(uint i=0; i<itemTypeNames.length(); i++)
{
    print(itemTypeNames[i] + ": " + getPlayerItemCount(getLocalPlayer(), itemTypeNames[i]));
}

See also
getItemTypeName getItemTypesCount


Index