Raised This Month: $51 Target: $400
 12% 

how to catch multikill ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mewbie222
Senior Member
Join Date: May 2018
Old 11-03-2018 , 17:02   how to catch multikill ?
Reply With Quote #1

how to catch multikill - murder from 2-3 and so on. players ? Tell me the correct code .. But it is unclear how it correctly to write .. Thanks in advance .
mewbie222 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 11-04-2018 , 05:22   Re: how to catch multikill ?
Reply With Quote #2

cs:s events


Little tricky, server can fire multiple events in same 'tick'.
So weapon_fire and player_deaths happen in same time.
We need tiny delay for this. With timer or RequestFrame().

Here is my example.
In this, you get new callback "nextframe" where you can check how many kills player did in same single 'tick' count.

PHP Code:

int KillCount
[MAXPLAYERS+1]; // array, keep record player kills (temporary)

public void OnPluginStart()
{
    
HookEventEx("player_death"player_death);
}

public 
void player_death(Event event, const char[] namebool dontBroadcast)
{

    
int userid event.GetInt("attacker");
    
int attacker GetClientOfUserId(userid);

    
// attacker is not valid client index
    
if(attacker <= || attacker MaxClients) return;


    
// when player kill count is reset (0), trigger nextframe callback
    
if(KillCount[attacker] == 0)
    {
        
DataPack data = new DataPack();
        
data.WriteCell(attacker);    // store client index to use later in KillCount array
        
data.WriteCell(userid);        // store client userid to find him later in game
        
data.Reset();

        
RequestFrame(nextframedata); // callback will fire after tiny delay
    
}

    
KillCount[attacker]++; // +1 kill
}


