SC2Mapster.com Wiki

PlayerRace

string PlayerRace(int player);

Race of the player

Parameters

int player

Player to check

Return value

string -

  • Empty String: If the player is not in the game
  • "Zerg", "Prot", "Terr": The player race

Examples

Example #1
// A map with a Zerg, a Protoss and a Terran
string race;

race = PlayerRace(1); // "Zerg"
race = PlayerRace(2); // "Prot" : Protoss
race = PlayerRace(3); // "Terr" : Terran
race = PlayerRace(4); // ""
Example #2: Debugging
function DebugPlayer(int player, string message) {
  string formatted = "Player " + IntToString(player) 
                   + " (" + PlayerRace(player)  + ") - " + message;
  TriggerDebugOutput(1, TextToString(formatted), false);
}

// DebugPlayer(1, "is a noob");
// Will print something like: "Player 1 (Zerg) - is a noob"

You must login to post a comment. Don't have an account? Register to get one!

  • 1 comment
  • Avatar of vjeux vjeux Mar 12, 2010 at 10:52 UTC - 0 likes

    Get a integer instead of a string

    int PlayerGetRace(int player) {
        string race = PlayerRace(player);
        if (race == "Zerg") {
        	return c_raceZerg;
        } else if (race == "Terr") {
        	return c_raceTerr;
        } else {
        	return c_raceProtoss; 
        }
    }
    
  • 1 comment

Facts

Date created
Mar 11, 2010
Last updated
Mar 12, 2010

Author