Azelphur / SourceIRC

An easy to use SourcePawn API to the IRC protocol.
6 stars 9 forks source link

L4D2 dont show when a bot connects/quits #15

Open CanadianJeff opened 3 years ago

CanadianJeff commented 3 years ago

otherwise flooded with crap like....

chew toy <3 connected. Zoey connected. Francis connected. Louis connected. Louis disconnected (Kicked by Console : survivor bot left the survivor team). Spitter connected. Charger connected. Boomer connected. Spitter disconnected (Kicked by Console : death anim finished). Smoker connected. Boomer disconnected (Kicked by Console : death anim finished). Charger disconnected (Kicked by Console : death anim finished). allenmc2008 connected. Francis disconnected (Kicked by Console : survivor bot left the survivor team). Spitter connected. allenmc2008 disconnected ([Little Anti-Cheat 1.6.3] Bhop Detected). Francis connected. Smoker disconnected (Kicked by Console : death anim finished). Spitter disconnected (Kicked by Console : death anim finished). -- Map Changing -- -- Map Changed to c8m2_subway -- Zoey connected. Francis connected. Louis connected. Louis disconnected (Kicked by Console : survivor bot left the survivor team). Bill connected.
JoinedSenses commented 3 years ago

If youd like to add this feature to your own, add an IsFakeClient(client) check after line 125 of sourceirc-relayall and also on line 137 of Event_PlayerDisconnect

    if (userid <= g_userid) // Ugly hack to get around mass connects on map change
        return;
    g_userid = userid;
    if (IsFakeClient(client))
        return;
    decl String:playername[MAX_NAME_LENGTH], String:result[IRC_MAXLEN];
    GetClientName(client, playername, sizeof(playername));
        new userid = GetEventInt(event, "userid");
        new client = GetClientOfUserId(userid);
        if (client != 0 && !IsFakeClient(client)) {
CanadianJeff commented 3 years ago
public void OnClientAuthorized(client, const String:auth[]) { // We are hooking this instead of the player_connect event as we want the steamid
    if (IsFakeClient(client)) return; // Please dont spam about bots
    new userid = GetClientUserId(client);
    if (userid <= g_userid) // Ugly hack to get around mass connects on map change
        return;
    g_userid = userid;
    decl String:playername[MAX_NAME_LENGTH], String:result[IRC_MAXLEN];
    GetClientName(client, playername, sizeof(playername));
    Format(result, sizeof(result), "%t", "Player Connected", playername, auth, userid);
    if (result[0] != '\0')
        IRC_MsgFlaggedChannels("relay", "%s", result);
}

public Action:Event_PlayerDisconnect(Handle:event, const String:name[], bool:dontBroadcast)
{   
    if (!GetConVarBool(g_cvHideDisconnect)) {
        new userid = GetEventInt(event, "userid");
        new client = GetClientOfUserId(userid);
        if (client != 0) {
            if (IsFakeClient(client)) return; // Please dont spam about bots
            decl String:reason[128], String:playername[MAX_NAME_LENGTH], String:auth[64], String:result[IRC_MAXLEN];
            GetEventString(event, "reason", reason, sizeof(reason));
            GetClientName(client, playername, sizeof(playername));
            GetClientAuthString(client, auth, sizeof(auth));
            for (new i = 0; i <= strlen(reason); i++) { // For some reason, certain disconnect reasons have \n in them, so i'm stripping them. Silly valve.
                if (reason[i] == '\n')
                    RemoveChar(reason, sizeof(reason), i);
            }
            Format(result, sizeof(result), "%t", "Player Disconnected", playername, auth, userid, reason);
            if (result[0] != '\0')
                IRC_MsgFlaggedChannels("relay", "%s", result);
        }
    }
}
JoinedSenses commented 3 years ago

That works. If I were to add this feature, it would come with a convar for toggling. Will leave this issue open in the mean time.

Azelphur commented 3 years ago

A PR that adds it as a convar would be appreciated :)