MapManagerModular icon indicating copy to clipboard operation
MapManagerModular copied to clipboard

[Suggestion] get_players_num should return playing bots too

Open di57inct opened this issue 1 year ago • 2 comments

It can also be optimized by using get_players instead.

stock get_players_num(ignore = 0)
{
    static maxplayers;
    if(!maxplayers) {
        maxplayers = get_maxplayers();
    }
    new pnum, team;
    for(new i = 1; i <= maxplayers; i++) {
        if(ignore > 0 && i == ignore
            || !is_user_connected(i)
            || is_user_hltv(i)) {
            continue;
        }

		team = get_user_team(i);

        if((team == 0 || team == 3) && (ignore == -1 || is_user_bot(i))) {
            continue;
        }

        pnum++;
    }
    return pnum;
}

di57inct avatar Jul 06 '24 19:07 di57inct

get_players_num should return playing bots too

Any reason for this?

It can also be optimized by using get_players instead.

Nope

Mistrick avatar Jul 07 '24 06:07 Mistrick

Any reason for this?

let's say you have small maps(like dust2x2 for example) defined in the map list file where you want a maximum of 16 players on them and you have 15 players on the server and 10 bots and it ends up changing to that map even if there are actually 25 actively playing slots

Nope

current code uses at least 4 natives for each player * 32 = 128 native calls when you can use just 3 or 4 with get_players but i guess it doesn't matter that much since the stock is called just a few times per map

di57inct avatar Jul 07 '24 08:07 di57inct