Closed GoD-Tony closed 8 years ago
God-Tony what you think about this variant win and lin?
static cell_t PTaH_GetEconItemViewFromWeapon(IPluginContext *pContext, const cell_t *params)
{
CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(params[1]);
if(!pEntity)
{
return pContext->ThrowNativeError("Entity %d is invalid", params[1]);
}
IServerNetworkable *pNet = ((IServerUnknown *)pEntity)->GetNetworkable();
if (!pNet || !UTIL_ContainsDataTable(pNet->GetServerClass()->m_pTable, "DT_BaseCombatWeapon"))
{
return pContext->ThrowNativeError("Entity %d is not weapon", params[1]);
}
int offset = -1;
if(!g_pGameConf[GameConf_PTaH]->GetOffset("m_hEconItemView", &offset) || offset == -1)
{
smutils->LogError(myself, "Failed to get m_hEconItemView offset");
return 0;
}
return (intptr_t)pEntity + offset;
}
@komashchenko:
GetOffset
so it doesn't have to be checked every time.Otherwise it looks good!
The function
CBaseCombatWeapon::GetEconItemView
is inlined on Windows and must be grabbed directly from the member variable with an offset. This should fix the issue for CS:GO.