Skip to content

Instantly share code, notes, and snippets.

@codenulls
Created December 26, 2018 18:20
Show Gist options
  • Save codenulls/51a16a244f05da5e9e02d166542fbfec to your computer and use it in GitHub Desktop.
Save codenulls/51a16a244f05da5e9e02d166542fbfec to your computer and use it in GitHub Desktop.
Function for getting all task names for MTA SA.
bool CClientGame::GetLocalPlayerTaskNames(SString& strConcatenatedTaskNames, bool bPrimary)
{
CClientPed* pLocalPlayer = static_cast<CClientPed*>(GetLocalPlayer());
if (pLocalPlayer)
{
int cTaskTypes = bPrimary ? 5 : 6;
for (int iTaskType = 0; iTaskType < cTaskTypes; iTaskType++)
{
std::vector<SString> taskHierarchy;
if (CStaticFunctionDefinitions::GetPedTask(*pLocalPlayer, bPrimary, iTaskType, taskHierarchy))
{
strConcatenatedTaskNames += "\n" + taskHierarchy[0];
for (uint i = 0; i < taskHierarchy.size(); i++)
{
if (i > 0)
{
strConcatenatedTaskNames += "->" + taskHierarchy[i];
}
}
}
}
}
else
{
return false;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment