MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / GetEntPropArraySize

Function GetEntPropArraySize

core/smn_entities.cpp:1418–1485  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1416}
1417
1418static cell_t GetEntPropArraySize(IPluginContext *pContext, const cell_t *params)
1419{
1420 CBaseEntity *pEntity;
1421 char *prop;
1422 edict_t *pEdict;
1423
1424 if (!IndexToAThings(params[1], &pEntity, &pEdict))
1425 {
1426 return pContext->ThrowNativeError("Entity %d (%d) is invalid", g_HL2.ReferenceToIndex(params[1]), params[1]);
1427 }
1428
1429 pContext->LocalToString(params[3], &prop);
1430
1431 switch (params[2])
1432 {
1433 case Prop_Data:
1434 {
1435 typedescription_t *td;
1436
1437 FIND_PROP_DATA(td);
1438
1439 return td->fieldSize;
1440 }
1441 case Prop_Send:
1442 {
1443 sm_sendprop_info_t info;
1444
1445 ServerClass *pServerClass = g_HL2.FindEntityServerClass(pEntity);
1446 if (pServerClass == nullptr)
1447 {
1448 return pContext->ThrowNativeError("Failed to retrieve entity %d (%d) server class!", g_HL2.ReferenceToIndex(params[1]), params[1]);
1449 }
1450
1451 if (!g_HL2.FindSendPropInfo(pServerClass->GetName(), prop, &info))
1452 {
1453 const char *class_name = g_HL2.GetEntityClassname(pEntity);
1454 return pContext->ThrowNativeError("Property \"%s\" not found (entity %d/%s)",
1455 prop,
1456 params[1],
1457 ((class_name) ? class_name : ""));
1458 }
1459
1460 if (info.prop->GetType() == DPT_Array)
1461 {
1462 return info.prop->GetNumElements();
1463 }
1464
1465 if (info.prop->GetType() != DPT_DataTable)
1466 {
1467 return 0;
1468 }
1469
1470 SendTable *pTable = info.prop->GetDataTable();
1471 if (!pTable)
1472 {
1473 return pContext->ThrowNativeError("Error looking up DataTable for prop %s", prop);
1474 }
1475

Callers

nothing calls this directly

Calls 7

IndexToAThingsFunction · 0.85
ReferenceToIndexMethod · 0.80
FindEntityServerClassMethod · 0.80
FindSendPropInfoMethod · 0.80
GetEntityClassnameMethod · 0.80
GetTypeMethod · 0.80
GetNameMethod · 0.45

Tested by

no test coverage detected