Meteor Scripting Functions
Player
bool isPlayer(int objectID)
Determine if an objectID is a player.
int playerID = getPlayer();
print(isPlayer(playerID));
Returns false if objectID was not found.
int getPlayer()
Get the local player ID.
print("Your name is " + getUnitDisplayName(getPlayer()));
Returns -1 if there is no player.
int getServerPlayer()
Get the server player ID.
print("Your name is " + getUnitDisplayName(getPlayer()));
In single player this function returns the local player and is identical to calling getPlayer().
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("" + i + ": " + getUnitDisplayName(playerID) + " (" + playerID + ")");
}
Returns -1 if there is no player at that index.
Player lists are stored 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());
int getPlayerState(int playerID)
Get a player's current state.
if(getPlayerState(getPlayer()) == 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.
int getNearestPlayer(vector2 pos)
Get the nearest spawned player to a position.
int playerID = getNearestPlayer(vector2(0,0));
if(playerID != -1)
print(getUnitDisplayName(playerID));
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.
vector2 getPlayerLastKilledPos(int objectID)
Get a player's last killed position.
print("Last killed pos: " + getPlayerLastKilledPos(getPlayer()));
int getPlayerWeapon(int objectID)
Get the specified player weapon slot index.
print(getPlayerWeapon(getPlayer()));
If the player was not found 0 is returned.
void setPlayerWeapon(int objectID, int slotIndex)
Set the specified player weapon slot index (local player or server only).
setPlayerWeapon(getPlayer(), 1);
void clampPlayerWeapon(int objectID)
Clamp the player weapon index to a valid/owned weapon slot (local player or server only).
giveItem(getPlayer(), "Uzi", -1);
clampPlayerWeapon(getPlayer());
Use this function to ensure the player's current weapon is valid after removing player weapons.
bool playerHasWeapon(int objectID, weaponItemName string)
Determine if a player has a weapon.
print("Player has Uzi: " + playerHasWeapon(getPlayer(), "Uzi"));
No playerID is required because the slots count is the same for all players.
int getPlayerWeaponSlotItemNumber(int slotIndex)
Get the item type index for a player weapon slot.
print(getPlayerWeaponSlotItemNumber(0));
No playerID is required because the slot item types are the same for all players.
Returns -1 if the slot is invalid.
string getPlayerWeaponSlotItemName(int slotIndex)
Get the item type name for a player weapon slot.
print(getPlayerWeaponSlotItemName(0));
No playerID is required because the slot item names are the same for all players.
Returns empty string if the slot is invalid.
int getPlayerWeaponSlotsCount()
Get the number of player weapon slots.
print("Player has " + getPlayerWeaponSlotsCount() + " weapon slots");
for(int i=0; i<getPlayerWeaponSlotsCount(); i++)
{
print(i + ": " + getPlayerWeaponSlotItemName(i));
}
No playerID is required because the slots count is the same for all players.
bool getPlayerNoTarget(int objectID)
Get whether enemies can target a player.
print("Player no target: " + getPlayerNoTarget(getPlayer()));
void setPlayerNoTarget(int objectID, bool noTargetEnabled)
Set whether enemies can target a player. (server only)
setPlayerNoTarget(getPlayer(), true);
No target also prevents the player from taking any damage, similar to god mode.
Index
Generated on the 15 May 2024 at 09:00:40 (UK Time)