Raised This Month: $32 Target: $400
 8% 

Solved How to achieve cumulative effect on death pool?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
damage220
Member
Join Date: Jul 2022
Location: Ukraine
Old 12-02-2022 , 12:33   How to achieve cumulative effect on death pool?
Reply With Quote #1

Hi, guys. I cannot figure out how to summarize all kills made with, say, he grenade or awp. I want to allow players to set money showing their kills and the problem here is not to update money, since I have all the necessary messages, but a fact that game engine processes death messages one by one and so when someone kills multiple enemies at once, the hud always shows +1 kill, though the total number of kills is correct. I want it to be cumulative, how to make it show +2, ..., +5 kills? I did some message logging, and here is what I got:
PHP Code:
[36.621555ham_killed_pre
[36.621555DeathMsg (83)
[
36.621555death_event
[36.621555Health (70)
[
36.621555ham_killed_post
[36.621555ham_killed_pre
[36.621555DeathMsg (83)
[
36.621555death_event
[36.621555Health (70)
[
36.621555ham_killed_post
[36.621555ham_killed_pre
[36.621555DeathMsg (83)
[
36.621555death_event
[36.621555Health (70)
[
36.621555ham_killed_post
[36.621555ham_killed_pre
[36.621555DeathMsg (83)
[
36.621555death_event
[36.621555Health (70)
[
36.621555ham_killed_post
killed phillip_style with grenade
killed -=Sh0rTy=- with grenade
killed bussemann with grenade
killed The Muffin Man with grenade
[36.630783Health (70)
[
36.630783Damage (71)
client_death36.630783
[36.630783Health (70)
[
36.630783Damage (71)
client_death36.630783
[36.634681Health (70)
[
36.661983Health (70)
[
36.661983Damage (71)
client_death36.661983
[36.661983Health (70)
[
36.661983Damage (71)
client_death36.661983
[36.794578death_msg_timer
[36.794578death_msg_timer
[36.794578death_msg_timer
[36.794578death_msg_timer 
You can see that most vital DeathMsg messages are all at one frame with gametime: 36.621555. The problem here is that I do not know where the last kill is. So I need something that is called after all these messages and to be sure it is called all the time.
1. I wish I could rely on client_death, but this forward is not triggered on suicide (team change) or amxmodx user_slap( function.
2. I tried to use set_task_ex(0.01, "death_msg_timer") to set a timer, but for some reason it takes too much time to execute the code (173 ms)
3. Damage message appears to be triggered after all DeathMsg messages, but again it is not triggered on team change, etc...
I completely lost at this point. Is the timer single possible solution to this problem? Except client_preThink which I do not want to consider actually.

Is it possible to somehow catch these console messages?
PHP Code:
killed phillip_style with grenade
killed -=Sh0rTy=- with grenade
killed bussemann with grenade
killed The Muffin Man with grenade 
They have perfect timing)

Ps: for those who have no idea what I am talking about, please see attachments (notice +1 above 4).
Attached Thumbnails
Click image for larger version

Name:	20221202192746_1.jpg
Views:	80
Size:	86.6 KB
ID:	198281  

Last edited by damage220; 12-02-2022 at 13:41.
damage220 is offline
damage220
Member
Join Date: Jul 2022
Location: Ukraine
Old 12-02-2022 , 13:40   Re: How to achieve cumulative effect on death pool?
Reply With Quote #2

I am sorry, I spent many hours with no success to achieve this goal and only after creating this thread I have found out that there is a function RequestFrame. I hope this will help someone in the future.
damage220 is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 12-02-2022 , 15:12   Re: How to achieve cumulative effect on death pool?
Reply With Quote #3

You can create a player global variable and store in it the current gametime when the player dies/killed, and update the players kills after one or two seconds passed from the last kill.

PHP Code:
new Float:g_fLastKillTime[33], g_UserComboFrags[33];

// HOOKED via ham sandwich module.
public fwPlayerKilledPost( const vId, const kId, const bool:shouldgib )
{
   if(!
is_user_connected(kId)) return;
   
g_fLastKillTime[kId] = get_gametime();
   
g_UserComboFrags[kId] ++;

   
set_task(1.25"UpdatePlayer"kId);
}

public 
UpdatePlayer(id)
{
   if( ( 
get_gametime() - g_fLastKillTime[id] ) >= 1.0 )
   {
       
// do your stuff...
   
}

__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 12-02-2022 at 15:28.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
damage220
Member
Join Date: Jul 2022
Location: Ukraine
Old 12-02-2022 , 15:45   Re: How to achieve cumulative effect on death pool?
Reply With Quote #4

Quote:
Originally Posted by Natsheh View Post
You can create a player global variable and store in it the current gametime when the player dies/killed, and update the players kills after one or two seconds passed from the last kill.

PHP Code:
new Float:g_fLastKillTime[33], g_UserComboFrags[33];

// HOOKED via ham sandwich module.
public fwPlayerKilledPost( const vId, const kId, const bool:shouldgib )
{
   if(!
is_user_connected(kId)) return;
   
g_fLastKillTime[kId] = get_gametime();
   
g_UserComboFrags[kId] ++;

   
set_task(1.25"UpdatePlayer"kId);
}

public 
UpdatePlayer(id)
{
   if( ( 
get_gametime() - g_fLastKillTime[id] ) >= 1.0 )
   {
       
// do your stuff...
   
}

I could but I do not like delayed response. I am pretty happy with the solution I posted above.
damage220 is offline
kww
Senior Member
Join Date: Feb 2021
Location: Russia
Old 12-03-2022 , 05:12   Re: How to achieve cumulative effect on death pool?
Reply With Quote #5

very poor implementation for just hooking grenade multikill
Quote:
zettai ryouiki (RADIO): Fire in the hole!
zettai ryouiki killed Albert with grenade
zettai ryouiki killed Norm with grenade
zettai ryouiki killed Henry with grenade
zettai ryouiki killed Niles with grenade
zettai ryouiki killed Ernie with grenade
zettai ryouiki killed Jason with grenade
zettai ryouiki killed Ulric with grenade
# Entity 121 is thinking! Beware!
# zettai ryouiki made 7 kills in this tick!
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 
attackerattacker read_data(1);

    if(!
is_user_connected(attacker))
        return;
    
    
g_kills[attacker]++;
    
set_pev(g_iEntitypev_nextthinkget_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(playersplayerCountGetPlayers_ExcludeDead GetPlayers_ExcludeHLTV);

    static 
id;

    for(new 
iplayerCounti++)
    {
        
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!"idg_kills[id])

            
// but reset it after your operations
            
g_kills[id] = 0;
        }
    }

__________________
Now working on: Side Weapons (Very lazy, tbh)
Avatar source: https://bit.ly/3BAk19g
Discord: kww#9951

Last edited by kww; 12-03-2022 at 05:23.
kww is offline
damage220
Member
Join Date: Jul 2022
Location: Ukraine
Old 12-04-2022 , 14:27   Re: How to achieve cumulative effect on death pool?
Reply With Quote #6

Quote:
Originally Posted by kww View Post
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 
attackerattacker read_data(1);

    if(!
is_user_connected(attacker))
        return;
    
    
g_kills[attacker]++;
    
set_pev(g_iEntitypev_nextthinkget_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(playersplayerCountGetPlayers_ExcludeDead GetPlayers_ExcludeHLTV);

    static 
id;

    for(new 
iplayerCounti++)
    {
        
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!"idg_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.
damage220 is offline
kww
Senior Member
Join Date: Feb 2021
Location: Russia
Old 12-05-2022 , 08:14   Re: How to achieve cumulative effect on death pool?
Reply With Quote #7

Quote:
Originally Posted by damage220 View Post
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.
This was a good experience on making thinking entities for me
__________________
Now working on: Side Weapons (Very lazy, tbh)
Avatar source: https://bit.ly/3BAk19g
Discord: kww#9951
kww is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:41.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode