Well there's a little too much code to post, but here's the basics.
My plugin has two arrays:
Code:
any g_Entity[2049];
EntityType g_EntityType[2049];
When the map starts, every entity on the map is given one of my subclasses of Dynamic. Whether it be BEntity, BNpc, BDoor, etc. Every entity on the map, and every entity created later on is given an associated object and type stored in the two above arrays.
When the player presses E on an NPC for instance, the plugin does this:
Code:
int iEnt = player.GetAimTarget(); //player is a BClient, representing a Client. No problems here
if(iEnt > 0 && iEnt < 2049 && g_EntityType[iEnt] == EntityType_Npc)
{
BNpc npc = g_Entity[iEnt];
npc.PressE(player); //this is where the problem eventually happens
}