Meteor 2 Scripting Functions
Inventory
void giveItem(int playerID, string itemName, int amount)
Give items to a player (server only).
if(isServer())
{
for(int i=0; i<getPlayersCount(); i++)
{
int playerID = getPlayerAtIndex(i);
giveItem(playerID, "Bullet", 100);
}
}
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.
int getItemCount(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 " + getItemCount(playerID, "Bullet") + " bullets");
}
void resetItems(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);
resetItems(playerID, false);
clampWeapon(playerObjectID);
}
}
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).
string getItemTypeName()
Get the name of an item type by index.
print(getItemTypeName(0));
int getAllItemsTypesCount()
Get the amount of item types.
print("There are " + getAllItemsTypesCount() + " item types.");
int getAllItemTypeNames()
Get the names of all the item types.
array<string> itemTypeNames = getAllItemTypeNames();
for(uint i=0; i<itemTypeNames.length(); i++)
{
print(itemTypeNames[i] + ": " + getItemCount(getLocalPlayer(), itemTypeNames[i]));
}
Index
Generated on the 23 November 2024 at 08:20:41 (UK Time)