UTIL GetLocalPlayer

From Valve Developer Community
< Ru
Revision as of 07:43, 11 July 2024 by Nesciuse (talk | contribs) (Using L template for links)
Jump to navigation Jump to search
Underlinked - Logo.png
This article needs more Wikipedia icon links to other articles to help Wikipedia icon integrate it into the encyclopedia. Please help improve this article by adding links Wikipedia icon that are relevant to the context within the existing text.
January 2024
English (en)Русский (ru)Translate (Translate)

UTIL_GetLocalPlayer это UTIL(en), используемый в Source Engine для нахождения локального игрока. Если игра запущена в одиночном режиме, возвращается указатель на структуру локального игрока. Если нет, возвращается NULL.

Использование

//-----------------------------------------------------------------------------
// Цель: Возвращается указатель на игрока если игра запущена в одиночном режиме, если нет - NULL.
//          
// Ввод  : 
// Вывод : CBasePlayer*
//-----------------------------------------------------------------------------
UTIL_GetLocalPlayer()

Пример

CBasePlayer *pPlayer = UTIL_GetLocalPlayer();
if ( pPlayer )
{
    // Любое действие
}
Vector vecPlayerCenter = UTIL_GetLocalPlayer()->WorldSpaceCenter();