alliedmodders / amxmodx

AMX Mod X - Half-Life 1 Scripting and Administration
http://www.amxmodx.org/
494 stars 197 forks source link

Miscstats plugin: Incorrect displaying of enemy remaining team name #560

Closed all85100 closed 5 years ago

all85100 commented 6 years ago

I like Amxmodx, some questions feedback, please fix Miscstats plugin: enemyremaining team name display error, when the enemy was killed one person, the remaining enemy team name wrong display set up their own team name, the remaining number and team name is not synchronized. The old Miscstats plugin, after the death of the teammate, does not show the enemyremaining function, in the 1.9.0 also shows but does not correspond, I think this is a new feature, it should be, after the death of teammates show how many people and their team name, the enemy after the death shows how many people and the enemy team name, I come from China, English is not very good. If you don't understand me, please let me know.

WPMGPRoSToTeMa commented 6 years ago

So, the team name is correct, but the player count is invalid?

all85100 commented 6 years ago

No, on the contrary, the team's death count is correct, the team's display name is wrong, but now its own team has also activated the Enemyremaining function after death, which was not shown previously, hoping as a new feature to fix him, After the death of the enemy or our teammates show the remaining number and the corresponding team name, and can be in the Stats.ini control show which side or all show,,, the necessity is not small, but also reasonable!

all85100 commented 6 years ago

Why didn't anyone fix this bug?

Arkshine commented 6 years ago

Because someone needs to investigate and it looks like no has the time or not interested. I can't do everything. Other people need to contribute. Keep in mind everyone is volunteers. Maybe @OciXCrom can try to give a look.

OciXCrom commented 6 years ago

I honestly failed to understand what the actual issue is. Can you maybe post an image showing the problem?

Arkshine commented 6 years ago

Looking at the beautiful code:

    new team = get_user_team(victim)
    if (EnemyRemaining && is_user_connected(victim))
    {
        if( TEAM_T <= team <= TEAM_CT )
        {
            new ppl[MAX_PLAYERS], pplnum, epplnum, a
            get_players(ppl, epplnum, "ae", team == TEAM_T ? "CT" : "TERRORIST")
            get_players(ppl, pplnum, "ae", team == TEAM_T ? "TERRORIST" : "CT")
            if( victim_alive )
            {
                for(a=0; a<pplnum; a++)
                {
                    if( ppl[a] == victim )
                    {
                        ppl[a] = ppl[--pplnum]
                        break
                    }
                }
            }

            if (pplnum && epplnum)
            {
                new message[128], team_name[32]

                set_hudmessage(255, 255, 255, 0.02, 0.85, 2, 0.05, 0.1, 0.02, 3.0, -1)

                /* This is a pretty stupid thing to translate, but whatever */
                new _teamname[32]
                if (team == TEAM_T)
                {
                    formatex(_teamname, charsmax(_teamname), "TERRORIST%s", (epplnum == 1) ? "" : "S")
                } else {
                    formatex(_teamname, charsmax(_teamname), "CT%s", (epplnum == 1) ? "" : "S")
                }

                new id
                for (a = 0; a < pplnum; ++a)
                {
                    id = ppl[a]
                    formatex(team_name, charsmax(team_name), "%L", id, _teamname)
                    formatex(message, charsmax(message), "%L", id, "REMAINING", epplnum, team_name)
                    ShowSyncHudMsg(id, g_bottom_sync, "%s", message)
                }
            }
        }
    }

I think the _teamname needs be reversed. The message shows the number of remaining enemies and the enemy team name is not correct.

new _teamname[32]
if (team == TEAM_T)
{
    formatex(_teamname, charsmax(_teamname), "TERRORIST%s", (epplnum == 1) ? "" : "S")
} else {
    formatex(_teamname, charsmax(_teamname), "CT%s", (epplnum == 1) ? "" : "S")
}
formatex(team_name, charsmax(team_name), "%L", id, _teamname)
formatex(message, charsmax(message), "%L", id, "REMAINING", epplnum, team_name)

team_name is based on the victim's team, so if we want to show the enemy team name, _teamname formatting should be reversed. It should be:

if (team == TEAM_T)
{
    formatex(_teamname, charsmax(_teamname), "CT%s", (epplnum == 1) ? "" : "S")
} else {
    formatex(_teamname, charsmax(_teamname), "TERRORIST%s", (epplnum == 1) ? "" : "S")
}
all85100 commented 6 years ago

default When a teammate dies, the remaining number shows an error. default When the enemy is dead and nothing is displayed, the enemy's remaining number and team name should be displayed.

all85100 commented 6 years ago

Simply put, when a teammate or enemy dies, the remaining number and team name should be the corresponding

这在以前只有敌人死亡才会显示,我觉得应该改成队友或者敌人死亡都显示

Arkshine commented 6 years ago

