AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   New Plugin Submissions (https://forums.alliedmods.net/forumdisplay.php?f=26)
-   -   D7 Kill Assist (https://forums.alliedmods.net/showthread.php?t=321887)

georgik57 03-05-2020 11:08

D7 Kill Assist
 
2 Attachment(s)
D i 5 7 i n c T's Kill Assist



http://bit.ly/D7ImgDesc
Enables kill assist. The player who has done the most damage to the killed victim(including the victim itself) will be shown as an assister in the death(frag) message.

Doesn't delay or alter the death message in any way.

Uses fake name change by sending messages to clients instead of changing it server-side, eliminating any compatibility issues with other plug-ins that rely on player name such as ranking plug-ins, etc.

Joined name parts are guaranteed to be different for better readability and as equal as possible in length at the same time.

Runs on any GoldSource(Half-Life 1) engine game.

Supports Counter-Strike: Condition Zero bots.



http://bit.ly/D7ImgSet
CVar: D7KADamageMin
Minimum damage required to consider an attacker as an assister.



http://bit.ly/D7ImgLang
None.



http://bit.ly/D7ImgNote
This plug-in requires the following:
- BitSum stocks include file (bitsums.inc). Attached along below.
- Optional: Ham Bots API. Latest version as of 2015 December 22 of the script(cs_ham_bots_api.sma) and include(cs_ham_bots_api.inc) are attached along below.

To enable support for CZ bots(Ham Bots API required), simply uncomment the following line and recompile:
PHP Code:

//#include <cs_ham_bots_api> 

-->
PHP Code:

#include <cs_ham_bots_api> 

Change the killer and assister names joiner by editing the following string and recompiling:
PHP Code:

new const g_szNameJoiner[] = " + "

Get source and compile locally.

Quote:

Originally Posted by georgik57 (Post 2777223)
I tested with default and latest HLTV on Windows and it worked just fine without crashing but the kill message showed as default(without assister/unmodified).
It looks like it's a Linux or ReHLTV problem.
Anyway, added a version that makes an exception and ignores HLTV in the first post which should fix the issue. Thanks for reporting. Have fun :)



http://bit.ly/D7ImgCredit
Spection - For his CS Revo Kill Assist plug-in from which I got the fake name change code.
MeRcyLeZZ - For his HamSandwich register bots API.
dorin2oo7 - For his images I used to style up my post.
NiHiLaNTh, schmurgel1983, KliPPy, meTaLiCroSS - For being true friends and always helping and teaching me new stuff.
Feedback - SoulWeaver16, q52888940, loc4lhost



http://bit.ly/D7ImgChange
Code:

To do:

T = needs testing
X = done
- = cancelled

[-] re-write with manual death message sending and restore name on name change(pre or post)
[X] re-write with fake name change(SVC_UPDATEUSERINFO)
v1.0.0
[T] fix damage taken not resetting for spawned player
v1.0.1
[T] make sure damage was taken
[T] correct friendly fire damage
[T] integer values
v1.0.4
[T] remove unnecessary connected cache
[X] fix crash when killer is not a valid and connected player
[T] reset damage from and done to player on client_putinserver instead of disconnect
[T] check if assister is connected
[T] remove unnecessary GetHamReturnStatus check
[T] remove unnecessary is_user_alive check on spawn
v1.1.0
[X] add minimum damage required to consider as assist
[X] test if a name can be longer than 31 characters when using the message
        1234567890123456789012345678901 killed self with trigger_hurt
[X] fix name joining code
[X] optimize name joining code
[X] increase name size to 32 in order to be able to have 31 character long names
[X] use charsmax instead of sizeof for g_szNameJoiner in calculations
[X] disable CZ bot support by default
v1.1.5
[ ] add individual messages for hltv
[ ] add forwards for sub-plugins
[ ] add support for zp infect when anti infection armor is on
[ ] add money, frag, ammo packs rewards for assist
[ ] overall optimization
[ ] name joiner easy customization through cvar



Code(for easy readability):
PHP Code:

// Modules
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

// Plug-in APIs
// Comment the next include to make it work without CZ bot support
//#include <cs_ham_bots_api>

// Stocks
#include <bitsums>
//#include <D7Debug>

const g_iSizeName 32;

new 
g_iMaxPlayers,
g_iIDPCVarKADamageMin,
g_iHealth,
g_iDamage[33][33],
g_iBsNameRestore;

new const 
g_szNameJoiner[] = " + ";
/*
new const g_szNamesTest[][g_iSizeName] =
{
    "1",
    "12",
    "123",
    "1234",
    "12345",
    "123456",
    "1234567",
    "12345678",
    "123456789",
    "1234567890",
    "12345678901",
    "123456789012",
    "1234567890123",
    "12345678901234",
    "123456789012345",
    "1234567890123456",
    "12345678901234567",
    "123456789012345678",
    "1234567890123456789",
    "12345678901234567890",
    "123456789012345.",
    "1234567890123456.",
    "12345678901234567.",
    "123456789012345678.",
    "1234567890123456789.",
    "12345678901234567890."
}*/

public plugin_init()
{
    
register_plugin("D7 Kill assist""1.1.5""D i 5 7 i n c T, Spection")
    
    
//register_event("HLTV", "fwEvHltvRoundStart", "a", "1=0", "2=0")
    
    
RegisterHam(Ham_Spawn"player""fwHamSpawnPlayer"1)
    
RegisterHam(Ham_TakeDamage"player""fwHamTakeDamagePlayerPre")
    
RegisterHam(Ham_TakeDamage"player""fwHamTakeDamagePlayer"1)
    
RegisterHam(Ham_Killed"player""fwHamKilledPlayerPre")
    
RegisterHam(Ham_Killed"player""fwHamKilledPlayer"1)
    
    
#if defined _cs_ham_bots_api_included
    
RegisterHamBots(Ham_Spawn"fwHamSpawnPlayer"1)
    
RegisterHamBots(Ham_TakeDamage"fwHamTakeDamagePlayerPre")
    
RegisterHamBots(Ham_TakeDamage"fwHamTakeDamagePlayer"1)
    
RegisterHamBots(Ham_Killed"fwHamKilledPlayerPre")
    
RegisterHamBots(Ham_Killed"fwHamKilledPlayer"1)
    
#endif
    
    
g_iMaxPlayers get_maxplayers();
    
    
g_iIDPCVarKADamageMin register_cvar("D7KADamageMin""1")
}
/*
public fwEvHltvRoundStart()
{
    client_print(0, print_center, "Round start")
    
    for (new iID = 1; iID <= g_iMaxPlayers; iID++)
        g_iDamage[iID] = Float:"";
}*/

public client_putinserver(iID)
{
    for (new 
iID2 1iID2 <= g_iMaxPlayersiID2++)
    {
        
g_iDamage[iID][iID2] = 0;
        
g_iDamage[iID2][iID] = 0;
    }
}

public 
fwHamSpawnPlayer(const iID)
{
    for (new 
iID2 1iID2 <= g_iMaxPlayersiID2++)
    {
        
g_iDamage[iID2][iID] = 0;
    }
}

public 
fwHamTakeDamagePlayerPre(const iIDVictim)//, const iIDInflictor, const iIDAttacker, const Float:fDamage, const iBsDamageType
{
    
g_iHealth get_user_health(iIDVictim);
}

public 
fwHamTakeDamagePlayer(const iIDVictim, const iIDInflictoriIDAttacker)//, const Float:fDamage, const iBsDamageType
{
    if (!(
<= iIDAttacker <= g_iMaxPlayers))
        
iIDAttacker iIDVictim;
    
    
g_iHealth -= get_user_health(iIDVictim);
    
    if (
g_iHealth <= 0)// || GetHamReturnStatus() == HAM_SUPERCEDE
        
return;
    
    
g_iDamage[iIDAttacker][iIDVictim] += g_iHealth;
}

// DeathMsg is triggered after fwHamKilledPlayerPre and before fwHamKilledPlayer
public fwHamKilledPlayerPre(const iIDVictimiIDAttacker)
{
    if (!(
<= iIDAttacker <= g_iMaxPlayers))
        
iIDAttacker iIDVictim;
    else if (!
is_user_connected(iIDAttacker))
        return;
    
    new 
iDamageiIDAssisteriTemp get_pcvar_num(g_iIDPCVarKADamageMin);
    
    for (new 
iID 1iID <= g_iMaxPlayersiID++)
    {
/*        if (g_iDamage[iID][iIDVictim])
            ftD7Log(_, _, "[fwHamKilledPlayerPre] iIDAttacker: ^"%s^". iIDAssister: ^"%s^". iIDVictim: ^"%s^". ^n\
            g_iDamage[%s][%s]: %.2f. iDamage: %d.",
            szNameAttacker, szNameAssister, g_szName[iIDVictim],
            g_szName[iID], g_szName[iIDVictim], g_iDamage[iID][iIDVictim], iDamage)
        */
        
if (iID == iIDAttacker || g_iDamage[iID][iIDVictim] < iTemp || iDamage >= g_iDamage[iID][iIDVictim] || !is_user_connected(iID))
        {
            
g_iDamage[iID][iIDVictim] = 0;
            
            continue;
        }
        
        
iIDAssister iID;
        
iDamage g_iDamage[iID][iIDVictim];
        
        
g_iDamage[iID][iIDVictim] = 0;
    }
    
    if (!
iIDAssister)
        return;
    
    new 
szNameAttacker[g_iSizeName], iLenAttackerszNameAssister[g_iSizeName], iLenAssister;
    
get_user_name(iIDAttackerszNameAttackercharsmax(szNameAttacker))
    
get_user_name(iIDAssisterszNameAssistercharsmax(szNameAssister))
    
//szNameAttacker = g_szNamesTest[random_num(0, sizeof g_szNamesTest - 1)];
    //szNameAssister = g_szNamesTest[random_num(0, sizeof g_szNamesTest - 1)];
    
iLenAttacker strlen(szNameAttacker);
    
iLenAssister strlen(szNameAssister);
    
    if (
iLenAttacker charsmax(g_szNameJoiner) + iLenAssister g_iSizeName)
    {
        
formatex(szNameAttacker[iLenAttacker], g_iSizeName iLenAttacker 1"%s%s"g_szNameJoinerszNameAssister)
    }
    else
    {
        
//ftD7Log(_, _, "[fwHamKilledPlayerPre] iIDAttacker: ^"%s^". iIDAssister: ^"%s^". iIDVictim: %d.", szNameAttacker, szNameAssister, iIDVictim)
        
        
static iLenNameEqualiLenNameEqualLoss;
        
        if (!
iLenNameEqual)
        {
            
iLenNameEqual floatround(1.0 * (g_iSizeName charsmax(g_szNameJoiner)) / 2floatround_floor);
            
iLenNameEqualLoss g_iSizeName - ((iLenNameEqual 2) + charsmax(g_szNameJoiner));
        }
        
        if (
iLenAttacker iLenNameEqual iLenNameEqualLoss)
        {
            
//ftD7Log(_, _, "[fwHamKilledPlayerPre] iLenAttacker(%d) < iLenNameEqual + iLenNameEqualLoss(%d).", iLenAttacker, iLenNameEqual + iLenNameEqualLoss)
            
formatex(szNameAttacker[iLenAttacker], g_iSizeName iLenAttacker"%s%s"g_szNameJoinerszNameAssister)
        }
        else if (
iLenAssister iLenNameEqual)
        {
            
//ftD7Log(_, _, "[fwHamKilledPlayerPre] iLenAssister(%d) < iLenNameEqual(%d).", iLenAssister, iLenNameEqual)
            
formatex(szNameAttacker[iLenNameEqual iLenNameEqualLoss + (iLenNameEqual iLenAssister)], g_iSizeName - (iLenNameEqual iLenNameEqualLoss + (iLenNameEqual iLenAssister)), "%s%s"g_szNameJoinerszNameAssister)
        }
        else
        {
            
//ftD7Log(_, _, "[fwHamKilledPlayerPre] Both iLenAttacker(%d) and iLenAssister(%d) are bigger than iLenNameEqual(%d)[+iLenNameEqualLoss(%d)].", iLenAttacker, iLenAssister, iLenNameEqual, iLenNameEqualLoss)
            
            
new iTemp;
            
            for (
iTemp 0iTemp <= ((iLenAttacker iLenAssister) ? (iLenAttacker 1) : (iLenAssister 1)); iTemp++)
            {
                if (
szNameAttacker[iTemp] != szNameAssister[iTemp] && szNameAttacker[iTemp] != ' ' && szNameAttacker[iTemp] != '    ')
                    break;
            }
            
            
iTemp += iLenNameEqual;
            
            if (
iTemp iLenAssister 1)
                
iTemp iLenAssister iLenNameEqual;
            
            
formatex(szNameAttacker[iLenNameEqual iLenNameEqualLoss], g_iSizeName - (iLenNameEqual iLenNameEqualLoss), "%s%s"g_szNameJoinerszNameAssister[iTemp])
        }
        
        
//ftD7Log(_, _, "[fwHamKilledPlayerPre] Joined name: ^"%s^".", szNameAttacker)
    
}
    
    
bitsum_add(g_iBsNameRestoreiIDAttacker)
    
    
message_begin(MSG_ALLSVC_UPDATEUSERINFO)
    
write_byte(iIDAttacker 1)
    
write_long(get_user_userid(iIDAttacker))
    
write_char('\')
    write_char('
n')
    write_char('
a')
    write_char('
m')
    write_char('
e')
    write_char('
\')
    write_string(szNameAttacker)
    for (iTemp = 0; iTemp < 16; iTemp++) write_byte(0)
    message_end()
}

public fwHamKilledPlayer(const iIDVictim, iIDAttacker)
{
    if (!(1 <= iIDAttacker <= g_iMaxPlayers))
        iIDAttacker = iIDVictim;
    
    if (!bitsum_get(g_iBsNameRestore, iIDAttacker))
        return;
    
    bitsum_del(g_iBsNameRestore, iIDAttacker)
    
    new szUserInfo[256]
    copy_infokey_buffer(engfunc(EngFunc_GetInfoKeyBuffer, iIDAttacker), szUserInfo, charsmax(szUserInfo))
    
    message_begin(MSG_ALL, SVC_UPDATEUSERINFO)
    write_byte(iIDAttacker - 1)
    write_long(get_user_userid(iIDAttacker))
    write_string(szUserInfo)
    write_long(0)
    write_long(0)
    write_long(0)
    write_long(0)
    message_end()




http://bit.ly/D7ImgDl
cs_ham_bots_api.sma
cs_ham_bots_api.inc
bitsums.inc

SoulWeaver16 11-05-2021 02:24

Re: D7 Kill Assist
 
I loved your plugin, it really works well with bots
A small bug, when shooting a friend and the enemy kills him, it appears in the feedkill as assistance, even though the FriendlyFire is not activated

georgik57 11-05-2021 11:13

Re: D7 Kill Assist
 
Quote:

Originally Posted by SoulWeaver16 (Post 2762529)
I loved your plugin, it really works well with bots
A small bug, when shooting a friend and the enemy kills him, it appears in the feedkill as assistance, even though the FriendlyFire is not activated

Weird, that means that damage is being registered for some reason. Try running it on a default add-on and see if still happens(I'm thinking some other plug-in might be causing this) and come back with a reply. Thanks for the feedback :)

SoulWeaver16 12-17-2021 17:17

Re: D7 Kill Assist
 
Quote:

Originally Posted by georgik57 (Post 2762555)
Weird, that means that damage is being registered for some reason. Try running it on a default add-on and see if still happens(I'm thinking some other plug-in might be causing this) and come back with a reply. Thanks for the feedback :)

I removed all my plugins and left only the defaults for AmxMod, D7KillAssist.amxx and cs_ham_bots_api.amxx
Still, shooting my teammates without FriendlyFire, when they kill them counts as an assist.
https://i.imgur.com/bpUDbdZ.png

georgik57 01-24-2022 12:30

Re: D7 Kill Assist
 
Quote:

Originally Posted by SoulWeaver16 (Post 2766338)
I removed all my plugins and left only the defaults for AmxMod, D7KillAssist.amxx and cs_ham_bots_api.amxx
Still, shooting my teammates without FriendlyFire, when they kill them counts as an assist.
https://i.imgur.com/bpUDbdZ.png

Fixed. Thank you for your feedback. You have been credited in the first post 8)

Updated. Check the first post for more information.

Napoleon_be 01-25-2022 18:41

Re: D7 Kill Assist
 
Highly underrated plugin in my opinion. Just wanted to leave my mark here, great job.

SoulWeaver16 02-10-2022 14:34

Re: D7 Kill Assist
 
Quote:

Originally Posted by georgik57 (Post 2769239)
Fixed. Thank you for your feedback. You have been credited in the first post 8)

Updated. Check the first post for more information.

I made many attempts, it's fixed, and I forgot to mention that it works fine in Zombie Mod, great plugin

georgik57 02-11-2022 19:17

Re: D7 Kill Assist
 
Quote:

Originally Posted by Napoleon_be (Post 2769396)
Highly underrated plugin in my opinion. Just wanted to leave my mark here, great job.

Quote:

Originally Posted by SoulWeaver16 (Post 2771073)
I made many attempts, it's fixed, and I forgot to mention that it works fine in Zombie Mod, great plugin

Thanks.
It doesn't officially support ZM but I'll probably add it in one of the next updates.

SoulWeaver16 02-12-2022 00:35

Re: D7 Kill Assist
 
Hey hi, here's another bug in [Zombie Mod] (I know it's not supported, I just provide reports)
The moment a bot/player dies because of the map, the server closes
Here is the example of the bot, which died in Vertigo due to falling and closed the game for me:
  • Brett killed self with trigger_hurt
I can't provide logs, because it doesn't show any errors, I don't know what the problem is, but I'll do more tests later. And my attempts in normal modes, it does not pass, so it's something only in Zombie mod

georgik57 02-12-2022 16:18

Re: D7 Kill Assist
 
I doubt the crash is happening because of this plug-in.
Try reproducing the events without it installed and see if it still happens.
Thanks for your feedback :)


All times are GMT -4. The time now is 05:50.

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