Meteor 2 Scripting Functions
Player
bool isPlayer(int objectID)
Determine if an objectID is a player.
int objectID = getLocalPlayerObject();
print(isPlayer(objectID));
Returns false if objectID was not found.
bool getLocalPlayerObject()
Get local player game object. Same as using PLAYER_OBJECT global variable.
print(getLocalPlayerObject());
print(PLAYER_OBJECT);
Returns -1 if no local player.
A global read-only variable simply called PLAYER_OBJECT always contains the current local player object ID.
bool getPlayerObject(int playerID)
Get a player game object from a playerID.
int playerID = getLocalPlayer();
print(getPlayerObject(playerID));
Returns the object the player is currently controlling (returns vehicle object if the player is in a vehicle, else the human object).
Returns -1 if player was not found.
void setPlayerObject(int playerID, int objectID)
Set a player object ID (player becomes that object) (local player and server only).
setPlayerObject(getLocalPlayer(), 0);
bool getPlayerHumanObject(int playerID)
Get a human player game object from a playerID, even if the player is in a vehicle.
int playerID = getLocalPlayer();
print(getPlayerHumanObject(playerID));
Returns -1 if player was not found.
int getLocalPlayer()
Get the local playerID (not objectID).
print(getLocalPlayer());
Same as calling getPlayerObject(getLocalPlayer());
Returns -1 if there is no local player.
int getServerPlayer()
Get the server player's object ID.
print(getServerPlayer());
In single player this function returns the local player and is identical to calling getLocalPlayer().
Returns -1 if there is no player.
int getPlayerAtIndex(int localIndex)
Get the player ID of another player by index.
for(int i=0; i<getPlayersCount(); i++)
{
int playerID = getPlayerAtIndex(i);
print("" + playerID + ": " + getPlayerName(playerID) + " (" + getPlayerObject(playerID) + ")");
}
Returns -1 if there is no player at that index.
Player lists are ordered differently on each player's computer.
Player IDs are network synced.
int getPlayersCount()
Get the number of players in the game.
print("Players count: " + getPlayersCount());
string getPlayerName(int playerID)
Get a player's profile name.
print(getPlayerName(getLocalPlayer()));
int getPlayerState(int playerID)
Get a player's current state.
if(getPlayerState(getLocalPlayer()) == STATE_PLAYING)
{
print("Your state is STATE_PLAYING");
}
Possible return values are STATE_PLAYING, STATE_WASTED, STATE_WAITING_TO_SPAWN and STATE_VIEWING.
If no player was found then STATE_WAITING_TO_SPAWN is returned.
bool getPlayerScopeAiming(int playerID)
Determine if a player is scope aiming.
print(getPlayerScopeAiming(getLocalPlayer()));
bool getPlayerScopeImagingMode(int playerID)
Get player's scope imaging mode.
print(getPlayerScopeImagingMode(getLocalPlayer()));
imagingMode can be either IM_VIS, IM_NV or IM_TI
bool getPlayerInVehicle(int playerID)
Determine if a player is in a vehicle.
if(getPlayerInVehicle(getLocalPlayer()))
{
print("In a vehicle");
}
int getPlayerVehicleObject(int playerID)
Get a player's vehicle object ID.
int objectID = getPlayerVehicleObject(getLocalPlayer());
print(objectID);
Returns -1 is the player is not in a vehicle.
bool getPlayerInteractionEnabled()
Get local player interaction enabled status.
print(getPlayerInteractionEnabled());
void setPlayerInteractionEnabled(bool enabled)
Enable or disable local player interaction/E key (local only)
setPlayerInteractionEnabled(false);
int getNearestPlayer(vector2 pos)
Get the nearest spawned player to a position.
int playerID = getNearestPlayer(vector2(0,0));
if(playerID != -1)
{
int playerObjectID = getPlayerObject(playerID);
print(getPlayerName(playerID) + " " + getPos(playerObjectID));
}
else
{
print("No players");
}
If no active player was found -1 is returned.
float getNearestPlayerDistance(vector2 pos, float defaultValue=-1)
Get the distance to the nearest spawned player from a position.
print(getNearestPlayerDistance(vector2(0,0)));
defaultValue is the return value if no active players were found. If no defaultValue is specified then -1 is used.
bool getPlayerCurrentWeaponRange(int playerID)
Get a player's current weapon range in pixels.
print(getPlayerCurrentWeaponRange(getLocalPlayer()));
bool getPlayerWeaponLaserOn(int playerID)
Determine if player's weapon laser is switched on.
print(getPlayerWeaponLaserOn(getLocalPlayer()));
float getPlayerWeaponLaserDistance(int playerID)
Get the length of a player's weapon laser.
print(getPlayerWeaponLaserDistance(getLocalPlayer()));
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.
Index