Yeah, the player's list to send to the message to and the team name are reversed. The code is really confusing.

If we should have a clear definition of EnemyRemaining option, it should be:

Each time an enemy is killed, a hud message is sent to the killer's teammates (including killer) displaying the remaining enemies count.

Right?

all85100 commented 6 years ago

Yes, You Are right!I have modified it on the basis of the old version, but I want to show the remaining number and team name after the death of my teammates or enemies.

new team = get_user_team(victim) if (EnemyRemaining && is_user_connected(victim)) { if (team == TEAM_T || team == TEAM_CT) { new ppl[MAX_PLAYERS], pplnum = 0, epplnum = 0, a, other_team, maxplayers = get_maxplayers() new enemy_team = (team == TEAM_T) ? TEAM_CT : TEAM_T
for (new i=1; i<=maxplayers; i++) { if (!is_user_connected(i)) { continue } if (i == victim) { continue } other_team = get_user_team(i) if (other_team == team && is_user_alive(i)) { epplnum++ } else if (other_team == enemy_team) { ppl[pplnum++] = i } }

        if (pplnum && epplnum)
        {
            new message[128], team_name[32]

            set_hudmessage(255, 255, 255, 0.01, 0.90, 2, 0.05, 0.1, 0.02, 3.0, -1)

            /* This is a pretty stupid thing to translate, but whatever */
            new _teamname[32]
            if (team == TEAM_T)
            {
                formatex(_teamname, charsmax(_teamname), "TERRORIST%s", (epplnum == 1) ? "" : "S")
            } else {
                formatex(_teamname, charsmax(_teamname), "CT%s", (epplnum == 1) ? "" : "S")
            }

            new id
            for (a = 0; a < pplnum; ++a)
            {
                id = ppl[a]
                formatex(team_name, charsmax(team_name), "%L", id, _teamname)
                formatex(message, charsmax(message), "%L", id, "REMAINING", epplnum, team_name)
                ShowSyncHudMsg(id, g_bottom_sync, "%s", message)
            }
        }
    }
}
Arkshine commented 6 years ago

The changes in this file part of the plugin are from https://github.com/alliedmodders/amxmodx/commit/9e4fe0d51438cd96653f4a6e6a51d95b6f941162#diff-3afb3f242934c594b97f6626a9655704L313.

The bug is there:

get_players(ppl, epplnum, "ae", team == TEAM_T ? "CT" : "TERRORIST")
get_players(ppl, pplnum, "ae", team == TEAM_T ? "TERRORIST" : "CT")

The first line is to get the enemies list. The second line is to get the number of the victim's teammates, but it overwrites the list above.

I would rearrange the code like that, atleast to be a little more understable:

if (EnemyRemaining && TEAM_T <= team <= TEAM_CT && is_user_connected(victim))
{
    static const teamIdentifiers[][] = { "", "TERRORIST", "CT" };
    new const victimTeammatesCount = get_playersnum_ex(GetPlayers_ExcludeDead | GetPlayers_MatchTeam, teamIdentifiers[team]);

    if (victimTeammatesCount)
    {
        new killerTeammatesList[MAX_PLAYERS], killerTeammatesCount;
        get_players_ex(killerTeammatesList, killerTeammatesCount, GetPlayers_ExcludeDead | GetPlayers_MatchTeam, teamIdentifiers[(team % 2) + 1]);

        if (killerTeammatesCount)
        {
            set_hudmessage(255, 255, 255, 0.02, 0.85, 2, 0.05, 0.1, 0.02, 3.0, -1);

            new teamNameKeylang[16], teamName[32];
            formatex(teamNameKeylang, charsmax(teamNameKeylang), "%s%s", teamIdentifiers[team], victimTeammatesCount > 1 ? "S" : "");

            for (new teammate, id; teammate < killerTeammatesCount; ++teammate)
            {
                id = killerTeammatesList[teammate];

                formatex(teamName, charsmax(teamName), "%L", id, teamNameKeylang);
                ShowSyncHudMsg(id, g_bottom_sync, "%l", "REMAINING", victimTeammatesCount, teamName);
            }
        }
    }
}

It removes the check with victim_alive (when you suicide) because it was doing that on the wrong list. It's not needed anymore here. Essentially, when a player dies (victim, suicide, team kill), the opposite team will be always notified (on alive players of course).

all85100 commented 6 years ago

default

Should be plural display

fix: formatex(teamNameKeylang, charsmax(teamNameKeylang), "%s%s", teamIdentifiers[team], victimTeammatesCount == 1 ? "" : "S");

Arkshine commented 6 years ago

The check was reversed, but you can do that too.

rsKliPPy commented 6 years ago

I don't think we should do that, it doesn't apply to all languages. Nobody notices those things, and even if they do, they wouldn't care.

Arkshine commented 6 years ago

Actually, I would probably rename the team name with "enemy/enemies".