Meteor 2 Scripting Functions
Weapon
int getWeapon(int objectID)
Get the specified object current weapon slot index.

Example
// show player current weapon slot index
print(getWeapon(PLAYER_OBJECT));

Comments
If the object was not found -1 is returned.

See also
setWeapon clampWeapon hasWeapon getWeaponSlotItemNumber getWeaponSlotItemName getWeaponSlotsCount

void setWeapon(int objectID, int slotIndex)
Set the specified object current weapon slot index (local player or server only).

Example
// select weapon slot 2 (PDW)
setWeapon(PLAYER_OBJECT, 2);

See also
getWeapon clampWeapon hasWeapon getWeaponSlotItemNumber getWeaponSlotItemName getWeaponSlotsCount setAutoWeaponSwitchingEnabled

void clampWeapon(int objectID)
Clamp an object's current weapon index to a valid (and owned for players) weapon slot (local player or server only).

Example
// take away player PDW
giveItem(getLocalPlayer(), "PDW", -1);

// ensure player's current weapon is valid
clampWeapon(PLAYER_OBJECT);

Comments
Use this function to ensure an object's current weapon is valid, especially after removing player weapons.

See also
getWeapon setWeapon hasWeapon getWeaponSlotItemNumber getWeaponSlotItemName getWeaponSlotsCount

bool hasWeapon(int objectID, weaponItemName string)
Determine if an object has a specific weapon.

Example
// does player have a PDW?
print("Player has PDW: " + hasWeapon(PLAYER_OBJECT, "PDW"));

Comments
This function is normally used for player objects.

See also
getWeapon setWeapon clampWeapon getWeaponSlotItemNumber getWeaponSlotItemName getWeaponSlotsCount

int getWeaponSlotItemNumber(int objectID, int slotIndex)
Get the item type index for an object weapon slot.

Example
// print player slot 0 item number
print(getWeaponSlotItemNumber(PLAYER_OBJECT, 0));

Comments
Returns -1 if the object or slot is invalid.

See also
getWeapon setWeapon clampWeapon hasWeapon getWeaponSlotItemName getWeaponSlotsCount

string getWeaponSlotItemName(int objectID, int slotIndex)
Get the item type name for a player weapon slot.

Example
// print weapon item name for slot 0
print(getWeaponSlotItemName(PLAYER_OBJECT, 0));

Comments
Returns empty string if the object or slot is invalid.

See also
getWeapon setWeapon clampWeapon hasWeapon getWeaponSlotItemNumber getWeaponSlotsCount

int getWeaponSlotsCount(int objectID)
Get the number of weapon slots an object has.

Example 1
// show number of player weapon slots
print("Player has " + getWeaponSlotsCount(PLAYER_OBJECT) + " weapon slots");

Example 2
// loop through weapon slots and display information
for(int i=0; i<getWeaponSlotsCount(PLAYER_OBJECT); i++)
{
    print(i + ": " + getWeaponSlotItemName(PLAYER_OBJECT, i));
}

See also
getWeapon setWeapon clampWeapon hasWeapon getWeaponSlotItemNumber getWeaponSlotItemName

bool getAutoWeaponSwitchingEnabled(int objectID)
Determine if auto weapon switching is enabled for an object.

Example
// print if auto weapon switching is enabled for object ID 1
print(getAutoWeaponSwitchingEnabled(1));

See also
setAutoWeaponSwitchingEnabled

void setAutoWeaponSwitchingEnabled(int objectID, bool enable)
Enable or disable auto weapon switching for an object.

Example
// disable auto weapon switching for object ID 1
if(isServer())
{
    setAutoWeaponSwitchingEnabled(1, false);
}

Comments
Server only.
Non player objects periodically switch between weapon mounts if the mounts are not linked. Use this function to enable or disable this behaviour.

See also
getAutoWeaponSwitchingEnabled setWeapon


Index

Generated on the 24 June 2024 at 06:55:38 (UK Time)