Mentrillum / Slender-Fortress-Modified-Versions

A modification of Team Fortress 2 based on the game Slender: The Eight Pages.
GNU General Public License v3.0
34 stars 23 forks source link

[Suggestion] Server Support for Command_GetBossIndexes #22

Closed MAGNAT2645 closed 3 years ago

MAGNAT2645 commented 3 years ago

Would be good to add server support to callback Command_GetBossIndexes (and perhaps to other debug commands) because when you run sm_sf2_getbossindexes command from server console (or via rcon), SM throws this error:

L 01/24/2021 - 15:15:28: [SM] Exception reported: Client index 0 is invalid
L 01/24/2021 - 15:15:28: [SM] Blaming: disabled/sf2.smx
L 01/24/2021 - 15:15:28: [SM] Call stack trace:
L 01/24/2021 - 15:15:28: [SM]   [0] ClientCommand

Code snippet:

public Action Command_GetBossIndexes(int iClient,int args)
{
    if (!g_bEnabled) return Plugin_Continue;

    char sMessage[512];
    char sProfile[SF2_MAX_PROFILE_NAME_LENGTH];

    if ( iClient == 0 )
        PrintToServer( "Active Boss Indexes:\n----------------------------" );
    else {
        ClientCommand(iClient, "echo Active Boss Indexes:");
        ClientCommand(iClient, "echo ----------------------------");
    }

    for (int i = 0; i < MAX_BOSSES; i++)
    {
        if (NPCGetUniqueID(i) == -1) continue;

        NPCGetProfile(i, sProfile, sizeof(sProfile));

        FormatEx(sMessage, sizeof(sMessage), "%d - %s", i, sProfile);
        if (NPCGetFlags(i) & SFF_FAKE)
        {
            StrCat(sMessage, sizeof(sMessage), " (fake)");
        }

        if (g_iSlenderCopyMaster[i] != -1)
        {
            char sCat[64];
            FormatEx(sCat, sizeof(sCat), " (copy of %d)", g_iSlenderCopyMaster[i]);
            StrCat(sMessage, sizeof(sMessage), sCat);
        }

        if ( iClient == 0 )
            PrintToServer( "%s", sMessage );
        else
            ClientCommand(iClient, "echo %s", sMessage);
    }

    if ( iClient != 0 ) {
        ClientCommand(iClient, "echo ----------------------------");
        ReplyToCommand(iClient, "Printed active boss indexes to your console!");
    }

    return Plugin_Handled;
}

EDIT: Also you should disable DEBUG macro by default.

Mentrillum commented 3 years ago

Will look into this, should be fixed when the final build comes out

Mentrillum commented 3 years ago

Bug has since then been fixed.