Meteor 2 Scripting Functions
Weapon
int getPlayerWeapon(int playerID)
Get the specified player's current weapon slot index.
print(getPlayerWeapon(getLocalPlayer()));
If the player was not found -1 is returned.
void setPlayerWeapon(int playerID, int slotIndex)
Set the specified player's current weapon slot index (local player or server only).
setPlayerWeapon(getLocalPlayer(), 2);
void clampPlayerWeapon(int playerID)
Clamp a player's current weapon index to a valid (and owned) weapon slot (local player or server only).
giveItem(getLocalPlayer(), "PDW", -1);
clampPlayerWeapon(getLocalPlayer());
Use this function to ensure a player's current weapon is valid, especially after removing weapons.
bool hasWeapon(int objectID, string weaponItemName)
Determine if an object has a specific weapon.
print("Player has PDW: " + hasWeapon(PLAYER_OBJECT, "PDW"));
This function is normally used for player objects.
int getWeaponSlotItemNumber(int objectID, int slotIndex)
Get the item type index for an object weapon slot.
print(getWeaponSlotItemNumber(PLAYER_OBJECT, 0));
Returns -1 if the object or slot is invalid.
string getWeaponSlotItemName(int objectID, int slotIndex)
Get the item type name for a player weapon slot.
print(getWeaponSlotItemName(PLAYER_OBJECT, 0));
Returns empty string if the object or slot is invalid.
int getWeaponSlotsCount(int objectID)
Get the number of weapon slots an object has.
print("Player has " + getWeaponSlotsCount(PLAYER_OBJECT) + " weapon slots");
for(int i=0; i<getWeaponSlotsCount(PLAYER_OBJECT); i++)
{
print(i + ": " + getWeaponSlotItemName(PLAYER_OBJECT, i));
}
bool hasLinkedWeapons(int objectID)
Determine if an object has linked weapons (all turrets fire at the same time).
if(hasLinkedWeapons(PLAYER_VEHICLE))
print("Linked weapon mounts");
else
print("Selectable weapon mounts");
bool isUsingMissileWeapon(int objectID)
Determine if an object is currently using a missile weapon.
A missile weapon is defined as a weapon with "Trigger missile alarm" set to true in the Weapon Editor.
float getWeaponAimingAngle(int objectID, int slotIndex=-1)
Get the aiming angle of a specified turret.
print("Current slot angle: " + getWeaponAimingAngle(PLAYER_VEHICLE, getPlayerWeapon(getLocalPlayer())));
print("Slot 0: " + getWeaponAimingAngle(PLAYER_VEHICLE, 0));
print("Slot 1: " + getWeaponAimingAngle(PLAYER_VEHICLE, 1));
slotIndex is 0 based. If slotIndex is invalid the object angle is returned.
Result is in degrees (e.g. north = 0, east = 90, south = 180, west = 270).
vector2 getWeaponMountWorldPos(int objectID, int slotIndex=-1)
Get the world position of a specified turret mounting point.
print("Current slot pos: " + getWeaponMountWorldPos(PLAYER_VEHICLE, getPlayerWeapon(getLocalPlayer())));
print("Slot 0: " + getWeaponMountWorldPos(PLAYER_VEHICLE, 0));
print("Slot 1: " + getWeaponMountWorldPos(PLAYER_VEHICLE, 1));
slotIndex is 0 based. If slotIndex is invalid the object position is returned.
vector2 getWeaponFireWorldPos(int objectID, int slotIndex)
Get the world position of a specified turret firing point (end of barrel).
print("Current slot pos: " + getWeaponFireWorldPos(PLAYER_VEHICLE, getPlayerWeapon(getLocalPlayer())));
print("Slot 0: " + getWeaponFireWorldPos(PLAYER_VEHICLE, 0));
print("Slot 1: " + getWeaponFireWorldPos(PLAYER_VEHICLE, 1));
slotIndex is 0 based. If slotIndex is invalid the object position is returned.
void throwGrenade(int objectID, string slotName, float strength)
Make an object throw a grenade.
throwGrenade(1, "Frag Grenade", 0);
throwGrenade(1, "Blue Smoke", 1);
slotName corresponds to the name of a grenade slot in game.ini.
strength is a normalised value from 0 to 1.
vector2 getAimingPos(int objectID)
Get the position an object is aiming at.
print(getAimingPos(PLAYER_OBJECT));
bool getWeaponLaserOn(int objectID)
Determine if object's weapon laser is switched on.
print(getWeaponLaserOn(PLAYER_OBJECT));
float getWeaponLaserDistance(int objectID)
Get the length of a object's weapon laser.
print(getWeaponLaserDistance(PLAYER_OBJECT));
If distance is less than or equal to 0 then the laser pointer is not on.
distance is the current laser length in pixels (use pixelsToMetres() to convert to metres).
The laser stops at the first obstruction (target) in line of sight.
vector2 getWeaponLaserEndPos(int objectID)
Get the length of a object's weapon laser.
print(getWeaponLaserEndPos(PLAYER_OBJECT));
If weapon laser is not switched on then object position is returned.
Index