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.
int getPlayerObject(int playerID)
Get a player game object from a playerID.
int playerID = getLocalPlayer();
print(getPlayerObject(playerID));
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);
int getObjectPlayer(int objectID)
Get a player ID from a player game object.
print(getObjectPlayer(10));
Returns -1 if the object is not a player or was not found.
int getLocalPlayer()
Get the local playerID (not objectID).
print(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());
bool playerExists(int playerID)
Determine if a player ID exists.
print("Players count: " + getPlayersCount());
playerID is not an object ID.
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, STATE_VIEWING and STATE_GAME_OVER.
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 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);
bool getPlayerGodModeEnabled(int playerID)
Get local player god mode enabled status.
print(getPlayerGodModeEnabled(LOCAL_PLAYER));
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 playerNear(vector2 pos, float maxDistance)
Determine if any player is within the specified distance of a position.
print(playerNear(vector2(0,0)));
int getPlayerCurrentWeapon(int playerID)
Get a player's current weapon.
print(getPlayerCurrentWeapon(getLocalPlayer()));
If the player is controlling vehicle weapons, the current weapon will be a vehicle mount index instead.
If the player has no weapon selected, -1 is returned.
bool getPlayerCurrentWeaponRange(int playerID)
Get a player's current weapon range in pixels.
print(getPlayerCurrentWeaponRange(getLocalPlayer()));
bool getPlayerCurrentWeaponScopeRange(int playerID)
Get a player's current weapon scope range in pixels.
print(getPlayerCurrentWeaponScopeRange(getLocalPlayer()));
int getLookObject()
Get the local player look object.
print(getLookObject());
Gets the object the local player is looking at.
Range is limited to 60 pixels (so the player needs to be next to the object and looking at it).
This function is designed for interacting with near objects (e.g. vehicles or switches). For longer distances use raycast() to implement a custom solution.
This function will not work while the player is in a vehicle.
Index