Meteor 2 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\items.ini.

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(getPlayerName(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);
        int playerObjectID = getPlayerObject(playerID);
        resetItems(playerID, false);
        clampWeapon(playerObjectID);
    }
}

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(uint i=0; i<itemTypeNames.length(); i++)
{
    print(itemTypeNames[i] + ": " + getItemCount(getLocalPlayer(), itemTypeNames[i]));
}

See also
getItemTypeName getAllItemsTypesCount


Index

Generated on the 23 November 2024 at 08:20:41 (UK Time)