public 
void nextframe(DataPack data)
{

    
int slot data.ReadCell(); // attacker client index
    
int attacker data.ReadCell(); // attacker userid
    
delete data;

    
// Reset KillCount[] at the beginning of code, so any error at this forward not disturb this counter system. Safety :)
    
int kills KillCount[slot];
    
KillCount[slot] = 0// reset



    
attacker GetClientOfUserId(attacker); // find attacker client index again

    // attacker client index found and is in game
    
if(attacker != && IsClientInGame(attacker))
    {
        
PrintToServer("%N kill count %i - Tick %i"attackerkillsGetGameTickCount());
    }


__________________
Do not Private Message @me
Bacardi is offline
mewbie222
Senior Member
Join Date: May 2018
Old 11-04-2018 , 06:56   Re: how to catch multikill ?
Reply With Quote #3

Thank you, I will try to understand .. Yes here it is interesting, and how then in QuakeSounds all this is realized ? In the same way , too, there are all sorts of multikills .. by the way here found the piece of code from quake sound
PHP Code:
public EventPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{    
    new 
attackerClient GetClientOfUserId(GetEventInt(event"attacker"));
    new 
victimClient GetClientOfUserId(GetEventInt(event"userid"));
    
    new 
soundId = -1;
    new 
killsValue 0;

    if(
victimClient<|| victimClient>iMaxClients)
    {
        return;
    }
    
    if(
attackerClient>&& attackerClient<=iMaxClients)
    {
        if(
attackerClient == victimClient)
        {
            if(
settingConfig[SELFKILL][NOT_BASED_ON_KILLS])
            {
                
soundId SELFKILL;
            }
        }
        else if(
GetClientTeam(attackerClient) == GetClientTeam(victimClient))
        {
            
consecutiveKills[attackerClient] = 0;
            
            if(
settingConfig[TEAMKILL][NOT_BASED_ON_KILLS])
            {
                
soundId TEAMKILL;
            }        
        }
        else
        {
            
totalKills++;
            
            
decl String:weapon[64];
            
GetEventString(event"weapon"weaponsizeof(weapon));
            
#if defined CSS
                
new bool:headshot GetEventBool(event"headshot");
            
#elseif defined TF2
                
new customkill GetEventInt(event"customkill");
                new 
bool:headshot = (customkill == 1);
            
#elseif defined DODS
                
new bool:headshot = (hurtHitGroup[victimClient] == 1);            
            
#else
                
new bool:headshot false;
            
#endif        
            
            
consecutiveKills[attackerClient]++;
            if(
headshot)
            {
                
headShotCount[attackerClient]++;
            }            
[
COLOR="Red"]            new Float:tempLastKillTime lastKillTime[attackerClient];
            
lastKillTime[attackerClient] = GetEngineTime();            
            if(
tempLastKillTime == -1.0 || (lastKillTime[attackerClient] - tempLastKillTime) > 1.5)
            {
                
lastKillCount[attackerClient] = 1;
            }
            else
            {
                
lastKillCount[attackerClient]++;
            }[/
COLOR]

            if(
totalKills == && settingConfig[FIRSTBLOOD][NOT_BASED_ON_KILLS])
            {
                
soundId FIRSTBLOOD;
            }
            else if(
settingConfig[KILLSOUND][consecutiveKills[attackerClient]])
            {
                
soundId KILLSOUND;
                
killsValue consecutiveKills[attackerClient];
            }
            else if(
settingConfig[COMBO][lastKillCount[attackerClient]])
            {
                
soundId COMBO;
                
killsValue lastKillCount[attackerClient];
            }
            else if(
headshot && settingConfig[HEADSHOT][headShotCount[attackerClient]])
            {                
                
soundId HEADSHOT;
                
killsValue headShotCount[attackerClient];
            }
            else if(
headshot && settingConfig[HEADSHOT][NOT_BASED_ON_KILLS])
            {                
                
soundId HEADSHOT;
            }            
            
#if defined TF2
            
else if(customkill == && settingConfig[KNIFE][NOT_BASED_ON_KILLS])
            {
                
soundId KNIFE;
            }
            
#elseif defined CSS
            
else if((StrEqual(weapon"hegrenade") || StrEqual(weapon"smokegrenade") || StrEqual(weapon"flashbang")) && settingConfig[GRENADE][NOT_BASED_ON_KILLS])
            {
                
soundId GRENADE;
            }
            else if(
StrEqual(weapon"knife") && settingConfig[KNIFE][NOT_BASED_ON_KILLS])
            {
                
soundId KNIFE;
            }            
            
#elseif defined DODS
            
else if((StrEqual(weapon"riflegren_ger") || StrEqual(weapon"riflegren_us") || StrEqual(weapon"frag_ger") || StrEqual(weapon"frag_us") || StrEqual(weapon"smoke_ger") || StrEqual(weapon"smoke_us")) && settingConfig[GRENADE][NOT_BASED_ON_KILLS])
            {
                
soundId GRENADE;
            }
            else if((
StrEqual(weapon"spade") || StrEqual(weapon"amerknife") || StrEqual(weapon"punch")) && settingConfig[KNIFE][NOT_BASED_ON_KILLS])
            {
                
soundId KNIFE;
            }            
            
#elseif defined HL2DM
            
else if(StrEqual(weapon"grenade_frag") && settingConfig[GRENADE][NOT_BASED_ON_KILLS])
            {
                
soundId GRENADE;
            }
            else if((
StrEqual(weapon"stunstick") || StrEqual(weapon"crowbar")) && settingConfig[KNIFE][NOT_BASED_ON_KILLS])
            {
                
soundId KNIFE;
            }
            
#endif
        
}
    } 
Thanks again . Sorry for bad English..

Last edited by mewbie222; 11-05-2018 at 04:18.
mewbie222 is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 11-07-2018 , 17:49   Re: how to catch multikill ?
Reply With Quote #4

mewbie222, In Quake sound, author realized sequential count, not parallel. So, you can hear "multikill" beginning from 2 and more shoots, not from the first like in Bacardi version.
If you are planning something similar to QS, you have to save the last time when kill is happen (use GetEngineTime()) for particulat client and compare time delta in the next kill event. If delta < like 2 sec., add +1 to kill counter.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
mewbie222
Senior Member
Join Date: May 2018
Old 11-14-2018 , 05:02   Re: how to catch multikill ?
Reply With Quote #5

Quote:
Originally Posted by Dragokas View Post
mewbie222, In Quake sound, author realized sequential count, not parallel. So, you can hear "multikill" beginning from 2 and more shoots, not from the first like in Bacardi version.
If you are planning something similar to QS, you have to save the last time when kill is happen (use GetEngineTime()) for particulat client and compare time delta in the next kill event. If delta < like 2 sec., add +1 to kill counter.
okay, I just found the Bacardi code a little complicated. Now I see . And plus there I noticed that the frame is connected , and that's a little confused . And so I code above brought the QS , it seems a bit simpler code, and it would not experienced in programming in Sortmode it seemed easier this.
p.s. Sorry for my English

Last edited by mewbie222; 11-14-2018 at 05:03.
mewbie222 is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 11-14-2018 , 06:44   Re: how to catch multikill ?
Reply With Quote #6

While a pain in the ass. It seems possible to hook pure multikill per bullet.

1. Imagine each bullet is an actual entity.
2. AddTempEntHook to get the velocity of the bullet if possible, push an imaginary bullet index into a dynamic array that "belongs" to the client, and create a timer to remove the bullet from the array after the bullet would've reached maximal damage distance. ( Usually 8192 ) also make sure the bullet index array contains speed ( no need for velocity ) and initial origin and time the bullet was shot.

3. hook the moment of death, and iterate the bullets array to find any bullet which shouldv'e hit by now based on distance from victim to bullet origin relative to the speed of the bullet. To prevent false positives check if the hitting bullet makes sense ( same weapon as inflictor, attacker is the bullet's owner... ).

4. When the bullet disappears due to distance ( based on your timer, check how many kills the bullet made )
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334
eyal282 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 10:12.


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