Mistrick / MapManagerModular

28 stars 21 forks source link

[Suggestion] get_players_num should return playing bots too #56

Open di57inct opened 1 week ago

di57inct commented 1 week ago

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;
}
Mistrick commented 1 week ago

get_players_num should return playing bots too

Any reason for this?

It can also be optimized by using get_players instead.

Nope

di57inct commented 1 week ago

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