static int runClientScript(lua_State* inState) { // Get entity index int theIndex = lua_tonumber(inState, 1); if(theIndex > 0) { // Look it up CBaseEntity* theEntity = CBaseEntity::Instance(g_engfuncs.pfnPEntityOfEntIndex(theIndex)); if(theEntity) { AvHPlayer* thePlayer = dynamic_cast<AvHPlayer*>(theEntity); if(thePlayer) { const char* theScript = lua_tostring(inState, 2); if(theScript != NULL) { thePlayer->RunClientScript(theScript); } } } } return 0; }