if (IsPlayerConnected(i) && !IsPlayerNPC(i))
// replace:for (new i=0; i < MAX_PLAYERS; i++)// with:for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)