Meteor 2 Scripting Functions
Player
bool isPlayer(int objectID)
Determine if an objectID is a player.

Example
// is player a player
int objectID = getLocalPlayerObject();
print(isPlayer(objectID));

Comments
Returns false if objectID was not found.

bool getLocalPlayerObject()
Get local player game object. Same as using PLAYER_OBJECT global variable.

Example
print(getLocalPlayerObject());
// or
print(PLAYER_OBJECT);

Comments
Returns -1 if no local player.
A global read-only variable simply called PLAYER_OBJECT always contains the current local player object ID.

See also
getPlayerObject

bool getPlayerObject(int playerID)
Get a player game object from a playerID.

Example
int playerID = getLocalPlayer();
print(getPlayerObject(playerID));

Comments
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.

See also
getLocalPlayerObject getPlayerHumanObject

void setPlayerObject(int playerID, int objectID)
Set a player object ID (player becomes that object) (local player and server only).

Example
setPlayerObject(getLocalPlayer(), 0);

See also
getPlayer

bool getPlayerHumanObject(int playerID)
Get a human player game object from a playerID, even if the player is in a vehicle.

Example
int playerID = getLocalPlayer();
print(getPlayerHumanObject(playerID));

Comments
Returns -1 if player was not found.

See also
getLocalPlayerObject getPlayerObject

int getLocalPlayer()
Get the local playerID (not objectID).

Example
print(getLocalPlayer());

Comments
Same as calling getPlayerObject(getLocalPlayer());
Returns -1 if there is no local player.

See also
getPlayerAtIndex getPlayersCount

int getServerPlayer()
Get the server player's object ID.

Example
print(getServerPlayer());

Comments
In single player this function returns the local player and is identical to calling getLocalPlayer().
Returns -1 if there is no player.

See also
getPlayer getPlayerAtIndex getPlayersCount

int getPlayerAtIndex(int localIndex)
Get the player ID of another player by index.

Example
// list players
for(int i=0; i<getPlayersCount(); i++)
{
    int playerID = getPlayerAtIndex(i);
    print("" + playerID + ": " + getPlayerName(playerID) + " (" + getPlayerObject(playerID) + ")");
}

Comments
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.

See also
getPlayer getPlayersCount

int getPlayersCount()
Get the number of players in the game.

Example
print("Players count: " + getPlayersCount());

See also
getPlayer getPlayerAtIndex

string getPlayerName(int playerID)
Get a player's profile name.

Example
print(getPlayerName(getLocalPlayer()));

See also
getDisplayName

int getPlayerState(int playerID)
Get a player's current state.

Example
if(getPlayerState(getLocalPlayer()) == STATE_PLAYING)
{
    print("Your state is STATE_PLAYING");
}

Comments
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.

Example
print(getPlayerScopeAiming(getLocalPlayer()));

See also
getPlayerScopeImagingMode

bool getPlayerScopeImagingMode(int playerID)
Get player's scope imaging mode.

Example
print(getPlayerScopeImagingMode(getLocalPlayer()));

Comments
imagingMode can be either IM_VIS, IM_NV or IM_TI

See also
getPlayerScopeAiming

bool getPlayerInVehicle(int playerID)
Determine if a player is in a vehicle.

Example
if(getPlayerInVehicle(getLocalPlayer()))
{
    print("In a vehicle");
}

See also
getPlayerVehicleObject

int getPlayerVehicleObject(int playerID)
Get a player's vehicle object ID.

Example
int objectID = getPlayerVehicleObject(getLocalPlayer());
print(objectID);

Comments
Returns -1 is the player is not in a vehicle.

See also
getPlayerInVehicle

bool getPlayerInteractionEnabled()
Get local player interaction enabled status.

Example
print(getPlayerInteractionEnabled());

See also
setPlayerInteractionEnabled

void setPlayerInteractionEnabled(bool enabled)
Enable or disable local player interaction/E key (local only)

Example
setPlayerInteractionEnabled(false);

See also
getPlayerInteractionEnabled

int getNearestPlayer(vector2 pos)
Get the nearest spawned player to a position.

Example
int playerID = getNearestPlayer(vector2(0,0));
if(playerID != -1)
{
    int playerObjectID = getPlayerObject(playerID);
    print(getPlayerName(playerID) + " " + getPos(playerObjectID));
}
else
{
    print("No players");
}

Comments
If no active player was found -1 is returned.

See also
getNearestPlayerDistance

float getNearestPlayerDistance(vector2 pos, float defaultValue=-1)
Get the distance to the nearest spawned player from a position.

Example
print(getNearestPlayerDistance(vector2(0,0)));

Comments
defaultValue is the return value if no active players were found. If no defaultValue is specified then -1 is used.

See also
getNearestPlayer

bool getPlayerCurrentWeaponRange(int playerID)
Get a player's current weapon range in pixels.

Example
print(getPlayerCurrentWeaponRange(getLocalPlayer()));

See also
pixelsToMetres

bool getPlayerWeaponLaserOn(int playerID)
Determine if player's weapon laser is switched on.

Example
print(getPlayerWeaponLaserOn(getLocalPlayer()));

See also
getPlayerWeaponLaserDistance

float getPlayerWeaponLaserDistance(int playerID)
Get the length of a player's weapon laser.

Example
print(getPlayerWeaponLaserDistance(getLocalPlayer()));

Comments
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.

See also
getPlayerWeaponLaserOn pixelsToMetres


Index

Generated on the 23 November 2024 at 08:20:43 (UK Time)