# Set Player Hero

Grammar — Set Player player’s hero to hero.
FlagsNative | Action

Sets the hero of the specified player.

# Arguments

  • int — Player
  • string<gamelink::Hero> — Hero

Returns — void

native void PlayerSetHero(int inPlayer, string inHero);

Category: Player / Player Settings

# Examples

mods/heroes.stormmodbase.stormmaps/maps/heroes/singleplayermaps/%2810%29trymemode.stormmap/MapScript.galaxy:1442

    TriggerExecute(gt_TryMeModePanelInitialize, true, true);
    libGame_gf_MinionTurnOnOffCatapults(false);
    PlayerSetHero(gv_pLAYER_AI_Enemy_C, "Arthas");
    PlayerSetMount(gv_pLAYER_AI_Enemy_C, "HorseBlack");
    libGame_gv_players[gv_pLAYER_AI_Enemy_C].lv_selectedMount = libCore_gf_DataMountGetMountIndexFromMountLink("HorseBlack");

mods/heroes.stormmod/base.stormmaps/maps/heroes/singleplayermaps/(10)trymemode.stormmapmap/MapScript.galaxy:1442

    TriggerExecute(gt_TryMeModePanelInitialize, true, true);
    libGame_gf_MinionTurnOnOffCatapults(false);
    PlayerSetHero(gv_pLAYER_AI_Enemy_C, "Arthas");
    PlayerSetMount(gv_pLAYER_AI_Enemy_C, "HorseBlack");
    libGame_gv_players[gv_pLAYER_AI_Enemy_C].lv_selectedMount = libCore_gf_DataMountGetMountIndexFromMountLink("HorseBlack");

mods/heroesbrawlmods/arenamodemods/arenamode.stormmodbase.stormdata/LibAREN.galaxy:428

    lv_itPlayer = 1;
    for ( ; ( (autoBD96AF1D_ai >= 0 && lv_itPlayer <= autoBD96AF1D_ae) || (autoBD96AF1D_ai < 0 && lv_itPlayer >= autoBD96AF1D_ae) ) ; lv_itPlayer += autoBD96AF1D_ai ) {
        PlayerSetHero(lv_itPlayer, (""));
        libGame_gf_SetCameraBoundStormIndexForPlayer(lv_itPlayer, libGame_gf_CameraBoundStormIndex(libAREN_gv_aRM_MechanicData[libAREN_gf_ArenaCurrentMechanicId()].lv_cameraBoundsRegion));
        CameraLockInput(lv_itPlayer, true);

mods/heroesbrawlmods/arenamodemods/attackdefend.stormmodbase.stormdata/LibAtDe.galaxy:428

    lv_itPlayer = 1;
    for ( ; ( (auto11D31742_ai >= 0 && lv_itPlayer <= auto11D31742_ae) || (auto11D31742_ai < 0 && lv_itPlayer >= auto11D31742_ae) ) ; lv_itPlayer += auto11D31742_ai ) {
        PlayerSetHero(lv_itPlayer, (""));
        CameraLockInput(lv_itPlayer, true);
        CameraPan(lv_itPlayer, libGame_gv_players[lv_itPlayer].lv_spawnPoint, 0.0, -1, 10.0, false);

mods/heroesdata.stormmodbase.stormdata/TriggerLibs/GameLib.galaxy:5475

    for ( ; ( (auto27F3DF11_ai >= 0 && lv_playerIndex <= auto27F3DF11_ae) || (auto27F3DF11_ai < 0 && lv_playerIndex >= auto27F3DF11_ae) ) ; lv_playerIndex += auto27F3DF11_ai ) {
        if ((PlayerStatus(lv_playerIndex) != c_playerStatusUnused) && (libGame_gv_players[lv_playerIndex].lv_heroIndex != 0)) {
            PlayerSetHero(lv_playerIndex, libCore_gf_GetHeroFromIndex(libGame_gv_players[lv_playerIndex].lv_heroIndex));
        }

mods/heroesdata.stormmodbase.stormdata/TriggerLibs/GameLib.galaxy:10623

    }

    PlayerSetHero(lp_player, libGame_gv_players[lp_heroIndex].lv_heroData.lv_heroCatalogLink);
    StatEventCreate("PlayerSpawned");
    StatEventAddDataInt(StatEventLastCreated(), "PlayerID", lp_player);

mods/heromods/chogall.stormmodbase.stormdata/LibHCHO.galaxy:1328

        lv_savedTalentsCho[lv_itTalent] = libGame_gv_talents_TalentChoices[lv_initialChoPlayerID][lv_itTalent].lv_selection;
    }
    PlayerSetHero(lv_initialGallPlayerID, "Cho");
    UnitSetOwner(lv_choUnit, lv_initialGallPlayerID, true);
    UnitGroupClear(libGame_gv_players[lv_initialGallPlayerID].lv_heroUnitGroup);

mods/heromods/chogall.stormmodbase.stormdata/LibHCHO.galaxy:1339

    libGame_gf_TalentsSetupTalentChoicesFromHeroDataForPlayer(libGame_gv_players[lv_initialGallPlayerID].lv_heroIndex, lv_initialGallPlayerID);
    UISetCommandAllowed(PlayerGroupSingle(lv_initialGallPlayerID), c_uiCommandAllowQueue, true);
    PlayerSetHero(lv_initialChoPlayerID, "Gall");
    UnitSetOwner(lv_gallUnit, lv_initialChoPlayerID, true);
    UnitGroupClear(libGame_gv_players[lv_initialChoPlayerID].lv_heroUnitGroup);

mods/heromods/chogall.stormmodbase.stormdata/LibHCHO.galaxy:1767


    lv_gallIndex = lv_gallPlayer;
    PlayerSetHero(lv_gallPlayer, libGame_gv_players[lv_gallIndex].lv_heroData.lv_heroCatalogLink);
    StatEventCreate("PlayerSpawned");
    StatEventAddDataInt(StatEventLastCreated(), "PlayerID", lv_gallPlayer);

mods/heromods/dva.stormmodbase.stormdata/LibHDVA.galaxy:232

    }

    PlayerSetHero(lp_player, libGame_gv_players[lp_player].lv_heroData.lv_heroCatalogLink);
    StatEventCreate("PlayerSpawned");
    StatEventAddDataInt(StatEventLastCreated(), "PlayerID", lp_player);