Azelphur / SourceIRC

An easy to use SourcePawn API to the IRC protocol.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

L4D2 dont show when a bot connects/quits

CanadianJeff opened this issue · comments

otherwise flooded with crap like....

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

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)) {
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);
		}
	}
}

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.

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