Meteor 2 Scripting Functions
Inventory
void givePlayerItem(int playerID, string itemName, int amount)
Give items to a player.
if(isServer())
{
for(int i=0; i<getPlayersCount(); i++)
{
int playerID = getPlayerAtIndex(i);
givePlayerItem(playerID, "Rifle Mag", 1);
}
}
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.
int getPlayerItemCount(int playerID, string itemName)
Get amount of an item a player has.
for(int i=0; i<getPlayersCount(); i++)
{
int playerID = getPlayerAtIndex(i);
print(getPlayerName(playerID) + " has " + getPlayerItemCount(playerID, "Rifle Mag") + " rifle mags");
}
void resetPlayerItems(int playerID, bool mapStartItemsOnly)
Reset a player's items (server only).
if(isServer())
{
for(int i=0; i<getPlayersCount(); i++)
{
int playerID = getPlayerAtIndex(i);
int playerObjectID = getPlayerObject(playerID);
resetPlayerItems(playerID, false);
clampPlayerWeapon(playerID);
}
}
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).
void addItem(int objectID, string itemName, int count)
Add item to an object's inventory (server and clients).
addItem(PLAYER_OBJECT, "Rifle Mag", 1);
void removeItem(int objectID, string itemName)
Remove an item from an object's inventory (server and clients).
removeItem(PLAYER_OBJECT, "Rifle Mag");
void getItemCount(int objectID, string itemName)
Get the count of an item from an object's inventory (server and clients).
print(getItemCount(PLAYER_OBJECT, "Rifle Mag"));
string getItemTypeNumber()
Get the index of an item type.
print(getItemTypeNumber("Chocolate Bar"));
Returns 0 (default item) if the item does not exist.
string getItemTypeName()
Get the name of an item type by index.
print(getItemTypeName(0));
int getItemTypesCount()
Get the amount of item types.
print("There are " + getItemTypesCount() + " item types.");
int getItemTypeNames()
Get the names of all item types.
array<string> itemTypeNames = getItemTypeNames();
for(uint i=0; i<itemTypeNames.length(); i++)
{
print(itemTypeNames[i] + ": " + getPlayerItemCount(getLocalPlayer(), itemTypeNames[i]));
}
Index