While I don't have any interest in this plugin, I do feel the need to explain why your code doesn't work.
To begin your logic is correct. Your first code snippet will not work as Witch is not a playable character, therefore the event and its subsequent function Event_PlayerDeath will not work. A little background on the game events.
PHP Code:
// We hook the event here. Done in OnPluginStart function.
HookEvent("player_death", Event_PlayerDeath);
//This is the function that gets called after the hook.
public Action Event_PlayerDeath(Event hEvent, const char[] strName, bool DontBroadcast)
{
}
You can read about all the events on this page.
https://wiki.alliedmods.net/Left_4_Dead_2_Events
Now the good thing is that if you look at the events page you can find an event dedicated to witch's death named witch_killed.
Applying the same logic from above, you can hook it and create a new function.
PHP Code:
// We hook the event here.
HookEvent("witch_killed", Event_WitchKilled);
//This is the function that gets called after the hook.
public Action Event_WitchKilled(Event hEvent, const char[] strName, bool DontBroadcast)
{
// This code will run every time a witch is killed.
}
The way the plugin is coded is that everytime Event_PlayerDeath is called it checks who died, were they a zombie and what class they were. Once that is done, it calls this code below.
PHP Code:
// This is if the zombie class was Tank
for (int i = 0; i < GetConVarInt(l4d2_loot_t_drop_items) + GetConVarInt(l4d2_loot_g_bonus); i++)
LootDropItem(Target, GetRandomItem(GetRandomGroup("Tank")));
There are three functions above.
- LootDropItem
- GetRandomItem
- GetRandomGroup
First two you can use as is as they are not dependent on the zombie class. However last one accepts zombie name as a string. Notice "Tank" ?? I would say for starting just use the string for "Tank" or another SI that already exists in the code as you are still learning.
To combine everything from above, you want to run the code when witch is killed.
PHP Code:
// We hook the event here.
HookEvent("witch_killed", Event_WitchKilled);
//This is the function that gets called after the hook.
public Action Event_WitchKilled(Event hEvent, const char[] strName, bool DontBroadcast)
{
// Now we can check for whether the a few things listed on the events page as to who killed the witch, what was the entity ID of the witch, was it one shot kill, was it a melee and if it was bride variant. But for now lets ignore those things and keep it simple.
// This is if the zombie class was Tank
for (int i = 0; i < GetConVarInt(l4d2_loot_t_drop_items) + GetConVarInt(l4d2_loot_g_bonus); i++)
LootDropItem(Target, GetRandomItem(GetRandomGroup("Tank")));
}
The above code would lead to sharing the same cvars for witch drop as they are set for Tank.
Its a learning process and I did not test the above code at all, but just went with the snippets from the existing code. Hopefully it would get you started somewhere. Feel free to ask questions.
__________________