static cell_t sm_IsClientSourceTV(IPluginContext *pCtx, const cell_t *params) { int index = params[1]; if ((index < 1) || (index > playerhelpers->GetMaxClients())) { return pCtx->ThrowNativeError("Client index %d is invalid", index); } IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(index); if (!pPlayer->IsConnected()) { return pCtx->ThrowNativeError("Client %d is not connected", index); } return (pPlayer->IsSourceTV()) ? 1 : 0; }
void Conditions_OnGameFrame(bool simulating) { if (!simulating) return; static condbitvec_t newconds; static condbitvec_t addedconds; static condbitvec_t removedconds; int maxClients = gpGlobals->maxClients; for (int i = 1; i <= maxClients; i++) { IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(i); if (!pPlayer->IsInGame() || pPlayer->IsSourceTV() || pPlayer->IsReplay()) continue; CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(i); condbitvec_t &oldconds = g_PlayerActiveConds[i]; GetPlayerConds(pEntity, &newconds); if (oldconds == newconds) continue; CondBitVecAndNot(newconds, oldconds, &addedconds); CondBitVecAndNot(oldconds, newconds, &removedconds); int bit; bit = -1; while ((bit = addedconds.FindNextSetBit(bit + 1)) != -1) { g_addCondForward->PushCell(i); g_addCondForward->PushCell(bit); g_addCondForward->Execute(NULL, NULL); } bit = -1; while ((bit = removedconds.FindNextSetBit(bit + 1)) != -1) { g_removeCondForward->PushCell(i); g_removeCondForward->PushCell(bit); g_removeCondForward->Execute(NULL, NULL); } g_PlayerActiveConds[i] = newconds; } }