PRO TIP: When posting, always specify the game you are referring to since SourceMod is used in over a dozen games.
Since you didn't specify a game, we'll work on a solution that should work with most Source Games. To do that, we'll need to find the right event to hook. We'll look here and will select 'Generic Source Events':
https://wiki.alliedmods.net/Game_Events_(Source)
If we look at player_death under generic events we see that the game reports the userid of the player killed and the userid of the attacker who killed him.
So... we can 'hook' the death event, get the userids of the killer and the victim. We can then check to see if the player is human and the attacker is a Bot. If so, we can print their names to chat.
The code would look like this:
PHP Code:
#pragma semicolon 1
#pragma newdecls required
#define PLUGIN_VERSION "1.0"
public Plugin myinfo =
{
name = "Killed by Bot",
author = "nikitos1ck",
description = "Sends message to chat when a human player is killed by a Bot",
version = PLUGIN_VERSION,
url = "www.sourcemod.com"
}
public void OnPluginStart()
{
HookEvent("player_death", Event_Death, EventHookMode_Post);
}
public void Event_Death(Handle event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(GetEventInt(event, "userid"));
int attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
if (!IsFakeClient(client) && IsFakeClient(attacker))
{
PrintToChatAll("Human player %N was killed by Bot named %N", client, attacker);
}
}
Translated, it says that when a player dies, and if the dead person isn't a Bot, and the killer is a bot, type a sentence containing their names in chat.
Let us know if you have any questions. Happy to help.