|
Author
|
Message
|
|
Senior Member
Join Date: Jul 2022
Location: Ukraine
|

12-04-2022
, 14:27
Re: How to achieve cumulative effect on death pool?
|
#1
|
Quote:
Originally Posted by kww
very poor implementation for just hooking grenade multikill
PHP Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include hamsandwich
#include amxmisc
new g_iEntity;
new g_kills[MAX_PLAYERS+1];
public plugin_init()
{
register_plugin("ggf","d","a");
g_iEntity = create_entity("info_target");
console_print(0, "created entity %i", g_iEntity);
register_event("DeathMsg", "Event_DeathMsg", "a")
RegisterHam(Ham_Think, "info_target", "Ham_info_target_Think");
}
public Event_DeathMsg()
{
static attacker; attacker = read_data(1);
if(!is_user_connected(attacker))
return;
g_kills[attacker]++;
set_pev(g_iEntity, pev_nextthink, get_gametime() + 0.05); // if you do grenade multikill, all kills will happen at the same tick
}
public Ham_info_target_Think(iEnt)
{
console_print(0, "^t# Entity %i is thinking! Beware!", iEnt);
if(iEnt != g_iEntity)
return;
new players[MAX_PLAYERS], playerCount;
get_players_ex(players, playerCount, GetPlayers_ExcludeDead | GetPlayers_ExcludeHLTV);
static id;
for(new i; i < playerCount; i++)
{
id = players[i];
if(g_kills[id])
{
// do whatever you want with kills value
console_print(0, "^t# %n made %i kills in this tick!", id, g_kills[id])
// but reset it after your operations
g_kills[id] = 0;
}
}
}
|
Thanks, kww. I did it in similar way except that I prefer RequestFrame much more and I take into account other kills like c4 explosion or gun shot.
|
|
|
|