Other great resources: Official JS API docs, Scripting Forum

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Overview

Indicates which player is currently being played/viewed by the human on the current machine.

This can be useful on challenges and skirmishes, as it tells you who the human player is if you capture the value of selectedPlayer at the very start of the game.

If the human player uses cheats, they can switch to a different player during the game so bear this in mind.

Example

Work out if human is looking at me
function am_i_being_watched() {
  if (selectedPlayer == me) { // human has infiltrated my AI brain!
    console("Hey! Stop watching me, go back to your own game!");
  }
}
setTimer("am_i_being_watched",10000); // check every 10 seconds
Make a note of which player the human should be...
// take a snapshot of which player the human is at the start of the game
var humanPlayer = selectedPlayer;
 
// has human switched players?
function checkForPlayerSwitch() {
  if (selectedPlayer != humanPlayer) { // human has switched players
    console("Naughty, naughty!");
  }
}
setTimer("checkForPlayerSwitch",10000); // check every 10 seconds
  • No labels